Skip to content

Commit

Permalink
change hue calculation + higher max frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
ASDosjani committed Aug 6, 2023
1 parent 492598f commit eacd048
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/cli/settings.c
Expand Up @@ -1315,7 +1315,7 @@ const clivalue_t valueTable[] = {
{ "ledstrip_beacon_armed_only", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_LED_STRIP_CONFIG, offsetof(ledStripConfig_t, ledstrip_beacon_armed_only) },
{ "ledstrip_brightness", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 5, 100 }, PG_LED_STRIP_CONFIG, offsetof(ledStripConfig_t, ledstrip_brightness) },
{ "ledstrip_rainbow_delta", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, HSV_HUE_MAX }, PG_LED_STRIP_CONFIG, offsetof(ledStripConfig_t, ledstrip_rainbow_delta) },
{ "ledstrip_rainbow_freq", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 1, 200 }, PG_LED_STRIP_CONFIG, offsetof(ledStripConfig_t, ledstrip_rainbow_freq) },
{ "ledstrip_rainbow_freq", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 1, 500 }, PG_LED_STRIP_CONFIG, offsetof(ledStripConfig_t, ledstrip_rainbow_freq) },
#endif

// PG_SDCARD_CONFIG
Expand Down
8 changes: 4 additions & 4 deletions src/main/io/ledstrip.c
Expand Up @@ -898,26 +898,26 @@ static void applyLedThrustRingLayer(bool updateNow, timeUs_t *timer)

static void applyRainbowLayer(bool updateNow, timeUs_t *timer)
{
//use offset as a fixed point number
static int offset = 0;

if (updateNow) {
*timer += HZ_TO_US(ledStripConfig()->ledstrip_rainbow_freq);
offset += ledStripConfig()->ledstrip_rainbow_freq;
*timer += HZ_TO_US(100);
}

uint8_t rainbowLedIndex = 0;

for (unsigned i = 0; i < ledCounts.count; i++) {
const ledConfig_t *ledConfig = &ledStripStatusModeConfig()->ledConfigs[i];
if (ledGetOverlayBit(ledConfig, LED_OVERLAY_RAINBOW)) {
hsvColor_t ledColor;
ledColor.h = (offset + (rainbowLedIndex * ledStripConfig()->ledstrip_rainbow_delta)) % HSV_HUE_MAX;
ledColor.h = (offset / 100 + (rainbowLedIndex * ledStripConfig()->ledstrip_rainbow_delta)) % (HSV_HUE_MAX + 1);
ledColor.s = 0;
ledColor.v = HSV_VALUE_MAX;
setLedHsv(i, &ledColor);
rainbowLedIndex++;
}
}
offset++;
}

typedef struct larsonParameters_s {
Expand Down

0 comments on commit eacd048

Please sign in to comment.