mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-01 17:56:12 +00:00
NRF52: disable autoshutdown if powered, add auto-shutdown warning for oled
This commit is contained in:
@@ -832,22 +832,20 @@ void UITask::loop() {
|
|||||||
if (millis() > next_batt_chck) {
|
if (millis() > next_batt_chck) {
|
||||||
uint16_t milliVolts = getBattMilliVolts();
|
uint16_t milliVolts = getBattMilliVolts();
|
||||||
if (milliVolts > 0 && milliVolts < AUTO_SHUTDOWN_MILLIVOLTS) {
|
if (milliVolts > 0 && milliVolts < AUTO_SHUTDOWN_MILLIVOLTS) {
|
||||||
|
if(!board.isExternalPowered()) {
|
||||||
// show low battery shutdown alert
|
if (_display != NULL) {
|
||||||
// we should only do this for eink displays, which will persist after power loss
|
_display->startFrame();
|
||||||
#if defined(THINKNODE_M1) || defined(LILYGO_TECHO)
|
_display->setTextSize(2);
|
||||||
if (_display != NULL) {
|
_display->setColor(DisplayDriver::RED);
|
||||||
_display->startFrame();
|
_display->drawTextCentered(_display->width() / 2, 20, "Low Battery.");
|
||||||
_display->setTextSize(2);
|
_display->drawTextCentered(_display->width() / 2, 40, "Shutting Down!");
|
||||||
_display->setColor(DisplayDriver::RED);
|
_display->endFrame();
|
||||||
_display->drawTextCentered(_display->width() / 2, 20, "Low Battery.");
|
#if !defined(THINKNODE_M1) && !defined(LILYGO_TECHO) // TODO: refactor eink variants to use EINK_DISPLAY macros to gate this properly
|
||||||
_display->drawTextCentered(_display->width() / 2, 40, "Shutting Down!");
|
delay(3000);
|
||||||
_display->endFrame();
|
#endif
|
||||||
|
}
|
||||||
|
shutdown();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
shutdown();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
next_batt_chck = millis() + 8000;
|
next_batt_chck = millis() + 8000;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -727,14 +727,23 @@ void UITask::loop() {
|
|||||||
if (millis() > next_batt_chck) {
|
if (millis() > next_batt_chck) {
|
||||||
_cached_batt_mv = getBattMilliVolts();
|
_cached_batt_mv = getBattMilliVolts();
|
||||||
if (_cached_batt_mv > 0 && _cached_batt_mv < AUTO_SHUTDOWN_MILLIVOLTS) {
|
if (_cached_batt_mv > 0 && _cached_batt_mv < AUTO_SHUTDOWN_MILLIVOLTS) {
|
||||||
|
if(!board.isExternalPowered()) {
|
||||||
shutdown();
|
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();
|
||||||
|
delay(3000); // TODO: refactor eink variants to use EINK_DISPLAY macros to gate this properly
|
||||||
|
}
|
||||||
|
shutdown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
next_batt_chck = millis() + 8000;
|
next_batt_chck = millis() + 8000;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (_display != NULL && _display->isOn() && millis >= next_batt_chck) {
|
if (_display != NULL && _display->isOn() && millis() >= next_batt_chck) {
|
||||||
_cached_batt_mv = getBattMilliVolts();
|
_cached_batt_mv = getBattMilliVolts();
|
||||||
next_batt_chck = millis() + 8000;
|
next_batt_chck = millis() + 8000;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user