mirror of
https://github.com/markqvist/RNode_Firmware.git
synced 2024-10-01 03:15:39 -04:00
Added button input and deep sleep
This commit is contained in:
parent
51172fb68f
commit
73de55c82b
8
Boards.h
8
Boards.h
@ -77,6 +77,8 @@
|
|||||||
#define HAS_PMU false
|
#define HAS_PMU false
|
||||||
#define HAS_NP false
|
#define HAS_NP false
|
||||||
#define HAS_EEPROM false
|
#define HAS_EEPROM false
|
||||||
|
#define HAS_INPUT false
|
||||||
|
#define HAS_SLEEP false
|
||||||
|
|
||||||
#if defined(ENABLE_TCXO)
|
#if defined(ENABLE_TCXO)
|
||||||
#define HAS_TCXO true
|
#define HAS_TCXO true
|
||||||
@ -252,11 +254,16 @@
|
|||||||
#elif BOARD_MODEL == BOARD_HELTEC32_V3
|
#elif BOARD_MODEL == BOARD_HELTEC32_V3
|
||||||
#define IS_ESP32S3 true
|
#define IS_ESP32S3 true
|
||||||
#define HAS_DISPLAY true
|
#define HAS_DISPLAY true
|
||||||
|
#define HAS_INPUT true
|
||||||
|
#define HAS_SLEEP true
|
||||||
#define HAS_BLUETOOTH false
|
#define HAS_BLUETOOTH false
|
||||||
#define HAS_BLE true
|
#define HAS_BLE true
|
||||||
// Cannot run wifi and BLE at same time?
|
// Cannot run wifi and BLE at same time?
|
||||||
#define HAS_CONSOLE false
|
#define HAS_CONSOLE false
|
||||||
#define HAS_EEPROM true
|
#define HAS_EEPROM true
|
||||||
|
#define PIN_WAKEUP GPIO_NUM_0
|
||||||
|
#define WAKEUP_LEVEL 0
|
||||||
|
|
||||||
#if defined(EXTERNAL_LEDS)
|
#if defined(EXTERNAL_LEDS)
|
||||||
const int pin_led_rx = 13;
|
const int pin_led_rx = 13;
|
||||||
const int pin_led_tx = 14;
|
const int pin_led_tx = 14;
|
||||||
@ -264,6 +271,7 @@
|
|||||||
const int pin_led_rx = 35;
|
const int pin_led_rx = 35;
|
||||||
const int pin_led_tx = 35;
|
const int pin_led_tx = 35;
|
||||||
#endif
|
#endif
|
||||||
|
const int pin_btn_usr1 = 0;
|
||||||
|
|
||||||
#define MODEM SX1262
|
#define MODEM SX1262
|
||||||
#define HAS_TCXO true
|
#define HAS_TCXO true
|
||||||
|
@ -82,6 +82,10 @@ void setup() {
|
|||||||
serial_interrupt_init();
|
serial_interrupt_init();
|
||||||
|
|
||||||
// Configure input and output pins
|
// Configure input and output pins
|
||||||
|
#if HAS_INPUT
|
||||||
|
input_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAS_NP == false
|
#if HAS_NP == false
|
||||||
pinMode(pin_led_rx, OUTPUT);
|
pinMode(pin_led_rx, OUTPUT);
|
||||||
pinMode(pin_led_tx, OUTPUT);
|
pinMode(pin_led_tx, OUTPUT);
|
||||||
@ -1289,6 +1293,23 @@ void loop() {
|
|||||||
#if HAS_BLUETOOTH || HAS_BLE == true
|
#if HAS_BLUETOOTH || HAS_BLE == true
|
||||||
if (!console_active && bt_ready) update_bt();
|
if (!console_active && bt_ready) update_bt();
|
||||||
#endif
|
#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;
|
volatile bool serial_polling = false;
|
||||||
|
@ -56,6 +56,10 @@ sx128x *LoRa = &sx128x_modem;
|
|||||||
#include "Power.h"
|
#include "Power.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAS_INPUT == true
|
||||||
|
#include "Input.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if MCU_VARIANT == MCU_ESP32 || MCU_VARIANT == MCU_NRF52
|
#if MCU_VARIANT == MCU_ESP32 || MCU_VARIANT == MCU_NRF52
|
||||||
#include "Device.h"
|
#include "Device.h"
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user