Skip to content

Commit

Permalink
Revert "tentative: remove LED function rssi"
Browse files Browse the repository at this point in the history
This reverts commit b9bbc61.
  • Loading branch information
gaelj committed May 11, 2016
1 parent b4729ec commit bfe7a9e
Showing 1 changed file with 9 additions and 30 deletions.
39 changes: 9 additions & 30 deletions src/main/io/ledstrip.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,16 +367,16 @@ bool parseLedStripConfig(uint8_t ledIndex, const char *config)
int val;

int parseState = X_COORDINATE;
bool result = true;
bool ok = true;

if (ledIndex >= MAX_LED_STRIP_LENGTH) {
return !result;
return !ok;
}

ledConfig_t *ledConfig = ledConfigs(ledIndex);
memset(ledConfig, 0, sizeof(ledConfig_t));

while (result) {
while (ok) {

char chunkSeparator = chunkSeparators[parseState];

Expand All @@ -388,7 +388,7 @@ bool parseLedStripConfig(uint8_t ledIndex, const char *config)
}

if (*config++ != chunkSeparator) {
result = false;
ok = false;
break;
}

Expand Down Expand Up @@ -442,13 +442,13 @@ bool parseLedStripConfig(uint8_t ledIndex, const char *config)
}
}

if (!result) {
if (!ok) {
memset(ledConfig, 0, sizeof(ledConfig_t));
}

reevalulateLedConfig();

return result;
return ok;
}

void generateLedConfig(uint8_t ledIndex, char *ledConfigBuffer, size_t bufferSize)
Expand Down Expand Up @@ -731,7 +731,6 @@ void applyLedIndicatorLayer(uint8_t indicatorFlashState)
}
}

/*
void applyLedHue(uint16_t flag, int16_t value, int16_t minRange, int16_t maxRange)
{
int scaled = scaleRange(value, minRange, maxRange, -60, +60);
Expand All @@ -748,25 +747,6 @@ void applyLedHue(uint16_t flag, int16_t value, int16_t minRange, int16_t maxRang
setLedHsv(i, &color);
}
}
*/

void applyLedThrottle()
{
int scaled = scaleRange(rcData[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX, -60, +60);
scaled += HSV_HUE_MAX; // wrap negative values correctly

for (int i = 0; i < ledCount; ++i) {
const ledConfig_t *ledConfig = ledConfigs(i);
if (!(ledConfig->flags & LED_FUNCTION_THROTTLE))
continue;

hsvColor_t color;
getLedHsv(i, &color);
color.h = (color.h + scaled) % (HSV_HUE_MAX + 1);
setLedHsv(i, &color);
}
}


#define ROTATION_SEQUENCE_LED_COUNT 6 // 2 on, 4 off
#define ROTATION_SEQUENCE_LED_WIDTH 2
Expand Down Expand Up @@ -941,9 +921,8 @@ void updateLedStrip(void)

// LAYER 1
applyLedModeLayer();
// applyLedHue(LED_FUNCTION_THROTTLE, rcData[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX);
// applyLedHue(LED_FUNCTION_RSSI, rssi, 0, 1023);
applyLedThrottle();
applyLedHue(LED_FUNCTION_THROTTLE, rcData[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX);
applyLedHue(LED_FUNCTION_RSSI, rssi, 0, 1023);

// LAYER 2
if (warningFlashNow) {
Expand Down Expand Up @@ -1150,7 +1129,7 @@ void pgResetFn_colors(hsvColor_t *instance)
{
BUILD_BUG_ON(ARRAYLEN(*colors_arr()) <= ARRAYLEN(defaultColors));

for (unsigned colorIndex = 0; colorIndex < ARRAYLEN(defaultColors); colorIndex++) {
for (int colorIndex = 0; colorIndex < ARRAYLEN(defaultColors); colorIndex++) {
*instance++ = *defaultColors[colorIndex];
}
}
Expand Down

0 comments on commit bfe7a9e

Please sign in to comment.