Skip to content

Commit 684c6ce

Browse files
committed
Differentiate examples on power save and power down
1 parent bd98aea commit 684c6ce

File tree

3 files changed

+72
-3
lines changed

3 files changed

+72
-3
lines changed

scripts/make.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
44

5-
TARGET=$SCRIPTPATH/../src/examples/http_get_time/http_get_time.ino
5+
TARGET=$SCRIPTPATH/../src/examples/power_down/power_down.ino
66
EXTRA_ARGS=--clean
77

88
if [ "$1" = "clean" ]; then
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#include <avr/io.h>
2+
#include <led_ctrl.h>
3+
#include <log.h>
4+
#include <low_power.h>
5+
#include <lte.h>
6+
#include <sequans_controller.h>
7+
8+
#ifdef __AVR_AVR128DB48__ // MINI
9+
10+
#define SerialDebug Serial3
11+
12+
#else
13+
#ifdef __AVR_AVR128DB64__ // Non-Mini
14+
15+
#define SerialDebug Serial5
16+
17+
#else
18+
#error "INCOMPATIBLE_DEVICE_SELECTED"
19+
#endif
20+
#endif
21+
22+
#define SW0 PIN_PD2
23+
24+
ISR(PORTD_PORT_vect) {
25+
if (PORTD.INTFLAGS & PIN2_bm) {
26+
PORTD.INTFLAGS = PIN2_bm;
27+
}
28+
}
29+
30+
void setup() {
31+
Log.begin(115200);
32+
33+
LedCtrl.begin();
34+
LedCtrl.startupCycle();
35+
36+
// Configure SW0 for interrupt so we can wake the device up from sleep by
37+
// pressing the button
38+
pinConfigure(SW0, PIN_DIR_INPUT | PIN_INT_FALL);
39+
40+
// Now we configure the low power module for power down configuration.
41+
LowPower.configurePowerDown();
42+
43+
Lte.begin();
44+
Log.infof("Connecting to operator");
45+
46+
while (!Lte.isConnected()) {
47+
Log.raw(".");
48+
delay(1000);
49+
}
50+
51+
Log.raw("\r\n");
52+
Log.infof("Connected to operator: %s\r\n", Lte.getOperator().c_str());
53+
}
54+
55+
void loop() {
56+
Log.raw("\r\n");
57+
Log.info("Powering down...");
58+
delay(100);
59+
60+
// Power down for 60 seconds
61+
LowPower.powerDown(60);
62+
63+
Log.info("Woke up!");
64+
65+
// Do work ...
66+
Log.info("Doing work...");
67+
delay(10000);
68+
}

src/examples/low_power/low_power.ino renamed to src/examples/power_save/power_save.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ ISR(PORTD_PORT_vect) {
3030

3131
void setup() {
3232
Log.begin(115200);
33-
Log.setLogLevel(LogLevel::DEBUG);
3433

3534
LedCtrl.begin();
3635
LedCtrl.startupCycle();
@@ -87,11 +86,13 @@ void setup() {
8786

8887
void loop() {
8988
Log.raw("\r\n");
90-
Log.info("Going to sleep...");
89+
Log.info("Power saving...");
9190
delay(100);
9291

9392
LowPower.powerSave();
9493

94+
Log.info("Woke up!");
95+
9596
// Do work ...
9697
Log.info("Doing work...");
9798
delay(10000);

0 commit comments

Comments
 (0)