Update LED throttle mode to use rcData instead of rcThrottle, avoid
having to reference min/maxThrottle. Range was not being calculated correctly. Throttle color now blends with the current color of the LED so that at mid throttle any orientation color is still correct when mixing Throttle and Flight Mode on an LED. Fix tabs. Reduce nesting level.
This commit is contained in:
parent
9723df947e
commit
d904741f43
|
@ -42,6 +42,11 @@ void setLedHsv(uint16_t index, const hsvColor_t *color)
|
|||
ledColorBuffer[index] = *color;
|
||||
}
|
||||
|
||||
void getLedHsv(uint16_t index, hsvColor_t *color)
|
||||
{
|
||||
*color = ledColorBuffer[index];
|
||||
}
|
||||
|
||||
void setLedValue(uint16_t index, const uint8_t value)
|
||||
{
|
||||
ledColorBuffer[index].v = value;
|
||||
|
|
|
@ -31,6 +31,8 @@ void ws2811LedStripDMAEnable(void);
|
|||
void ws2811UpdateStrip(void);
|
||||
|
||||
void setLedHsv(uint16_t index, const hsvColor_t *color);
|
||||
void getLedHsv(uint16_t index, hsvColor_t *color);
|
||||
|
||||
void scaleLedValue(uint16_t index, const uint8_t scalePercent);
|
||||
void setLedValue(uint16_t index, const uint8_t value);
|
||||
|
||||
|
|
|
@ -643,15 +643,21 @@ void applyLedIndicatorLayer(uint8_t indicatorFlashState)
|
|||
void applyLedThrottleLayer()
|
||||
{
|
||||
const ledConfig_t *ledConfig;
|
||||
hsvColor_t color;
|
||||
|
||||
uint8_t ledIndex;
|
||||
for (ledIndex = 0; ledIndex < ledCount; ledIndex++) {
|
||||
ledConfig = &ledConfigs[ledIndex];
|
||||
if(ledConfig->flags & LED_FUNCTION_THROTTLE) {
|
||||
int hue = scaleRange(rcCommand[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX, hsv_lightBlue.h, hsv_red.h);
|
||||
hsvColor_t color = {hue , 0 , 255};
|
||||
setLedHsv(ledIndex, &color);
|
||||
}
|
||||
ledConfig = &ledConfigs[ledIndex];
|
||||
if(!(ledConfig->flags & LED_FUNCTION_THROTTLE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
getLedHsv(ledIndex, &color);
|
||||
|
||||
int scaled = scaleRange(rcData[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX, -60, +60);
|
||||
scaled += HSV_HUE_MAX;
|
||||
color.h = scaled % HSV_HUE_MAX;
|
||||
setLedHsv(ledIndex, &color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,3 +65,4 @@ void generateLedConfig(uint8_t ledIndex, char *ledConfigBuffer, size_t bufferSiz
|
|||
|
||||
bool parseColor(uint8_t index, char *colorConfig);
|
||||
void applyDefaultColors(hsvColor_t *colors, uint8_t colorCount);
|
||||
|
||||
|
|
Loading…
Reference in New Issue