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][0] = 2; // rainbow: angle top left to bottom right
|
||||||
userconf.ledprog_setting[0][1] = 25; // rainbow: spacing
|
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.checksum = checksum();
|
||||||
userconf.checkval = CHECKVAL;
|
userconf.checkval = CHECKVAL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,17 +154,17 @@ void led_rgb_1_lite_then_fade(uint8_t preview, uint8_t tick)
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
hue *= 6;
|
hsv2rgb_8b(hue * 6, i, 255, &prog_rgb[0], &prog_rgb[1], &prog_rgb[2]);
|
||||||
hsv2rgb_8b(hue, i, 255, &prog_rgb[0], &prog_rgb[1], &prog_rgb[2]);
|
|
||||||
|
|
||||||
// make the rate adjustment a bit more intuitive
|
// make the rate adjustment a bit more intuitive
|
||||||
if (rate >= 254) rate = 255;
|
if (rate >= 254) rate = 255;
|
||||||
else rate >>= 2;
|
else rate >>= 2;
|
||||||
|
rate++;
|
||||||
|
|
||||||
// fade out anything that's already lit at user's rate
|
// fade out anything that's already lit at user's rate
|
||||||
for (i = 0; i < 9; i++) {
|
for (i = 0; i < 9; i++) {
|
||||||
if (lite_persist[i]) lite_persist[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;
|
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++) {
|
for (i = start; i < end; i++) {
|
||||||
rgb[i][0] = prog_rgb[0];
|
rgb[i][0] = prog_rgb[0];
|
||||||
|
rgb[i][1] = prog_rgb[1];
|
||||||
|
rgb[i][2] = prog_rgb[2];
|
||||||
lite_persist[i] = LITE_PERSIST;
|
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) {
|
if (lite_idx == end) {
|
||||||
lite_timeout = LITE_IDLE_DWELL;
|
lite_timeout = LITE_IDLE_DWELL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
led_is_updated();
|
||||||
}
|
}
|
||||||
|
|
||||||
lite_timeout--;
|
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_PERSIST 3;
|
||||||
#define TWINKLE_RGB_VAL 240
|
#define TWINKLE_RGB_VAL 255
|
||||||
uint8_t twinkle_set[9] = {0};
|
uint8_t twinkle_set[9] = {0};
|
||||||
|
|
||||||
void led_rgb_2_twinkle(uint8_t preview, uint8_t tick)
|
void led_rgb_2_twinkle(uint8_t preview, uint8_t tick)
|
||||||
|
@ -248,12 +252,13 @@ void led_rgb_2_twinkle(uint8_t preview, uint8_t tick)
|
||||||
uint8_t sat;
|
uint8_t sat;
|
||||||
|
|
||||||
// set
|
// set
|
||||||
|
if ((tick & 3) == 0) {
|
||||||
rnd = prng_get8();
|
rnd = prng_get8();
|
||||||
if (rnd >= userconf.ledprog_setting[2][1]) {
|
if (rnd < userconf.ledprog_setting[2][1]) {
|
||||||
// yup, we're doing it
|
// yup, we're doing it
|
||||||
rnd = prng_get16();
|
rnd = prng_get16();
|
||||||
rnd *= 1536;
|
rnd *= 1536;
|
||||||
rnd <<= 16;
|
rnd >>= 16;
|
||||||
|
|
||||||
sat = userconf.ledprog_setting[2][0];
|
sat = userconf.ledprog_setting[2][0];
|
||||||
if (sat >= 128) sat = 128 - (sat - 128);
|
if (sat >= 128) sat = 128 - (sat - 128);
|
||||||
|
@ -269,6 +274,7 @@ void led_rgb_2_twinkle(uint8_t preview, uint8_t tick)
|
||||||
rgb[rnd][2] = prog_rgb[2];
|
rgb[rnd][2] = prog_rgb[2];
|
||||||
twinkle_set[rnd] = TWINKLE_PERSIST;
|
twinkle_set[rnd] = TWINKLE_PERSIST;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// decay
|
// decay
|
||||||
for (i = 0; i < 9; i++) {
|
for (i = 0; i < 9; i++) {
|
||||||
|
@ -278,6 +284,8 @@ void led_rgb_2_twinkle(uint8_t preview, uint8_t tick)
|
||||||
else rgb[i][j] >>= 1;
|
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;
|
uint8_t i, j;
|
||||||
|
|
||||||
uint16_t hue = userconf.ledprog_setting[3][1] * 6;
|
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;
|
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
|
// set hues
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
hsv2rgb_8b(hue, 255, 255, &prog_rgb[0], &prog_rgb[1], &prog_rgb[2]);
|
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
|
// 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
|
// 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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue