Merge pull request #692 from liamcottle/feature/thinknode-m1-poweroff
ThinkNode M1: low battery auto shutdown
This commit is contained in:
@@ -551,7 +551,22 @@ 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) {
|
||||||
|
|
||||||
|
// show low battery shutdown alert
|
||||||
|
// we should only do this for eink displays, which will persist after power loss
|
||||||
|
#ifdef THINKNODE_M1
|
||||||
|
if (_display != NULL) {
|
||||||
|
_display->startFrame();
|
||||||
|
_display->setTextSize(2);
|
||||||
|
_display->setColor(DisplayDriver::RED);
|
||||||
|
_display->drawTextCentered(_display->width() / 2, 20, "Low Battery.");
|
||||||
|
_display->drawTextCentered(_display->width() / 2, 40, "Shutting Down!");
|
||||||
|
_display->endFrame();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
shutdown();
|
shutdown();
|
||||||
|
|
||||||
}
|
}
|
||||||
next_batt_chck = millis() + 8000;
|
next_batt_chck = millis() + 8000;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void powerOff() override {
|
void powerOff() override {
|
||||||
|
|
||||||
|
// turn off all leds, sd_power_system_off will not do this for us
|
||||||
|
#ifdef P_LORA_TX_LED
|
||||||
|
digitalWrite(P_LORA_TX_LED, LOW);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// power off board
|
||||||
sd_power_system_off();
|
sd_power_system_off();
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ build_flags =
|
|||||||
-D DISPLAY_CLASS=GxEPDDisplay
|
-D DISPLAY_CLASS=GxEPDDisplay
|
||||||
-D OFFLINE_QUEUE_SIZE=256
|
-D OFFLINE_QUEUE_SIZE=256
|
||||||
-D PIN_BUZZER=6
|
-D PIN_BUZZER=6
|
||||||
|
-D AUTO_SHUTDOWN_MILLIVOLTS=3300
|
||||||
; -D MESH_PACKET_LOGGING=1
|
; -D MESH_PACKET_LOGGING=1
|
||||||
; -D MESH_DEBUG=1
|
; -D MESH_DEBUG=1
|
||||||
build_src_filter = ${ThinkNode_M1.build_src_filter}
|
build_src_filter = ${ThinkNode_M1.build_src_filter}
|
||||||
|
|||||||
Reference in New Issue
Block a user