1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-24 00:35:39 +03:00

Fixed ordering of the LED_STRIP overlays.

This commit is contained in:
mikeller 2018-11-03 18:01:09 +13:00
parent 44f19bd128
commit 09353a2b5d

View file

@ -86,8 +86,6 @@ static bool ledStripEnabled = true;
static void ledStripDisable(void);
//#define USE_LED_ANIMATION
#define HZ_TO_US(hz) ((int32_t)((1000 * 1000) / (hz)))
#define MAX_TIMER_DELAY (5 * 1000 * 1000)
@ -960,55 +958,21 @@ static void applyLedBlinkLayer(bool updateNow, timeUs_t *timer)
}
}
#ifdef USE_LED_ANIMATION
static void applyLedAnimationLayer(bool updateNow, timeUs_t *timer)
{
static uint8_t frameCounter = 0;
const int animationFrames = ledGridRows;
if (updateNow) {
frameCounter = (frameCounter + 1 < animationFrames) ? frameCounter + 1 : 0;
*timer += HZ_TO_US(20);
}
if (ARMING_FLAG(ARMED))
return;
int previousRow = frameCounter > 0 ? frameCounter - 1 : animationFrames - 1;
int currentRow = frameCounter;
int nextRow = (frameCounter + 1 < animationFrames) ? frameCounter + 1 : 0;
for (int ledIndex = 0; ledIndex < ledCounts.count; ledIndex++) {
const ledConfig_t *ledConfig = &ledStripConfig()->ledConfigs[ledIndex];
if (ledGetY(ledConfig) == previousRow) {
setLedHsv(ledIndex, getSC(LED_SCOLOR_ANIMATION));
scaleLedValue(ledIndex, 50);
} else if (ledGetY(ledConfig) == currentRow) {
setLedHsv(ledIndex, getSC(LED_SCOLOR_ANIMATION));
} else if (ledGetY(ledConfig) == nextRow) {
scaleLedValue(ledIndex, 50);
}
}
}
#endif
// In reverse order of priority
typedef enum {
timBlink,
timLarson,
timBattery,
timRssi,
#ifdef USE_GPS
timGps,
#endif
timWarning,
timRing,
timIndicator,
#ifdef USE_VTX_COMMON
timVtx,
#endif
timIndicator,
#ifdef USE_LED_ANIMATION
timAnimation,
#ifdef USE_GPS
timGps,
#endif
timRing,
timBattery,
timRssi,
timWarning,
timTimerCount
} timId_e;
@ -1037,9 +1001,6 @@ static applyLayerFn_timed* layerTable[] = {
[timVtx] = &applyLedVtxLayer,
#endif
[timIndicator] = &applyLedIndicatorLayer,
#ifdef USE_LED_ANIMATION
[timAnimation] = &applyLedAnimationLayer,
#endif
[timRing] = &applyLedThrustRingLayer
};