* some fixes around the powerOff(). Tidy ups

This commit is contained in:
Scott Powell
2025-03-14 19:08:41 +11:00
parent 99b376c512
commit 6a4b7463ef
4 changed files with 39 additions and 41 deletions

View File

@@ -26,7 +26,6 @@ static const uint8_t meshcore_logo [] PROGMEM = {
}; };
void UITask::begin(const char* node_name, const char* build_date, uint32_t pin_code) { void UITask::begin(const char* node_name, const char* build_date, uint32_t pin_code) {
_prevBtnState = HIGH;
_auto_off = millis() + AUTO_OFF_MILLIS; _auto_off = millis() + AUTO_OFF_MILLIS;
clearMsgPreview(); clearMsgPreview();
_node_name = node_name; _node_name = node_name;
@@ -66,7 +65,8 @@ void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, i
} }
void UITask::renderCurrScreen() { void UITask::renderCurrScreen() {
if (_display != NULL) { if (_display == NULL) return; // assert() ??
char tmp[80]; char tmp[80];
if (_origin[0] && _msg[0]) { if (_origin[0] && _msg[0]) {
// render message preview // render message preview
@@ -104,7 +104,6 @@ void UITask::renderCurrScreen() {
_display->print(tmp); _display->print(tmp);
} }
} }
}
} }
void UITask::userLedHandler() { void UITask::userLedHandler() {
@@ -135,7 +134,7 @@ void UITask::userLedHandler() {
void UITask::buttonHandler() { void UITask::buttonHandler() {
#ifdef PIN_USER_BTN #ifdef PIN_USER_BTN
static int prev_btn_state = HIGH; static int prev_btn_state = !USER_BTN_PRESSED;
static unsigned long btn_state_change_time = 0; static unsigned long btn_state_change_time = 0;
static unsigned long next_read = 0; static unsigned long next_read = 0;
int cur_time = millis(); int cur_time = millis();
@@ -153,7 +152,6 @@ void UITask::buttonHandler() {
} }
} else { // unpressed ? check pressed time ... } else { // unpressed ? check pressed time ...
if ((cur_time - btn_state_change_time) > 5000) { if ((cur_time - btn_state_change_time) > 5000) {
Serial.println("power off");
#ifdef PIN_STATUS_LED #ifdef PIN_STATUS_LED
digitalWrite(PIN_STATUS_LED, LOW); digitalWrite(PIN_STATUS_LED, LOW);
delay(10); delay(10);

View File

@@ -7,7 +7,6 @@ class UITask {
DisplayDriver* _display; DisplayDriver* _display;
mesh::MainBoard* _board; mesh::MainBoard* _board;
unsigned long _next_refresh, _auto_off; unsigned long _next_refresh, _auto_off;
int _prevBtnState;
bool _connected; bool _connected;
uint32_t _pin_code; uint32_t _pin_code;
const char* _node_name; const char* _node_name;

View File

@@ -40,7 +40,7 @@ public:
virtual void onBeforeTransmit() { } virtual void onBeforeTransmit() { }
virtual void onAfterTransmit() { } virtual void onAfterTransmit() { }
virtual void reboot() = 0; virtual void reboot() = 0;
virtual void powerOff() { while (1) { }}; // hope it's overriden or never called ;) virtual void powerOff() { /* no op */ }
virtual uint8_t getStartupReason() const = 0; virtual uint8_t getStartupReason() const = 0;
virtual bool startOTAUpdate() { return false; } // not supported virtual bool startOTAUpdate() { return false; } // not supported
}; };

View File

@@ -68,7 +68,8 @@ public:
} }
void powerOff() override { void powerOff() override {
enterDeepSleep(0); // TODO: re-enable this when there is a definite wake-up source pin:
// enterDeepSleep(0);
} }
uint16_t getBattMilliVolts() override { uint16_t getBattMilliVolts() override {