make sure initial code run clears running state and goes into standby

This commit is contained in:
Brooke 2025-05-04 22:15:06 -04:00
parent cf209fce4d
commit 88162e2935
2 changed files with 7 additions and 4 deletions

View File

@ -112,6 +112,9 @@ void setup() {
// set up the RGB ~61Hz periodic timer // set up the RGB ~61Hz periodic timer
conf_rgb_timer(); conf_rgb_timer();
// clear initial setup
rgb_run_next = 1;
// enable global interrupts (though they should already be enabled?) // enable global interrupts (though they should already be enabled?)
sei(); sei();
} }
@ -145,7 +148,7 @@ void loop() {
enable_rgb_timer(); // then start the RGB program timebase. enable_rgb_timer(); // then start the RGB program timebase.
sleep_cpu(SLPCTRL_SMODE_IDLE_gc); // we can idle CPU after running the program sleep_cpu(SLEEP_MODE_IDLE); // we can idle CPU after running the program
break; break;
} }
@ -158,7 +161,7 @@ void loop() {
break; break;
} }
sleep_cpu(SLPCTRL_SMODE_IDLE_gc); // we can idle CPU after running the program sleep_cpu(SLEEP_MODE_IDLE); // we can idle CPU after running the program
break; break;
} }
@ -167,7 +170,7 @@ void loop() {
rgb.show(); // send final updates to the led rgb.show(); // send final updates to the led
run_rgbprog = RGB_IDLE; run_rgbprog = RGB_IDLE;
sleep_cpu(SLPCTRL_SMODE_IDLE_gc); // we can idle CPU after running the program sleep_cpu(SLEEP_MODE_IDLE); // we can idle CPU after running the program
break; break;
} }
@ -177,7 +180,7 @@ void loop() {
digitalWrite(PIN_LED_PWRENA, LOW); // disable LED power supply, digitalWrite(PIN_LED_PWRENA, LOW); // disable LED power supply,
run_rgbprog = RGB_IDLE; // and clear run_rgbprog. run_rgbprog = RGB_IDLE; // and clear run_rgbprog.
sleep_cpu(SLPCTRL_SMODE_STDBY_gc); // finally, go to sleep in standby mode sleep_cpu(SLEEP_MODE_STANDBY); // finally, go to sleep in standby mode
break; break;
} }