sensecap solar: stabilize wake pin and add button hold poweroff
This commit is contained in:
@@ -23,6 +23,11 @@ static char command[160];
|
|||||||
unsigned long lastActive = 0; // mark last active time
|
unsigned long lastActive = 0; // mark last active time
|
||||||
unsigned long nextSleepinSecs = 120; // next sleep in seconds. The first sleep (if enabled) is after 2 minutes from boot
|
unsigned long nextSleepinSecs = 120; // next sleep in seconds. The first sleep (if enabled) is after 2 minutes from boot
|
||||||
|
|
||||||
|
#if defined(PIN_USER_BTN) && defined(_SEEED_SENSECAP_SOLAR_H_)
|
||||||
|
static unsigned long userBtnDownAt = 0;
|
||||||
|
#define USER_BTN_HOLD_OFF_MILLIS 1500
|
||||||
|
#endif
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
@@ -127,6 +132,21 @@ void loop() {
|
|||||||
command[0] = 0; // reset command buffer
|
command[0] = 0; // reset command buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(PIN_USER_BTN) && defined(_SEEED_SENSECAP_SOLAR_H_)
|
||||||
|
// Hold the user button to power off the SenseCAP Solar repeater.
|
||||||
|
int btnState = digitalRead(PIN_USER_BTN);
|
||||||
|
if (btnState == LOW) {
|
||||||
|
if (userBtnDownAt == 0) {
|
||||||
|
userBtnDownAt = millis();
|
||||||
|
} else if ((unsigned long)(millis() - userBtnDownAt) >= USER_BTN_HOLD_OFF_MILLIS) {
|
||||||
|
Serial.println("Powering off...");
|
||||||
|
board.powerOff(); // does not return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
userBtnDownAt = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
the_mesh.loop();
|
the_mesh.loop();
|
||||||
sensors.loop();
|
sensors.loop();
|
||||||
#ifdef DISPLAY_CLASS
|
#ifdef DISPLAY_CLASS
|
||||||
|
|||||||
@@ -43,10 +43,12 @@ public:
|
|||||||
|
|
||||||
#ifdef PIN_USER_BTN
|
#ifdef PIN_USER_BTN
|
||||||
while (digitalRead(PIN_USER_BTN) == LOW);
|
while (digitalRead(PIN_USER_BTN) == LOW);
|
||||||
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(g_ADigitalPinMap[PIN_USER_BTN]), NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
|
// Keep pull-up enabled in system-off so the wake line doesn't float low.
|
||||||
|
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(g_ADigitalPinMap[PIN_USER_BTN]), NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
|
||||||
#elif defined(PIN_BUTTON1)
|
#elif defined(PIN_BUTTON1)
|
||||||
while (digitalRead(PIN_BUTTON1) == LOW);
|
while (digitalRead(PIN_BUTTON1) == LOW);
|
||||||
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(g_ADigitalPinMap[PIN_BUTTON1]), NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
|
// Keep pull-up enabled in system-off so the wake line doesn't float low.
|
||||||
|
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(g_ADigitalPinMap[PIN_BUTTON1]), NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NRF52_POWER_MANAGEMENT
|
#ifdef NRF52_POWER_MANAGEMENT
|
||||||
|
|||||||
Reference in New Issue
Block a user