Skip to content

Commit e8d4ab5

Browse files
authored
Merge pull request #692 from liamcottle/feature/thinknode-m1-poweroff
ThinkNode M1: low battery auto shutdown
2 parents d4856a5 + 18ef1ba commit e8d4ab5

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

examples/companion_radio/ui-new/UITask.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,22 @@ void UITask::loop() {
551551
if (millis() > next_batt_chck) {
552552
uint16_t milliVolts = getBattMilliVolts();
553553
if (milliVolts > 0 && milliVolts < AUTO_SHUTDOWN_MILLIVOLTS) {
554+
555+
// show low battery shutdown alert
556+
// we should only do this for eink displays, which will persist after power loss
557+
#ifdef THINKNODE_M1
558+
if (_display != NULL) {
559+
_display->startFrame();
560+
_display->setTextSize(2);
561+
_display->setColor(DisplayDriver::RED);
562+
_display->drawTextCentered(_display->width() / 2, 20, "Low Battery.");
563+
_display->drawTextCentered(_display->width() / 2, 40, "Shutting Down!");
564+
_display->endFrame();
565+
}
566+
#endif
567+
554568
shutdown();
569+
555570
}
556571
next_batt_chck = millis() + 8000;
557572
}

src/helpers/nrf52/ThinkNodeM1Board.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ class ThinkNodeM1Board : public mesh::MainBoard {
5757
}
5858

5959
void powerOff() override {
60+
61+
// turn off all leds, sd_power_system_off will not do this for us
62+
#ifdef P_LORA_TX_LED
63+
digitalWrite(P_LORA_TX_LED, LOW);
64+
#endif
65+
66+
// power off board
6067
sd_power_system_off();
68+
6169
}
6270
};

variants/thinknode_m1/platformio.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ build_flags =
7777
-D DISPLAY_CLASS=GxEPDDisplay
7878
-D OFFLINE_QUEUE_SIZE=256
7979
-D PIN_BUZZER=6
80+
-D AUTO_SHUTDOWN_MILLIVOLTS=3300
8081
; -D MESH_PACKET_LOGGING=1
8182
; -D MESH_DEBUG=1
8283
build_src_filter = ${ThinkNode_M1.build_src_filter}

0 commit comments

Comments
 (0)