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