mirror of
https://github.com/liberatedsystems/RNode_Firmware_CE.git
synced 2025-08-01 10:56:15 -04:00
Added button input and deep sleep
This commit is contained in:
parent
51172fb68f
commit
73de55c82b
3 changed files with 33 additions and 0 deletions
|
@ -82,6 +82,10 @@ void setup() {
|
|||
serial_interrupt_init();
|
||||
|
||||
// Configure input and output pins
|
||||
#if HAS_INPUT
|
||||
input_init();
|
||||
#endif
|
||||
|
||||
#if HAS_NP == false
|
||||
pinMode(pin_led_rx, OUTPUT);
|
||||
pinMode(pin_led_tx, OUTPUT);
|
||||
|
@ -1289,6 +1293,23 @@ void loop() {
|
|||
#if HAS_BLUETOOTH || HAS_BLE == true
|
||||
if (!console_active && bt_ready) update_bt();
|
||||
#endif
|
||||
|
||||
#if HAS_INPUT
|
||||
input_read();
|
||||
#endif
|
||||
}
|
||||
|
||||
void sleep_now() {
|
||||
#if HAS_SLEEP == true
|
||||
esp_sleep_enable_ext0_wakeup(PIN_WAKEUP, WAKEUP_LEVEL);
|
||||
esp_deep_sleep_start();
|
||||
#endif
|
||||
}
|
||||
|
||||
void button_event(uint8_t event, unsigned long duration) {
|
||||
if (duration > 2000) {
|
||||
sleep_now();
|
||||
}
|
||||
}
|
||||
|
||||
volatile bool serial_polling = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue