Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/companion_radio/AbstractUITask.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#include "NodePrefs.h"
#include "MyMesh.h"

#ifndef AUTO_SHUTDOWN_LOW_READINGS
#define AUTO_SHUTDOWN_LOW_READINGS 3
#endif

enum class UIEventType {
none,
contactMessage,
Expand Down
7 changes: 5 additions & 2 deletions examples/companion_radio/ui-new/UITask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,8 +1055,9 @@ void UITask::loop() {
#ifdef AUTO_SHUTDOWN_MILLIVOLTS
if (millis() > next_batt_chck) {
uint16_t milliVolts = getBattMilliVolts();
if (milliVolts > 0 && milliVolts < AUTO_SHUTDOWN_MILLIVOLTS) {
if(!board.isExternalPowered()) {
if (milliVolts > 0 && milliVolts < AUTO_SHUTDOWN_MILLIVOLTS && !board.isExternalPowered()) {
_low_batt_count++;
if (_low_batt_count >= AUTO_SHUTDOWN_LOW_READINGS) {
if (_display != NULL) {
_display->startFrame();
_display->setTextSize(2);
Expand All @@ -1068,6 +1069,8 @@ void UITask::loop() {
}
shutdown();
}
} else {
_low_batt_count = 0;
}
next_batt_chck = millis() + 8000;
}
Expand Down
2 changes: 2 additions & 0 deletions examples/companion_radio/ui-new/UITask.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class UITask : public AbstractUITask {
unsigned long _alert_expiry;
int _msgcount;
unsigned long ui_started_at, next_batt_chck;
uint8_t _low_batt_count;
int next_backlight_btn_check = 0;
#ifdef PIN_STATUS_LED
int led_state = 0;
Expand Down Expand Up @@ -91,6 +92,7 @@ class UITask : public AbstractUITask {

UITask(mesh::MainBoard* board, MultiSerialInterface* serial) : AbstractUITask(board, serial), _display(NULL), _sensors(NULL) {
next_batt_chck = _next_refresh = 0;
_low_batt_count = 0;
ui_started_at = 0;
curr = NULL;
}
Expand Down
21 changes: 12 additions & 9 deletions examples/companion_radio/ui-tiny/UITask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,19 +755,22 @@ void UITask::loop() {
#ifdef AUTO_SHUTDOWN_MILLIVOLTS
if (millis() > next_batt_chck) {
_cached_batt_mv = getBattMilliVolts();
if (_cached_batt_mv > 0 && _cached_batt_mv < AUTO_SHUTDOWN_MILLIVOLTS) {
if(!board.isExternalPowered()) {
if (_cached_batt_mv > 0 && _cached_batt_mv < AUTO_SHUTDOWN_MILLIVOLTS && !board.isExternalPowered()) {
_low_batt_count++;
if (_low_batt_count >= AUTO_SHUTDOWN_LOW_READINGS) {
if (_display != NULL) {
_display->startFrame();
_display->setTextSize(2);
_display->drawTextCentered(_display->width() / 2, 6, "Low battery!");
_display->setTextSize(1);
_display->drawTextCentered(_display->width() / 2, 18, "Shutting down!");
_display->endFrame();
if (_display->isEink() == false) { delay(3000); }
_display->startFrame();
_display->setTextSize(2);
_display->drawTextCentered(_display->width() / 2, 6, "Low battery!");
_display->setTextSize(1);
_display->drawTextCentered(_display->width() / 2, 18, "Shutting down!");
_display->endFrame();
if (_display->isEink() == false) { delay(3000); }
}
shutdown();
}
} else {
_low_batt_count = 0;
}
next_batt_chck = millis() + 8000;
}
Expand Down
2 changes: 2 additions & 0 deletions examples/companion_radio/ui-tiny/UITask.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class UITask : public AbstractUITask {
unsigned long ui_started_at, next_batt_chck;
int next_backlight_btn_check = 0;
uint16_t _cached_batt_mv;
uint8_t _low_batt_count;
#ifdef PIN_STATUS_LED
int led_state = 0;
int next_led_change = 0;
Expand Down Expand Up @@ -74,6 +75,7 @@ class UITask : public AbstractUITask {
UITask(mesh::MainBoard* board, MultiSerialInterface* serial) : AbstractUITask(board, serial), _display(NULL), _sensors(NULL) {
next_batt_chck = _next_refresh = 0;
_cached_batt_mv = 0;
_low_batt_count = 0;
ui_started_at = 0;
curr = NULL;
}
Expand Down