Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c2161f5

Browse files
committedMay 15, 2024
Reorganize RTC standby example
1 parent 2e9a6ac commit c2161f5

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed
 

‎examples/Standby_WakeFromRTC_C33/Standby_WakeFromRTC_C33.ino

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,36 @@ void blinkLed(int ledPin, int delayTime = 1000){
1414
}
1515

1616
void setup() {
17+
board.setAllPeripheralsPower(true); // TODO: Check if this is necessary
18+
1719
pinMode(LEDR, OUTPUT); // Used to indicate errors
1820
digitalWrite(LEDR, HIGH); // Turn off the red LED
1921
pinMode(LED_BUILTIN, OUTPUT);
22+
digitalWrite(LED_BUILTIN, LOW); // Turn on the built-in LED
23+
delay(1000);
2024
digitalWrite(LED_BUILTIN, HIGH); // Turn off the built-in LED
2125
pinMode(LEDB, OUTPUT); // Used to indicate that the board is awake
2226

2327
// Turn on the blue LED to show that the board is still awake
2428
digitalWrite(LEDB, LOW);
2529

26-
RTC.begin();
27-
2830
if(!board.begin()){
2931
while (true){
3032
blinkLed(LEDR);
3133
}
3234
}
33-
34-
board.enableWakeupFromRTC(0, 0, 10); // Sleep for 60 seconds
35-
board.setAllPeripheralsPower(true); // TODO: Check if this is necessary
36-
35+
36+
RTC.begin();
3737
if (!RTC.isRunning()) {
38-
RTC.setTime(initialTime);
38+
if(!RTC.setTime(initialTime)){
39+
while (true){
40+
blinkLed(LEDR);
41+
}
42+
}
3943
}
4044

45+
board.enableWakeupFromRTC(0, 0, 10, [](){}, &RTC); // Sleep for 10 seconds
46+
// board.setAllPeripheralsPower(false);
4147
board.standByUntilWakeupEvent();
4248
}
4349

0 commit comments

Comments
 (0)
Please sign in to comment.