adding what's needed to enable the softdevice and the power off function

This commit is contained in:
Pierre committed 2020-01-19 20:36:13 -06:00
1 parent 9a99c9cd5d
commit e58aebb046
1 file changed
+7 -3
@@ -1,6 +1,7 @@
/*
Blink_sleep
Turns on an LED on for one second, then off for one second, until the time to go to sleep runs out.
You can wake up the feather by pressing a key/switch connecting the WAKE_LOW_PIN to GND and the WAKE_HIGH_PIN to 3.3V (VCC)
Based on the blinky arduino example
@@ -10,6 +11,7 @@
by Pierre Constantineau
*/
#include <bluefruit.h>
#define WAKE_LOW_PIN PIN_A0
#define WAKE_HIGH_PIN PIN_A1
@@ -22,11 +24,11 @@ void gotoSleep(unsigned long time)
if ((time>SLEEPING_DELAY))
{
// to reduce power consumption when sleeping, turn off all your LEDs (and other power hungry devices)
digitalwrite(LED_BUILTIN, LOW);
digitalWrite(LED_BUILTIN, LOW);
// setup your wake-up pins.
pinModeSense(WAKE_LOW_PIN, INPUT_PULLUP_SENSE); // this pin (WAKE_LOW_PIN) is pulled up and wakes up the feather when externally connected to ground.
pinModeSense(WAKE_HIGH_PIN, INPUT_PULLDOWN_SENSE); // this pin (WAKE_HIGH_PIN) is pulled down and wakes up the feather when externally connected to 3.3v.
pinMode(WAKE_LOW_PIN, INPUT_PULLUP_SENSE); // this pin (WAKE_LOW_PIN) is pulled up and wakes up the feather when externally connected to ground.
pinMode(WAKE_HIGH_PIN, INPUT_PULLDOWN_SENSE); // this pin (WAKE_HIGH_PIN) is pulled down and wakes up the feather when externally connected to 3.3v.
// power down nrf52.
sd_power_system_off(); // this function puts the whole nRF52 to deep sleep (no Bluetooth). If no sense pins are setup (or other hardware interrupts), the nrf52 will not wake up.
@@ -35,6 +37,8 @@ void gotoSleep(unsigned long time)
// the setup function runs once when you press reset or power the board
void setup() {
Bluefruit.begin(); // Sleep functions need the softdevice to be active.
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}