more cleanup and clarity

This commit is contained in:
true 2025-04-03 14:21:48 -07:00
parent 3607db3c4c
commit b5bf65fead
1 changed files with 11 additions and 11 deletions

View File

@ -56,6 +56,11 @@ enum {
RGB_PROG_BTN_RELEASE RGB_PROG_BTN_RELEASE
}; };
enum {
PROG_RUN = 0,
PROG_INIT = 1
};
uint8_t run_rgb_program = 0; uint8_t run_rgb_program = 0;
@ -106,7 +111,7 @@ void loop() {
digitalWrite(PIN_PA6, HIGH); // enable LED power supply, digitalWrite(PIN_PA6, HIGH); // enable LED power supply,
delay(10); // wait a moment for LEDs to stabilize, delay(10); // wait a moment for LEDs to stabilize,
rgb_program[0](1); // initialize the program, rgb_program[0](PROG_INIT); // initialize the program,
run_rgb_program++; // and set to running mode. run_rgb_program++; // and set to running mode.
enable_rgb_timer(); // then start the RGB program timebase. enable_rgb_timer(); // then start the RGB program timebase.
@ -117,13 +122,10 @@ void loop() {
} }
case RGB_PROG_RUNNING: { // continuing to run a program case RGB_PROG_RUNNING: { // continuing to run a program
// send updates to the led rgb.show(); // send updates to the led
rgb.show();
// then process the next program frame if (!rgb_program[0](PROG_RUN)) { // then process the next program frame
if (!rgb_program[0](0)) { run_rgb_program = RGB_PROG_IDLE;// until the program says it's done
// until the program says it's done
run_rgb_program = RGB_PROG_IDLE;
break; break;
} }
@ -133,8 +135,7 @@ void loop() {
} }
case RGB_PROG_BTN_RELEASE: { // button released wakes MCU, but we're still running a program case RGB_PROG_BTN_RELEASE: { // button released wakes MCU, but we're still running a program
// skip processing and go back to stage 2 run_rgb_program = RGB_PROG_RUNNING; // so skip processing this cycle and go back to stage 2
run_rgb_program = RGB_PROG_RUNNING;
idle_cpu(); // we can idle the CPU after doing nothing idle_cpu(); // we can idle the CPU after doing nothing
@ -146,8 +147,7 @@ void loop() {
digitalWrite(PIN_PA6, LOW); // disable LED power supply, digitalWrite(PIN_PA6, LOW); // disable LED power supply,
run_rgb_program = RGB_PROG_IDLE; // and clear run_rgb_program. run_rgb_program = RGB_PROG_IDLE; // and clear run_rgb_program.
// finally, go to sleep in standby mode sleep_cpu(); // finally, go to sleep in standby mode
sleep_cpu();
break; break;
} }