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 max; // max number of iterations for this angle
uint8_t angle; // fill direction from LUT uint8_t angle; // fill direction from LUT
uint8_t output = 1;
uint16_t hoff; uint16_t hoff;
// run at half framerate // run at half framerate
@ -102,15 +104,19 @@ 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 (i == idx) { // is this LED part of this pattern at this index?
if (preview) { // are we in preview mode? if (preview) { // are we in preview mode?
output = 1;
if (j != 0) { // is the first letter not the one selected? if (j != 0) { // is the first letter not the one selected?
if ((preview & 0x7f) == 0) {// is this preview selected? if ((preview & 0xf) == 0) {// is this preview selected?
if (j < 5) continue; // pass over any outputs that are not "TECH" letters 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];
} }
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 n++; // nybble index
@ -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 // fade out anything that's already lit at user's rate
for (i = 0; i < 9; i++) { 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]--; if (lite_persist[i]) lite_persist[i]--;
else for (j = 0; j < 3; 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;
@ -174,29 +190,42 @@ void led_rgb_1_lite_then_fade(uint8_t preview, uint8_t tick)
if (!lite_timeout) { if (!lite_timeout) {
if (!lite_direction) { if (!lite_direction) {
// left to right // left to right
// light RETRO if (!preview || (preview && (lite_idx == 1))) {
if (lite_idx < 5) { if (lite_idx < 5) {
rgb[lite_idx][0] = prog_rgb[0]; // light RETRO
rgb[lite_idx][1] = prog_rgb[1]; rgb[lite_idx][0] = prog_rgb[0];
rgb[lite_idx][2] = prog_rgb[2]; rgb[lite_idx][1] = prog_rgb[1];
lite_persist[lite_idx] = LITE_PERSIST; rgb[lite_idx][2] = prog_rgb[2];
lite_persist[lite_idx] = LITE_PERSIST;
}
} }
// light TECH if (!preview || ((preview & 0xf) == 1)) {
if (lite_idx < 4) { // light TECH
rgb[lite_idx + 5][0] = prog_rgb[0]; if (lite_idx < 4) {
rgb[lite_idx + 5][1] = prog_rgb[1]; rgb[lite_idx + 5][0] = prog_rgb[0];
rgb[lite_idx + 5][2] = prog_rgb[2]; rgb[lite_idx + 5][1] = prog_rgb[1];
lite_persist[lite_idx + 5] = LITE_PERSIST; rgb[lite_idx + 5][2] = prog_rgb[2];
lite_persist[lite_idx + 5] = LITE_PERSIST;
}
} }
} else { } else {
// up to down // up to down
if (lite_idx < 2) { if (lite_idx < 2) {
if (!lite_idx) { if (!lite_idx) {
start = 0; if (preview) {
end = 5; start = 1;
end = 2;
} else {
start = 0;
end = 5;
}
} else { } else {
start = 5; if ((preview & 0xf) != 1) {
start = 9;
} else {
start = 5;
}
end = 9; end = 9;
} }

View File

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