diff --git a/fw/HackSpaceCon/src/main.cpp b/fw/HackSpaceCon/src/main.cpp index b552980..be526d0 100644 --- a/fw/HackSpaceCon/src/main.cpp +++ b/fw/HackSpaceCon/src/main.cpp @@ -56,6 +56,11 @@ enum { RGB_PROG_BTN_RELEASE }; +enum { + PROG_RUN = 0, + PROG_INIT = 1 +}; + uint8_t run_rgb_program = 0; @@ -106,7 +111,7 @@ void loop() { digitalWrite(PIN_PA6, HIGH); // enable LED power supply, 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. enable_rgb_timer(); // then start the RGB program timebase. @@ -117,13 +122,10 @@ void loop() { } case RGB_PROG_RUNNING: { // continuing to run a program - // send updates to the led - rgb.show(); + rgb.show(); // send updates to the led - // then process the next program frame - if (!rgb_program[0](0)) { - // until the program says it's done - run_rgb_program = RGB_PROG_IDLE; + if (!rgb_program[0](PROG_RUN)) { // then process the next program frame + run_rgb_program = RGB_PROG_IDLE;// until the program says it's done break; } @@ -133,8 +135,7 @@ void loop() { } 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; + run_rgb_program = RGB_PROG_RUNNING; // so skip processing this cycle and go back to stage 2 idle_cpu(); // we can idle the CPU after doing nothing @@ -146,8 +147,7 @@ void loop() { digitalWrite(PIN_PA6, LOW); // disable LED power supply, run_rgb_program = RGB_PROG_IDLE; // and clear run_rgb_program. - // finally, go to sleep in standby mode - sleep_cpu(); + sleep_cpu(); // finally, go to sleep in standby mode break; }