Skip to content

Commit dbd2e4c

Browse files
committed
companion: suspend radio when hibernating
This should significantly reduce power consumption in the hibernation. Implemented only for the SX126X radios, for others it's NOOP. Also explicitly shutdown peripherals (GPS, LED) on Heltec T114. Fixes: #1014 Signed-off-by: Jaroslav Škarvada <[email protected]>
1 parent 9405e8b commit dbd2e4c

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

examples/companion_radio/ui-new/UITask.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ void UITask::shutdown(bool restart){
650650
_board->reboot();
651651
} else {
652652
_display->turnOff();
653+
radio_driver.powerOff();
653654
_board->powerOff();
654655
}
655656
}

src/helpers/radiolib/CustomSX1262Wrapper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class CustomSX1262Wrapper : public RadioLibWrapper {
1515
float getLastRSSI() const override { return ((CustomSX1262 *)_radio)->getRSSI(); }
1616
float getLastSNR() const override { return ((CustomSX1262 *)_radio)->getSNR(); }
1717

18+
virtual void powerOff() override { ((CustomSX1262 *)_radio)->sleep(false); }
19+
1820
float packetScore(float snr, int packet_len) override {
1921
int sf = ((CustomSX1262 *)_radio)->spreadingFactor;
2022
return packetScoreInt(snr, sf, packet_len);

src/helpers/radiolib/RadioLibWrappers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class RadioLibWrapper : public mesh::Radio {
5050
virtual float getLastRSSI() const override;
5151
virtual float getLastSNR() const override;
5252

53+
virtual void powerOff() { /* no op */ }
54+
5355
float packetScore(float snr, int packet_len) override { return packetScoreInt(snr, 10, packet_len); } // assume sf=10
5456
};
5557

variants/heltec_t114/T114Board.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ class T114Board : public mesh::MainBoard {
4848
}
4949

5050
void powerOff() override {
51+
#ifdef LED_PIN
52+
digitalWrite(LED_PIN, HIGH);
53+
#endif
54+
#if ENV_INCLUDE_GPS == 1
55+
pinMode(GPS_EN, OUTPUT);
56+
digitalWrite(GPS_EN, LOW);
57+
#endif
5158
sd_power_system_off();
5259
}
5360

0 commit comments

Comments
 (0)