fix rgb program 1, 2, and 3
This commit is contained in:
parent
d24d0b6d03
commit
51239bffa7
|
@ -45,6 +45,15 @@ void userconf_load()
|
|||
userconf.ledprog_setting[0][0] = 2; // rainbow: angle top left to bottom right
|
||||
userconf.ledprog_setting[0][1] = 25; // rainbow: spacing
|
||||
|
||||
userconf.ledprog_setting[1][0] = 8; // lite then fade: fade rate
|
||||
userconf.ledprog_setting[1][1] = 192; // lite then fade: hue
|
||||
|
||||
userconf.ledprog_setting[2][0] = 255; // twinkle: saturation
|
||||
userconf.ledprog_setting[2][1] = 4; // twinkle: intensity
|
||||
|
||||
userconf.ledprog_setting[3][0] = 5; // alternate: offset in 22.5deg increments
|
||||
userconf.ledprog_setting[3][1] = 244; // alternate: hue
|
||||
|
||||
userconf.checksum = checksum();
|
||||
userconf.checkval = CHECKVAL;
|
||||
}
|
||||
|
|
|
@ -154,17 +154,17 @@ void led_rgb_1_lite_then_fade(uint8_t preview, uint8_t tick)
|
|||
i = 0;
|
||||
}
|
||||
|
||||
hue *= 6;
|
||||
hsv2rgb_8b(hue, i, 255, &prog_rgb[0], &prog_rgb[1], &prog_rgb[2]);
|
||||
hsv2rgb_8b(hue * 6, i, 255, &prog_rgb[0], &prog_rgb[1], &prog_rgb[2]);
|
||||
|
||||
// make the rate adjustment a bit more intuitive
|
||||
if (rate >= 254) rate = 255;
|
||||
else rate >>= 2;
|
||||
rate++;
|
||||
|
||||
// fade out anything that's already lit at user's rate
|
||||
for (i = 0; i < 9; i++) {
|
||||
if (lite_persist[i]) lite_persist[i]--;
|
||||
else for (j = 0; j < 2; j++) {
|
||||
else for (j = 0; j < 3; j++) {
|
||||
if (rgb[i][j] > rate) rgb[i][j] -= rate; else rgb[i][j] = 0;
|
||||
}
|
||||
}
|
||||
|
@ -201,6 +201,8 @@ void led_rgb_1_lite_then_fade(uint8_t preview, uint8_t tick)
|
|||
|
||||
for (i = start; i < end; i++) {
|
||||
rgb[i][0] = prog_rgb[0];
|
||||
rgb[i][1] = prog_rgb[1];
|
||||
rgb[i][2] = prog_rgb[2];
|
||||
lite_persist[i] = LITE_PERSIST;
|
||||
}
|
||||
}
|
||||
|
@ -224,6 +226,8 @@ void led_rgb_1_lite_then_fade(uint8_t preview, uint8_t tick)
|
|||
if (lite_idx == end) {
|
||||
lite_timeout = LITE_IDLE_DWELL;
|
||||
}
|
||||
|
||||
led_is_updated();
|
||||
}
|
||||
|
||||
lite_timeout--;
|
||||
|
@ -238,7 +242,7 @@ void led_rgb_1_lite_then_fade(uint8_t preview, uint8_t tick)
|
|||
*/
|
||||
|
||||
#define TWINKLE_PERSIST 3;
|
||||
#define TWINKLE_RGB_VAL 240
|
||||
#define TWINKLE_RGB_VAL 255
|
||||
uint8_t twinkle_set[9] = {0};
|
||||
|
||||
void led_rgb_2_twinkle(uint8_t preview, uint8_t tick)
|
||||
|
@ -248,26 +252,28 @@ void led_rgb_2_twinkle(uint8_t preview, uint8_t tick)
|
|||
uint8_t sat;
|
||||
|
||||
// set
|
||||
rnd = prng_get8();
|
||||
if (rnd >= userconf.ledprog_setting[2][1]) {
|
||||
// yup, we're doing it
|
||||
rnd = prng_get16();
|
||||
rnd *= 1536;
|
||||
rnd <<= 16;
|
||||
if ((tick & 3) == 0) {
|
||||
rnd = prng_get8();
|
||||
if (rnd < userconf.ledprog_setting[2][1]) {
|
||||
// yup, we're doing it
|
||||
rnd = prng_get16();
|
||||
rnd *= 1536;
|
||||
rnd >>= 16;
|
||||
|
||||
sat = userconf.ledprog_setting[2][0];
|
||||
if (sat >= 128) sat = 128 - (sat - 128);
|
||||
sat <<= 1;
|
||||
sat = userconf.ledprog_setting[2][0];
|
||||
if (sat >= 128) sat = 128 - (sat - 128);
|
||||
sat <<= 1;
|
||||
|
||||
hsv2rgb_8b(rnd, sat, TWINKLE_RGB_VAL, &prog_rgb[0], &prog_rgb[1], &prog_rgb[2]);
|
||||
hsv2rgb_8b(rnd, sat, TWINKLE_RGB_VAL, &prog_rgb[0], &prog_rgb[1], &prog_rgb[2]);
|
||||
|
||||
rnd = prng_get16() & 0xfff;
|
||||
rnd /= 455;
|
||||
rnd = prng_get16() & 0xfff;
|
||||
rnd /= 455;
|
||||
|
||||
rgb[rnd][0] = prog_rgb[0];
|
||||
rgb[rnd][1] = prog_rgb[1];
|
||||
rgb[rnd][2] = prog_rgb[2];
|
||||
twinkle_set[rnd] = TWINKLE_PERSIST;
|
||||
rgb[rnd][0] = prog_rgb[0];
|
||||
rgb[rnd][1] = prog_rgb[1];
|
||||
rgb[rnd][2] = prog_rgb[2];
|
||||
twinkle_set[rnd] = TWINKLE_PERSIST;
|
||||
}
|
||||
}
|
||||
|
||||
// decay
|
||||
|
@ -278,6 +284,8 @@ void led_rgb_2_twinkle(uint8_t preview, uint8_t tick)
|
|||
else rgb[i][j] >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
led_is_updated();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -292,7 +300,7 @@ void led_rgb_3_alternate(uint8_t preview, uint8_t tick)
|
|||
uint8_t i, j;
|
||||
|
||||
uint16_t hue = userconf.ledprog_setting[3][1] * 6;
|
||||
uint8_t offset = (userconf.ledprog_setting[3][0] & 0xf) * 16 * 6;
|
||||
uint16_t offset = (userconf.ledprog_setting[3][0] & 0xf) * 16 * 6;
|
||||
|
||||
uint8_t is_flashing = 0;
|
||||
|
||||
|
@ -307,6 +315,8 @@ void led_rgb_3_alternate(uint8_t preview, uint8_t tick)
|
|||
}
|
||||
}
|
||||
|
||||
// don't need to update flashing state. this is handled by the cursor
|
||||
|
||||
// set hues
|
||||
for (i = 0; i < 2; i++) {
|
||||
hsv2rgb_8b(hue, 255, 255, &prog_rgb[0], &prog_rgb[1], &prog_rgb[2]);
|
||||
|
|
|
@ -485,12 +485,13 @@ void ui_render()
|
|||
}
|
||||
|
||||
// actually run the program
|
||||
led_rgbprog[rgb_prog_idx - 1](LED_RGBPROG_NORMAL, tick);
|
||||
led_rgbprog[rgb_prog_idx](LED_RGBPROG_NORMAL, tick);
|
||||
}
|
||||
}
|
||||
|
||||
// temp: remove me once buttons are tested and working
|
||||
led_rgbprog[0](LED_RGBPROG_NORMAL, tick);
|
||||
rgb_prog_idx = 4;
|
||||
led_rgbprog[rgb_prog_idx](LED_RGBPROG_NORMAL, tick);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue