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:
Michael Keller 2016-11-04 16:29:16 +13:00 committed by GitHub
commit f17895db30
7 changed files with 24 additions and 5 deletions

View File

@ -166,6 +166,7 @@ typedef struct master_s {
modeColorIndexes_t modeColors[LED_MODE_COUNT];
specialColorIndexes_t specialColors;
uint8_t ledstrip_visual_beeper; // suppress LEDLOW mode if beeper is on
rc_alias_e ledstrip_aux_channel;
#endif
#ifdef TRANSPONDER

View File

@ -672,6 +672,7 @@ void createDefaultConfig(master_t *config)
applyDefaultModeColors(config->modeColors);
applyDefaultSpecialColors(&(config->specialColors));
config->ledstrip_visual_beeper = 0;
config->ledstrip_aux_channel = THROTTLE;
#endif
#ifdef VTX

View File

@ -960,6 +960,11 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
sbufWriteU8(dst, j);
sbufWriteU8(dst, masterConfig.specialColors.color[j]);
}
sbufWriteU8(dst, LED_AUX_CHANNEL);
sbufWriteU8(dst, 0);
sbufWriteU8(dst, masterConfig.ledstrip_aux_channel);
break;
#endif

View File

@ -170,6 +170,7 @@ static const specialColorIndexes_t defaultSpecialColors[] = {
};
static int scaledThrottle;
static int scaledAux;
static void updateLedRingCounts(void);
@ -253,7 +254,7 @@ bool parseLedStripConfig(int ledIndex, const char *config)
RING_COLORS,
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];
memset(ledConfig, 0, sizeof(ledConfig_t));
@ -492,7 +493,7 @@ static void applyLedFixedLayers()
}
if (ledGetOverlayBit(ledConfig, LED_OVERLAY_THROTTLE)) {
hOffset += ((scaledThrottle - 10) * 4) / 3;
hOffset += scaledAux;
}
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
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();
@ -1035,6 +1037,10 @@ bool setModeColor(ledModeIndex_e modeIndex, int modeColorIndex, int colorIndex)
if (modeColorIndex < 0 || modeColorIndex >= LED_SPECIAL_COLOR_COUNT)
return false;
masterConfig.specialColors.color[modeColorIndex] = colorIndex;
} else if (modeIndex == LED_AUX_CHANNEL) {
if (modeColorIndex < 0 || modeColorIndex >= 1)
return false;
masterConfig.ledstrip_aux_channel = colorIndex;
} else {
return false;
}

View File

@ -75,7 +75,8 @@ typedef enum {
LED_MODE_ANGLE,
LED_MODE_MAG,
LED_MODE_BARO,
LED_SPECIAL
LED_SPECIAL,
LED_AUX_CHANNEL
} ledModeIndex_e;
typedef enum {

View File

@ -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++) {
int colorIndex = masterConfig.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);
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)

View File

@ -59,7 +59,7 @@
#define MSP_PROTOCOL_VERSION 0
#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