File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,6 +23,11 @@ static char command[160];
2323unsigned long lastActive = 0 ; // mark last active time
2424unsigned long nextSleepinSecs = 120 ; // next sleep in seconds. The first sleep (if enabled) is after 2 minutes from boot
2525
26+ #if defined(PIN_USER_BTN) && defined(_SEEED_SENSECAP_SOLAR_H_)
27+ static unsigned long userBtnDownAt = 0 ;
28+ #define USER_BTN_HOLD_OFF_MILLIS 1500
29+ #endif
30+
2631void setup () {
2732 Serial.begin (115200 );
2833 delay (1000 );
@@ -127,6 +132,21 @@ void loop() {
127132 command[0 ] = 0 ; // reset command buffer
128133 }
129134
135+ #if defined(PIN_USER_BTN) && defined(_SEEED_SENSECAP_SOLAR_H_)
136+ // Hold the user button to power off the SenseCAP Solar repeater.
137+ int btnState = digitalRead (PIN_USER_BTN);
138+ if (btnState == LOW) {
139+ if (userBtnDownAt == 0 ) {
140+ userBtnDownAt = millis ();
141+ } else if ((unsigned long )(millis () - userBtnDownAt) >= USER_BTN_HOLD_OFF_MILLIS) {
142+ Serial.println (" Powering off..." );
143+ board.powerOff (); // does not return
144+ }
145+ } else {
146+ userBtnDownAt = 0 ;
147+ }
148+ #endif
149+
130150 the_mesh.loop ();
131151 sensors.loop ();
132152#ifdef DISPLAY_CLASS
Original file line number Diff line number Diff line change @@ -43,10 +43,12 @@ class SenseCapSolarBoard : public NRF52BoardDCDC {
4343
4444#ifdef PIN_USER_BTN
4545 while (digitalRead (PIN_USER_BTN) == LOW);
46- nrf_gpio_cfg_sense_input (digitalPinToInterrupt (g_ADigitalPinMap[PIN_USER_BTN]), NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
46+ // Keep pull-up enabled in system-off so the wake line doesn't float low.
47+ nrf_gpio_cfg_sense_input (digitalPinToInterrupt (g_ADigitalPinMap[PIN_USER_BTN]), NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
4748#elif defined(PIN_BUTTON1)
4849 while (digitalRead (PIN_BUTTON1) == LOW);
49- nrf_gpio_cfg_sense_input (digitalPinToInterrupt (g_ADigitalPinMap[PIN_BUTTON1]), NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
50+ // Keep pull-up enabled in system-off so the wake line doesn't float low.
51+ nrf_gpio_cfg_sense_input (digitalPinToInterrupt (g_ADigitalPinMap[PIN_BUTTON1]), NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
5052#endif
5153
5254#ifdef NRF52_POWER_MANAGEMENT
You can’t perform that action at this time.
0 commit comments