mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-21 15:25:36 +03:00
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
4 changed files with 20 additions and 6 deletions
|
@ -42,6 +42,11 @@ void setLedHsv(uint16_t index, const hsvColor_t *color)
|
||||||
ledColorBuffer[index] = *color;
|
ledColorBuffer[index] = *color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void getLedHsv(uint16_t index, hsvColor_t *color)
|
||||||
|
{
|
||||||
|
*color = ledColorBuffer[index];
|
||||||
|
}
|
||||||
|
|
||||||
void setLedValue(uint16_t index, const uint8_t value)
|
void setLedValue(uint16_t index, const uint8_t value)
|
||||||
{
|
{
|
||||||
ledColorBuffer[index].v = value;
|
ledColorBuffer[index].v = value;
|
||||||
|
|
|
@ -31,6 +31,8 @@ void ws2811LedStripDMAEnable(void);
|
||||||
void ws2811UpdateStrip(void);
|
void ws2811UpdateStrip(void);
|
||||||
|
|
||||||
void setLedHsv(uint16_t index, const hsvColor_t *color);
|
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 scaleLedValue(uint16_t index, const uint8_t scalePercent);
|
||||||
void setLedValue(uint16_t index, const uint8_t value);
|
void setLedValue(uint16_t index, const uint8_t value);
|
||||||
|
|
||||||
|
|
|
@ -643,15 +643,21 @@ void applyLedIndicatorLayer(uint8_t indicatorFlashState)
|
||||||
void applyLedThrottleLayer()
|
void applyLedThrottleLayer()
|
||||||
{
|
{
|
||||||
const ledConfig_t *ledConfig;
|
const ledConfig_t *ledConfig;
|
||||||
|
hsvColor_t color;
|
||||||
|
|
||||||
uint8_t ledIndex;
|
uint8_t ledIndex;
|
||||||
for (ledIndex = 0; ledIndex < ledCount; ledIndex++) {
|
for (ledIndex = 0; ledIndex < ledCount; ledIndex++) {
|
||||||
ledConfig = &ledConfigs[ledIndex];
|
ledConfig = &ledConfigs[ledIndex];
|
||||||
if(ledConfig->flags & LED_FUNCTION_THROTTLE) {
|
if(!(ledConfig->flags & LED_FUNCTION_THROTTLE)) {
|
||||||
int hue = scaleRange(rcCommand[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX, hsv_lightBlue.h, hsv_red.h);
|
continue;
|
||||||
hsvColor_t color = {hue , 0 , 255};
|
}
|
||||||
setLedHsv(ledIndex, &color);
|
|
||||||
}
|
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);
|
bool parseColor(uint8_t index, char *colorConfig);
|
||||||
void applyDefaultColors(hsvColor_t *colors, uint8_t colorCount);
|
void applyDefaultColors(hsvColor_t *colors, uint8_t colorCount);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue