From 6d13c21d49bcc8b940a112113f84e35f056d20e9 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Sat, 7 Jun 2014 23:50:30 +0100 Subject: [PATCH] Update the ws2811 led strip code for orientation and battery warning. When armed the first half of the strip is green the second half is red. When disarmed the strip is various shades of red. When the battery is low the strip will flash. --- src/main/mw.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main/mw.c b/src/main/mw.c index 1d45ffb6cb..59e431dc10 100755 --- a/src/main/mw.c +++ b/src/main/mw.c @@ -348,19 +348,18 @@ void updateInflightCalibrationState(void) } } -static const uint8_t colors[][3] = +static const uint8_t stripOrientation[][3] = { + {0, 255, 0}, + {0, 255, 0}, + {0, 255, 0}, + {0, 255, 0}, + {0, 255, 0}, + + {255, 0, 0}, + {255, 0, 0}, + {255, 0, 0}, {255, 0, 0}, - {0, 255, 0}, - {0, 0, 255}, - {255, 0, 255}, - - {255, 255, 255}, - {255, 255, 255}, - - {255, 255, 0}, - {0, 0, 255}, - {0, 255, 0}, {255, 0, 0} }; @@ -395,13 +394,13 @@ static const uint8_t stripRed[][3] = uint32_t lastStripUpdateAt = 0; -#define LED_STRIP_50HZ ((1000 * 1000) / 50) +#define LED_STRIP_10HZ ((1000 * 1000) / 10) void updateLedStrip(void) { uint32_t now = micros(); - if (now - lastStripUpdateAt < LED_STRIP_50HZ) { + if (now - lastStripUpdateAt < LED_STRIP_10HZ) { return; } @@ -411,13 +410,15 @@ void updateLedStrip(void) if (stripState == 0) { if (f.ARMED) { - ws2812SetStripColors(stripRed, 10); + ws2812SetStripColors(stripOrientation, sizeof(stripOrientation) / sizeof(stripOrientation[0])); } else { - ws2812SetStripColors(colors, 10); + ws2812SetStripColors(stripRed, sizeof(stripRed) / sizeof(stripRed[0])); } stripState = 1; } else { - ws2812SetStripColors(stripOff, 10); + if (feature(FEATURE_VBAT) && shouldSoundBatteryAlarm()) { + ws2812SetStripColors(stripOff, sizeof(stripOff) / sizeof(stripOff[0])); + } stripState = 0; } }