Skip to content

Commit f43126e

Browse files
committed
cleanups after change PMU lib
1 parent c7026ee commit f43126e

File tree

5 files changed

+14
-29
lines changed

5 files changed

+14
-29
lines changed

include/display.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ void dp_setup(int contrast = 0);
102102
void dp_refresh(bool nextPage = false);
103103
void dp_init(bool verbose = false);
104104
void dp_shutdown(void);
105-
void dp_message(const char *msg, int line, bool invers);
106105
void dp_setFont(int font, int inv = 0);
107106
void dp_dump(uint8_t *pBuffer = NULL);
108107
void dp_contrast(uint8_t contrast);

include/power.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void calibrate_voltage(void);
5555
bool batt_sufficient(void);
5656

5757
#ifdef HAS_PMU
58-
#include "XPowersLib.h"
58+
#include <XPowersLib.h>
5959
extern XPowersPMU pmu;
6060
enum pmu_power_t { pmu_power_on, pmu_power_off, pmu_power_sleep };
6161
void AXP192_powerevent_IRQ(void);

src/display.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -446,14 +446,6 @@ void dp_shutdown(void) {
446446
#endif
447447
}
448448

449-
// print static message on display
450-
void dp_message(const char *msg, int line, bool invers) {
451-
dp_setFont(MY_FONT_SMALL, invers ? 1 : 0);
452-
dp->setCursor(0, line * 8);
453-
dp->printf("%-16s", msg);
454-
dp_dump();
455-
} // dp_message
456-
457449
// ------------- QR code plotter -----------------
458450

459451
void dp_printqr(uint16_t offset_x, uint16_t offset_y, const char *Message) {

src/power.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ void AXP192_powerevent_IRQ(void) {
3535
pmu.getVbusCurrent());
3636
if (pmu.isVbusRemoveIrq())
3737
ESP_LOGI(TAG, "USB unplugged.");
38-
3938
if (pmu.isBatInsertIrq())
4039
ESP_LOGI(TAG, "Battery is connected.");
4140
if (pmu.isBatRemoveIrq())
@@ -48,18 +47,17 @@ void AXP192_powerevent_IRQ(void) {
4847
ESP_LOGI(TAG, "Battery high temperature.");
4948
if (pmu.isBattTempHighIrq())
5049
ESP_LOGI(TAG, "Battery low temperature.");
50+
51+
// PEK button handling:
52+
// long press -> shutdown power, must be exited by another longpress
53+
if (pmu.isPekeyLongPressIrq())
54+
AXP192_power(pmu_power_off); // switch off Lora, GPS, display
5155
#ifdef HAS_BUTTON
52-
// short press -> esp32 deep sleep mode, can be exited by pressing user button
53-
if (pmu.isPekeyShortPressIrq()) {
56+
// short press -> esp32 deep sleep mode, must be exited by user button
57+
if (pmu.isPekeyShortPressIrq())
5458
enter_deepsleep(0, HAS_BUTTON);
55-
}
5659
#endif
5760

58-
// long press -> shutdown power, can be exited by another longpress
59-
if (pmu.isPekeyLongPressIrq()) {
60-
AXP192_power(pmu_power_off); // switch off Lora, GPS, display
61-
}
62-
6361
pmu.clearIrqStatus();
6462

6563
// refresh stored voltage value
@@ -69,6 +67,8 @@ void AXP192_powerevent_IRQ(void) {
6967
void AXP192_power(pmu_power_t powerlevel) {
7068
switch (powerlevel) {
7169
case pmu_power_off:
70+
pmu.setChargerLedFunction(XPOWER_CHGLED_CTRL_MANUAL);
71+
pmu.setChargingLedFreq(XPOWERS_CHG_LED_DISABLE);
7272
pmu.shutdown();
7373
break;
7474
case pmu_power_sleep:
@@ -152,7 +152,7 @@ void AXP192_init(void) {
152152
);
153153
#endif // PMU_INT
154154

155-
// set charging parameterss according to user settings if we have (see power.h)
155+
// set charging parameters according to user settings if we have (see power.h)
156156
#ifdef PMU_CHG_CURRENT
157157
pmu.setChargeCurrent(PMU_CHG_CURRENT);
158158
pmu.setChargerVoltageLimit(PMU_CHG_CUTOFF);

src/reset.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,14 @@ void enter_deepsleep(const uint64_t wakeup_sec, gpio_num_t wakeup_gpio) {
105105
RTC_runmode = RUNMODE_SLEEP;
106106
int i;
107107

108-
// show message on display
109-
#ifdef HAS_DISPLAY
110-
dp_message("-GOING TO SLEEP-", 7, true);
111-
#endif
112-
113108
// validate wake up pin, if we have
114109
if (!GPIO_IS_VALID_GPIO(wakeup_gpio))
115110
wakeup_gpio = GPIO_NUM_MAX;
116111

117-
// stop further enqueuing of senddata and MAC processing
118-
// -> skipped, because shutting down bluedroid stack tends to crash
119-
// libpax_counter_stop();
112+
// stop further enqueuing of senddata and MAC processing
113+
libpax_counter_stop();
120114

121-
// switch off any power consuming hardware
115+
// switch off any power consuming hardware
122116
#if (HAS_SDS011)
123117
sds011_sleep();
124118
#endif

0 commit comments

Comments
 (0)