mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 21:35:44 +03:00
Merge pull request #1419 from mikeller/ledstrip_hue_overlay_cli_fix
Enable using of any RC channel to set the color hue modifier.
This commit is contained in:
commit
f17895db30
7 changed files with 24 additions and 5 deletions
|
@ -166,6 +166,7 @@ typedef struct master_s {
|
||||||
modeColorIndexes_t modeColors[LED_MODE_COUNT];
|
modeColorIndexes_t modeColors[LED_MODE_COUNT];
|
||||||
specialColorIndexes_t specialColors;
|
specialColorIndexes_t specialColors;
|
||||||
uint8_t ledstrip_visual_beeper; // suppress LEDLOW mode if beeper is on
|
uint8_t ledstrip_visual_beeper; // suppress LEDLOW mode if beeper is on
|
||||||
|
rc_alias_e ledstrip_aux_channel;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TRANSPONDER
|
#ifdef TRANSPONDER
|
||||||
|
|
|
@ -672,6 +672,7 @@ void createDefaultConfig(master_t *config)
|
||||||
applyDefaultModeColors(config->modeColors);
|
applyDefaultModeColors(config->modeColors);
|
||||||
applyDefaultSpecialColors(&(config->specialColors));
|
applyDefaultSpecialColors(&(config->specialColors));
|
||||||
config->ledstrip_visual_beeper = 0;
|
config->ledstrip_visual_beeper = 0;
|
||||||
|
config->ledstrip_aux_channel = THROTTLE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef VTX
|
#ifdef VTX
|
||||||
|
|
|
@ -960,6 +960,11 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
|
||||||
sbufWriteU8(dst, j);
|
sbufWriteU8(dst, j);
|
||||||
sbufWriteU8(dst, masterConfig.specialColors.color[j]);
|
sbufWriteU8(dst, masterConfig.specialColors.color[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sbufWriteU8(dst, LED_AUX_CHANNEL);
|
||||||
|
sbufWriteU8(dst, 0);
|
||||||
|
sbufWriteU8(dst, masterConfig.ledstrip_aux_channel);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -170,6 +170,7 @@ static const specialColorIndexes_t defaultSpecialColors[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static int scaledThrottle;
|
static int scaledThrottle;
|
||||||
|
static int scaledAux;
|
||||||
|
|
||||||
static void updateLedRingCounts(void);
|
static void updateLedRingCounts(void);
|
||||||
|
|
||||||
|
@ -253,7 +254,7 @@ bool parseLedStripConfig(int ledIndex, const char *config)
|
||||||
RING_COLORS,
|
RING_COLORS,
|
||||||
PARSE_STATE_COUNT
|
PARSE_STATE_COUNT
|
||||||
};
|
};
|
||||||
static const char chunkSeparators[PARSE_STATE_COUNT] = {',', ':', ':',':', '\0'};
|
static const char chunkSeparators[PARSE_STATE_COUNT] = {',', ':', ':', ':', '\0'};
|
||||||
|
|
||||||
ledConfig_t *ledConfig = &masterConfig.ledConfigs[ledIndex];
|
ledConfig_t *ledConfig = &masterConfig.ledConfigs[ledIndex];
|
||||||
memset(ledConfig, 0, sizeof(ledConfig_t));
|
memset(ledConfig, 0, sizeof(ledConfig_t));
|
||||||
|
@ -492,7 +493,7 @@ static void applyLedFixedLayers()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ledGetOverlayBit(ledConfig, LED_OVERLAY_THROTTLE)) {
|
if (ledGetOverlayBit(ledConfig, LED_OVERLAY_THROTTLE)) {
|
||||||
hOffset += ((scaledThrottle - 10) * 4) / 3;
|
hOffset += scaledAux;
|
||||||
}
|
}
|
||||||
|
|
||||||
color.h = (color.h + hOffset) % (HSV_HUE_MAX + 1);
|
color.h = (color.h + hOffset) % (HSV_HUE_MAX + 1);
|
||||||
|
@ -962,6 +963,7 @@ void ledStripUpdate(uint32_t currentTime)
|
||||||
// apply all layers; triggered timed functions has to update timers
|
// apply all layers; triggered timed functions has to update timers
|
||||||
|
|
||||||
scaledThrottle = ARMING_FLAG(ARMED) ? scaleRange(rcData[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX, 10, 100) : 10;
|
scaledThrottle = ARMING_FLAG(ARMED) ? scaleRange(rcData[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX, 10, 100) : 10;
|
||||||
|
scaledAux = scaleRange(rcData[masterConfig.ledstrip_aux_channel], PWM_RANGE_MIN, PWM_RANGE_MAX, 0, HSV_HUE_MAX + 1);
|
||||||
|
|
||||||
applyLedFixedLayers();
|
applyLedFixedLayers();
|
||||||
|
|
||||||
|
@ -1035,6 +1037,10 @@ bool setModeColor(ledModeIndex_e modeIndex, int modeColorIndex, int colorIndex)
|
||||||
if (modeColorIndex < 0 || modeColorIndex >= LED_SPECIAL_COLOR_COUNT)
|
if (modeColorIndex < 0 || modeColorIndex >= LED_SPECIAL_COLOR_COUNT)
|
||||||
return false;
|
return false;
|
||||||
masterConfig.specialColors.color[modeColorIndex] = colorIndex;
|
masterConfig.specialColors.color[modeColorIndex] = colorIndex;
|
||||||
|
} else if (modeIndex == LED_AUX_CHANNEL) {
|
||||||
|
if (modeColorIndex < 0 || modeColorIndex >= 1)
|
||||||
|
return false;
|
||||||
|
masterConfig.ledstrip_aux_channel = colorIndex;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,8 @@ typedef enum {
|
||||||
LED_MODE_ANGLE,
|
LED_MODE_ANGLE,
|
||||||
LED_MODE_MAG,
|
LED_MODE_MAG,
|
||||||
LED_MODE_BARO,
|
LED_MODE_BARO,
|
||||||
LED_SPECIAL
|
LED_SPECIAL,
|
||||||
|
LED_AUX_CHANNEL
|
||||||
} ledModeIndex_e;
|
} ledModeIndex_e;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
@ -1797,13 +1797,18 @@ static void printModeColor(uint8_t dumpMask, master_t *defaultConfig)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *format = "mode_color %u %u %u\r\n";
|
||||||
for (uint32_t j = 0; j < LED_SPECIAL_COLOR_COUNT; j++) {
|
for (uint32_t j = 0; j < LED_SPECIAL_COLOR_COUNT; j++) {
|
||||||
int colorIndex = masterConfig.specialColors.color[j];
|
int colorIndex = masterConfig.specialColors.color[j];
|
||||||
int colorIndexDefault = defaultConfig->specialColors.color[j];
|
int colorIndexDefault = defaultConfig->specialColors.color[j];
|
||||||
const char *format = "mode_color %u %u %u\r\n";
|
|
||||||
cliDefaultPrintf(dumpMask, colorIndex == colorIndexDefault, format, LED_SPECIAL, j, colorIndexDefault);
|
cliDefaultPrintf(dumpMask, colorIndex == colorIndexDefault, format, LED_SPECIAL, j, colorIndexDefault);
|
||||||
cliDumpPrintf(dumpMask, colorIndex == colorIndexDefault, format, LED_SPECIAL, j, colorIndex);
|
cliDumpPrintf(dumpMask, colorIndex == colorIndexDefault, format, LED_SPECIAL, j, colorIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ledStripAuxChannel = masterConfig.ledstrip_aux_channel;
|
||||||
|
int ledStripAuxChannelDefault = defaultConfig->ledstrip_aux_channel;
|
||||||
|
cliDefaultPrintf(dumpMask, ledStripAuxChannel == ledStripAuxChannelDefault, format, LED_AUX_CHANNEL, 0, ledStripAuxChannelDefault);
|
||||||
|
cliDumpPrintf(dumpMask, ledStripAuxChannel == ledStripAuxChannelDefault, format, LED_AUX_CHANNEL, 0, ledStripAuxChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cliModeColor(char *cmdline)
|
static void cliModeColor(char *cmdline)
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
#define MSP_PROTOCOL_VERSION 0
|
#define MSP_PROTOCOL_VERSION 0
|
||||||
|
|
||||||
#define API_VERSION_MAJOR 1 // increment when major changes are made
|
#define API_VERSION_MAJOR 1 // increment when major changes are made
|
||||||
#define API_VERSION_MINOR 21 // increment when any change is made, reset to zero when major changes are released after changing API_VERSION_MAJOR
|
#define API_VERSION_MINOR 22 // increment when any change is made, reset to zero when major changes are released after changing API_VERSION_MAJOR
|
||||||
|
|
||||||
#define API_VERSION_LENGTH 2
|
#define API_VERSION_LENGTH 2
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue