From 2f14f6119039b6feee9a2388253cf608f7fbf60e Mon Sep 17 00:00:00 2001 From: mikeller Date: Tue, 23 Aug 2016 01:21:19 +1200 Subject: [PATCH] Fixed lockups on LED_STRIP configuration. --- src/main/io/ledstrip.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/io/ledstrip.c b/src/main/io/ledstrip.c index 4af92de4d3..c41c3a884b 100644 --- a/src/main/io/ledstrip.c +++ b/src/main/io/ledstrip.c @@ -257,10 +257,10 @@ STATIC_UNIT_TESTED void determineLedStripDimensions(void) STATIC_UNIT_TESTED void determineOrientationLimits(void) { - highestYValueForNorth = (ledGridHeight / 2) - 1; - lowestYValueForSouth = ((ledGridHeight + 1) / 2); - highestXValueForWest = (ledGridWidth / 2) - 1; - lowestXValueForEast = ((ledGridWidth + 1) / 2); + highestYValueForNorth = MIN((ledGridHeight / 2) - 1, 0); + lowestYValueForSouth = (ledGridHeight + 1) / 2; + highestXValueForWest = MIN((ledGridWidth / 2) - 1, 0); + lowestXValueForEast = (ledGridWidth + 1) / 2; } STATIC_UNIT_TESTED void updateLedCount(void) @@ -533,7 +533,11 @@ static void applyLedFixedLayers() case LED_FUNCTION_FLIGHT_MODE: for (unsigned i = 0; i < ARRAYLEN(flightModeToLed); i++) if (!flightModeToLed[i].flightMode || FLIGHT_MODE(flightModeToLed[i].flightMode)) { - color = *getDirectionalModeColor(ledIndex, &masterConfig.modeColors[flightModeToLed[i].ledMode]); + hsvColor_t *directionalColor = getDirectionalModeColor(ledIndex, &masterConfig.modeColors[flightModeToLed[i].ledMode]); + if (directionalColor) { + color = *directionalColor; + } + break; // stop on first match } break;