mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 01:05:27 +03:00
Update LED ring code to have the documented behavior.
The logic is greatly simplified compared to the code in the original pull request.
This commit is contained in:
parent
b50c5d9724
commit
9fb1863d74
1 changed files with 8 additions and 8 deletions
|
@ -744,29 +744,29 @@ void applyLedThrottleLayer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ROTATION_SEQUENCE_LED_COUNT 6 // 2 on, 4 off
|
||||||
|
#define ROTATION_SEQUENCE_LED_WIDTH 2
|
||||||
|
|
||||||
void applyLedThrustRingLayer(void)
|
void applyLedThrustRingLayer(void)
|
||||||
{
|
{
|
||||||
uint8_t ledIndex;
|
uint8_t ledIndex;
|
||||||
static uint8_t rotationPhase = 0;
|
static uint8_t rotationPhase = ROTATION_SEQUENCE_LED_COUNT;
|
||||||
bool nextLedOn = false;
|
bool nextLedOn = false;
|
||||||
hsvColor_t ringColor;
|
hsvColor_t ringColor;
|
||||||
const ledConfig_t *ledConfig;
|
const ledConfig_t *ledConfig;
|
||||||
|
|
||||||
uint8_t phaseCount = ledsInRingCount / 2;
|
|
||||||
|
|
||||||
uint8_t ledRingIndex = 0;
|
uint8_t ledRingIndex = 0;
|
||||||
for (ledIndex = 0; ledIndex < ledCount; ledIndex++) {
|
for (ledIndex = 0; ledIndex < ledCount; ledIndex++) {
|
||||||
|
|
||||||
ledConfig = &ledConfigs[ledIndex];
|
ledConfig = &ledConfigs[ledIndex];
|
||||||
|
|
||||||
|
|
||||||
if ((ledConfig->flags & LED_FUNCTION_THRUST_RING) == 0) {
|
if ((ledConfig->flags & LED_FUNCTION_THRUST_RING) == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool applyColor = false;
|
bool applyColor = false;
|
||||||
if (ARMING_FLAG(ARMED)) {
|
if (ARMING_FLAG(ARMED)) {
|
||||||
if (ledRingIndex == rotationPhase || ledIndex == rotationPhase + phaseCount) {
|
if ((ledRingIndex + rotationPhase) % ROTATION_SEQUENCE_LED_COUNT < ROTATION_SEQUENCE_LED_WIDTH) {
|
||||||
applyColor = true;
|
applyColor = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -787,9 +787,9 @@ void applyLedThrustRingLayer(void)
|
||||||
ledRingIndex++;
|
ledRingIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
rotationPhase++;
|
rotationPhase--;
|
||||||
if (rotationPhase == phaseCount) {
|
if (rotationPhase == 0) {
|
||||||
rotationPhase = 0;
|
rotationPhase = ROTATION_SEQUENCE_LED_COUNT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue