wip: fix preview on programs 0 and 1

both now "preview" properly in the program editor, but the program is a mess for testing this. fix before release
This commit is contained in:
true 2024-08-05 18:02:02 -07:00
parent 00a428a425
commit 0191126555
2 changed files with 84 additions and 45 deletions

View File

@ -71,6 +71,8 @@ void led_rgb_0_rainbow(uint8_t preview, uint8_t tick)
uint8_t max; // max number of iterations for this angle
uint8_t angle; // fill direction from LUT
uint8_t output = 1;
uint16_t hoff;
// run at half framerate
@ -102,16 +104,20 @@ void led_rgb_0_rainbow(uint8_t preview, uint8_t tick)
if (i == idx) { // is this LED part of this pattern at this index?
if (preview) { // are we in preview mode?
output = 1;
if (j != 0) { // is the first letter not the one selected?
if ((preview & 0x7f) == 0) {// is this preview selected?
if (j < 5) continue; // pass over any outputs that are not "TECH" letters
if ((preview & 0xf) == 0) {// is this preview selected?
if (j < 5) output = 0; // pass over any outputs that are not "TECH" letters
} else output = 0;
}
} else return; // preview is not selected, so we're done here
}
if (output) {
rgb[j][0] = prog_rgb[0]; // if so, copy the values
rgb[j][1] = prog_rgb[1];
rgb[j][2] = prog_rgb[2];
}
}
n++; // nybble index
if (n == 5) n++; // skip the 6th nybble; this indicates the max
@ -164,6 +170,16 @@ void led_rgb_1_lite_then_fade(uint8_t preview, uint8_t tick)
// fade out anything that's already lit at user's rate
for (i = 0; i < 9; i++) {
if (preview) {
if (i <= 4) {
if (i != 1) {
continue;
}
} else if ((preview & 0xf) != 1) {
continue;
}
}
if (lite_persist[i]) lite_persist[i]--;
else for (j = 0; j < 3; j++) {
if (rgb[i][j] > rate) rgb[i][j] -= rate; else rgb[i][j] = 0;
@ -174,14 +190,17 @@ void led_rgb_1_lite_then_fade(uint8_t preview, uint8_t tick)
if (!lite_timeout) {
if (!lite_direction) {
// left to right
// light RETRO
if (!preview || (preview && (lite_idx == 1))) {
if (lite_idx < 5) {
// light RETRO
rgb[lite_idx][0] = prog_rgb[0];
rgb[lite_idx][1] = prog_rgb[1];
rgb[lite_idx][2] = prog_rgb[2];
lite_persist[lite_idx] = LITE_PERSIST;
}
}
if (!preview || ((preview & 0xf) == 1)) {
// light TECH
if (lite_idx < 4) {
rgb[lite_idx + 5][0] = prog_rgb[0];
@ -189,14 +208,24 @@ void led_rgb_1_lite_then_fade(uint8_t preview, uint8_t tick)
rgb[lite_idx + 5][2] = prog_rgb[2];
lite_persist[lite_idx + 5] = LITE_PERSIST;
}
}
} else {
// up to down
if (lite_idx < 2) {
if (!lite_idx) {
if (preview) {
start = 1;
end = 2;
} else {
start = 0;
end = 5;
}
} else {
if ((preview & 0xf) != 1) {
start = 9;
} else {
start = 5;
}
end = 9;
}

View File

@ -23,13 +23,13 @@
#define MIN_GC 2
#define MAX_GC 26
#define UI_CONF_SAVE_TIMEOUT 160
#define UI_CONF_SAVE_TIMEOUT 192
#define UI_PROG_RUNTIME_MIN (128*15) // 15 seconds
#define UI_PROG_RUNTIME_MAX (128*120) // 120 seconds
static uint8_t mode = MODE_RUN;
static uint8_t mode = MODE_PROGRAM;
static uint8_t tick = 0;
static uint16_t editor_timeout_timer = 0;
@ -52,7 +52,7 @@ const uint16_t cursor_flash_rates[8] = { // off-to-on flash rates in 1/256
static uint8_t rgb_prog_idx = 0; // currently running rgbled program index
static uint16_t rgb_prog_timer = 9; // timeout until this program is done and switches
static uint8_t rgb_prog_is_editing = 0; // currently editing a program's parameters
static uint8_t preview_idx = 0; // currently selected program preview index
static uint8_t preview_idx = 1; // currently selected program preview index
static uint8_t config_save_timer;
@ -87,6 +87,7 @@ void ui_btn_push_cb(uint8_t idx)
// depending on the mode
if (mode == MODE_PROGRAM) preview_idx = 0;
if (mode == MODE_PARAMETER) {
/*
preview_idx = 0;
for (i = 0; i < 5; i++) {
if (userconf.ledprog_ena_mask & (1 << preview_idx)) {
@ -94,6 +95,7 @@ void ui_btn_push_cb(uint8_t idx)
break;
}
}
*/
}
return;
@ -344,8 +346,8 @@ static void ui_cursor_flash()
break;
}
case MODE_PROGRAM: {
// cursor is always off
cursor[color] = 0;
// cursor is on if this program is flagged as on
cursor[0] = (userconf.ledprog_ena_mask & (1 << preview_idx)) ? 127 : 0;
break;
}
@ -405,10 +407,10 @@ void ui_render()
}
}
switch (mode) {
case MODE_RUN: { // render an existing program
tick++;
switch (mode) {
case MODE_RUN: { // render an existing program
// set brightness from knob 32 times/second
// (the knob value updates less frequently, but we need to fade nicely)
if (tick & 7 == 7) {
@ -505,24 +507,29 @@ void ui_render()
// always force rendering
led_is_updated();
for (i = 0; i < 5; i++) {
for (i = 0; i < 2; i++) {
// render
if (led_rgbprog[i]) {
led_rgbprog[i](LED_RGBPROG_PREVIEW | preview_idx, tick);
}
if (preview_idx == i) {
// flash the selected output
if (flash & 1) {
rgb[i][0] >>= 5;
rgb[i][1] >>= 5;
rgb[i][2] >>= 5;
rgb[i][0] = 32;
rgb[i][1] = 32;
rgb[i][2] = 32;
//rgb[i][0] >>= 3;
//rgb[i][1] >>= 3;
//rgb[i][2] >>= 3;
}
} else {
// dim inactive outputs
if (!(userconf.ledprog_ena_mask & (1 << i))) {
rgb[i][0] >>= 3;
rgb[i][1] >>= 3;
rgb[i][2] >>= 3;
}
//if (!(userconf.ledprog_ena_mask & (1 << i))) {
// rgb[i][0] >>= 1;
// rgb[i][1] >>= 1;
// rgb[i][2] >>= 1;
//}
}
}
@ -552,15 +559,18 @@ void ui_render()
if (preview_idx == i) {
// flash the selected output
if (flash & 1) {
rgb[i][0] >>= 5;
rgb[i][1] >>= 5;
rgb[i][2] >>= 5;
rgb[i][0] = 32;
rgb[i][1] = 32;
rgb[i][2] = 32;
//rgb[i][0] >>= 5;
//rgb[i][1] >>= 5;
//rgb[i][2] >>= 5;
}
} else {
// dim the other outputs
rgb[i][0] >>= 2;
rgb[i][1] >>= 2;
rgb[i][2] >>= 2;
// rgb[i][0] >>= 2;
// rgb[i][1] >>= 2;
// rgb[i][2] >>= 2;
}
} else {
// clear the output if it isn't enabled