|
|
|
@ -21,6 +21,7 @@ mcu: nano328p |
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#include <cstddef> |
|
|
|
|
#include <menu.h> |
|
|
|
|
#include <menuIO/u8g2Out.h> |
|
|
|
|
// #include <menuIO/encoderIn.h>
|
|
|
|
@ -34,6 +35,7 @@ using namespace Menu; |
|
|
|
|
#define LEDPIN 2 |
|
|
|
|
#define LOCKPIN LEDPIN |
|
|
|
|
#define BTN_SEL 33 |
|
|
|
|
#define WAKE_UP_GPIO GPIO_NUM_33 |
|
|
|
|
#define BTN_UP 32 |
|
|
|
|
#define BTN_DOWN 25 |
|
|
|
|
|
|
|
|
@ -106,10 +108,11 @@ result doLockScreen(menuOut &o, idleEvent e); |
|
|
|
|
result activateLock(); |
|
|
|
|
result deactivateLock(); |
|
|
|
|
void decrement_timer(); |
|
|
|
|
result setTimeout(); |
|
|
|
|
|
|
|
|
|
int battery = 55; |
|
|
|
|
|
|
|
|
|
int ledCtrl = LOW; |
|
|
|
|
int timeout_s = 6; |
|
|
|
|
|
|
|
|
|
result myLedOn() { |
|
|
|
|
ledCtrl = HIGH; |
|
|
|
@ -166,6 +169,8 @@ MENU(subMenu, "Settings", doNothing, noEvent, noStyle, |
|
|
|
|
// OP("LED On", myLedOn, enterEvent), //
|
|
|
|
|
// OP("LED Off", myLedOff, enterEvent), //
|
|
|
|
|
FIELD(battery, "Battery", "%", 0, 100, 0, 0, doNothing, noEvent, noStyle), |
|
|
|
|
FIELD(timeout_s, "Timeout", "s", 0, 3600, 10, 1, setTimeout, updateEvent, |
|
|
|
|
noStyle), |
|
|
|
|
SUBMENU(setLed), //
|
|
|
|
|
SUBMENU(selTheme), //
|
|
|
|
|
OP("Alert test", doAlert, enterEvent), //
|
|
|
|
@ -234,6 +239,11 @@ result alert(menuOut &o, idleEvent e) { |
|
|
|
|
return proceed; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
result setTimeout() { |
|
|
|
|
nav.timeOut = timeout_s; |
|
|
|
|
return proceed; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
unsigned long lock_timer_s = 0; // this decrements
|
|
|
|
|
unsigned long lock_time_s = 0; // this doesn't
|
|
|
|
|
|
|
|
|
@ -370,15 +380,32 @@ void setup() { |
|
|
|
|
// disable second option
|
|
|
|
|
// mainMenu[1].enabled = disabledStatus;
|
|
|
|
|
nav.idleTask = idle; // point a function to be used when menu is suspended
|
|
|
|
|
setTimeout(); |
|
|
|
|
options->invertFieldKeys = true; |
|
|
|
|
Serial.println("setup done."); |
|
|
|
|
Serial.flush(); |
|
|
|
|
|
|
|
|
|
esp_sleep_enable_ext0_wakeup(WAKE_UP_GPIO, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lastSleep; |
|
|
|
|
int thisSleep; |
|
|
|
|
void loop() { |
|
|
|
|
lastSleep = nav.sleepTask == NULL ? 0 : 1; |
|
|
|
|
nav.doInput(); |
|
|
|
|
thisSleep = nav.sleepTask == NULL ? 0 : 1; |
|
|
|
|
digitalWrite(LEDPIN, ledCtrl); |
|
|
|
|
if (nav.changed(0)) { // only draw if menu changed for gfx device
|
|
|
|
|
if (nav.sleepTask) { |
|
|
|
|
u8g2.firstPage(); |
|
|
|
|
do { |
|
|
|
|
u8g2.setCursor(0, 15); |
|
|
|
|
u8g2.setPowerSave(1); |
|
|
|
|
esp_light_sleep_start(); |
|
|
|
|
} while (u8g2.nextPage()); |
|
|
|
|
} else if (lastSleep != thisSleep) { |
|
|
|
|
Serial.println("Waking Up!"); |
|
|
|
|
u8g2.setPowerSave(0); |
|
|
|
|
} else if (nav.changed(0)) { // only draw if menu changed for gfx device
|
|
|
|
|
// change checking leaves more time for other tasks
|
|
|
|
|
u8g2.firstPage(); |
|
|
|
|
do |
|
|
|
|