Skip to content

Commit 8d47553

Browse files
committed
Refactor C33 RTC wakeup example
1 parent 678a376 commit 8d47553

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed
+24-22
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
11

2-
#include "Arduino.h"
32
#include "Arduino_PowerManagement.h"
43
#include "RTC.h"
54

6-
RTCTime initial_time(1, Month::JANUARY, 2000, 12, 10, 00, DayOfWeek::TUESDAY, SaveLight::SAVING_TIME_ACTIVE);
5+
RTCTime initialTime(1, Month::JANUARY, 2000, 12, 10, 00, DayOfWeek::TUESDAY, SaveLight::SAVING_TIME_ACTIVE);
76

8-
LowPower lowPower;
9-
PowerManagement manager;
107
Board board;
11-
Charger charger;
8+
9+
void blinkLed(int ledPin, int delayTime = 1000){
10+
digitalWrite(ledPin, LOW);
11+
delay(delayTime);
12+
digitalWrite(ledPin, HIGH);
13+
delay(delayTime);
14+
}
1215

1316
void setup() {
17+
pinMode(LEDR, OUTPUT); // Used to indicate errors
18+
digitalWrite(LEDR, HIGH); // Turn off the red LED
1419
pinMode(LED_BUILTIN, OUTPUT);
15-
digitalWrite(LED_BUILTIN, LOW);
20+
digitalWrite(LED_BUILTIN, HIGH); // Turn off the built-in LED
21+
pinMode(LEDB, OUTPUT); // Used to indicate that the board is awake
22+
23+
// Turn on the blue LED to show that the board is still awake
24+
digitalWrite(LEDB, LOW);
1625

1726
RTC.begin();
1827

19-
manager = PowerManagement();
20-
manager.begin();
21-
board = manager.getBoard();
22-
23-
board.enableWakeupFromRTC();
24-
board.setAllPeripheralsPower(true);
28+
if(!board.begin()){
29+
while (true){
30+
blinkLed(LEDR);
31+
}
32+
}
2533

34+
board.enableWakeupFromRTC(0, 0, 10); // Sleep for 60 seconds
35+
board.setAllPeripheralsPower(true); // TODO: Check if this is necessary
2636

2737
if (!RTC.isRunning()) {
28-
RTC.setTime(initial_time);
38+
RTC.setTime(initialTime);
2939
}
3040

31-
digitalWrite(LED_BUILTIN, HIGH);
32-
board.sleepFor(0, 0, 10);
33-
34-
// Turn LED on to indicate the board is awake
35-
digitalWrite(LED_BUILTIN, LOW);
36-
}
37-
38-
void loop(){
39-
//board.setAllPeripheralsPower(false);
4041
board.standByUntilWakeupEvent();
4142
}
4243

44+
void loop(){}

0 commit comments

Comments
 (0)