cleanups after change PMU lib
This commit is contained in:
parent
c7026ee7a4
commit
f43126eec2
@ -102,7 +102,6 @@ void dp_setup(int contrast = 0);
|
|||||||
void dp_refresh(bool nextPage = false);
|
void dp_refresh(bool nextPage = false);
|
||||||
void dp_init(bool verbose = false);
|
void dp_init(bool verbose = false);
|
||||||
void dp_shutdown(void);
|
void dp_shutdown(void);
|
||||||
void dp_message(const char *msg, int line, bool invers);
|
|
||||||
void dp_setFont(int font, int inv = 0);
|
void dp_setFont(int font, int inv = 0);
|
||||||
void dp_dump(uint8_t *pBuffer = NULL);
|
void dp_dump(uint8_t *pBuffer = NULL);
|
||||||
void dp_contrast(uint8_t contrast);
|
void dp_contrast(uint8_t contrast);
|
||||||
|
@ -55,7 +55,7 @@ void calibrate_voltage(void);
|
|||||||
bool batt_sufficient(void);
|
bool batt_sufficient(void);
|
||||||
|
|
||||||
#ifdef HAS_PMU
|
#ifdef HAS_PMU
|
||||||
#include "XPowersLib.h"
|
#include <XPowersLib.h>
|
||||||
extern XPowersPMU pmu;
|
extern XPowersPMU pmu;
|
||||||
enum pmu_power_t { pmu_power_on, pmu_power_off, pmu_power_sleep };
|
enum pmu_power_t { pmu_power_on, pmu_power_off, pmu_power_sleep };
|
||||||
void AXP192_powerevent_IRQ(void);
|
void AXP192_powerevent_IRQ(void);
|
||||||
|
@ -446,14 +446,6 @@ void dp_shutdown(void) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// print static message on display
|
|
||||||
void dp_message(const char *msg, int line, bool invers) {
|
|
||||||
dp_setFont(MY_FONT_SMALL, invers ? 1 : 0);
|
|
||||||
dp->setCursor(0, line * 8);
|
|
||||||
dp->printf("%-16s", msg);
|
|
||||||
dp_dump();
|
|
||||||
} // dp_message
|
|
||||||
|
|
||||||
// ------------- QR code plotter -----------------
|
// ------------- QR code plotter -----------------
|
||||||
|
|
||||||
void dp_printqr(uint16_t offset_x, uint16_t offset_y, const char *Message) {
|
void dp_printqr(uint16_t offset_x, uint16_t offset_y, const char *Message) {
|
||||||
|
@ -35,7 +35,6 @@ void AXP192_powerevent_IRQ(void) {
|
|||||||
pmu.getVbusCurrent());
|
pmu.getVbusCurrent());
|
||||||
if (pmu.isVbusRemoveIrq())
|
if (pmu.isVbusRemoveIrq())
|
||||||
ESP_LOGI(TAG, "USB unplugged.");
|
ESP_LOGI(TAG, "USB unplugged.");
|
||||||
|
|
||||||
if (pmu.isBatInsertIrq())
|
if (pmu.isBatInsertIrq())
|
||||||
ESP_LOGI(TAG, "Battery is connected.");
|
ESP_LOGI(TAG, "Battery is connected.");
|
||||||
if (pmu.isBatRemoveIrq())
|
if (pmu.isBatRemoveIrq())
|
||||||
@ -48,17 +47,16 @@ void AXP192_powerevent_IRQ(void) {
|
|||||||
ESP_LOGI(TAG, "Battery high temperature.");
|
ESP_LOGI(TAG, "Battery high temperature.");
|
||||||
if (pmu.isBattTempHighIrq())
|
if (pmu.isBattTempHighIrq())
|
||||||
ESP_LOGI(TAG, "Battery low temperature.");
|
ESP_LOGI(TAG, "Battery low temperature.");
|
||||||
#ifdef HAS_BUTTON
|
|
||||||
// short press -> esp32 deep sleep mode, can be exited by pressing user button
|
|
||||||
if (pmu.isPekeyShortPressIrq()) {
|
|
||||||
enter_deepsleep(0, HAS_BUTTON);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// long press -> shutdown power, can be exited by another longpress
|
// PEK button handling:
|
||||||
if (pmu.isPekeyLongPressIrq()) {
|
// long press -> shutdown power, must be exited by another longpress
|
||||||
|
if (pmu.isPekeyLongPressIrq())
|
||||||
AXP192_power(pmu_power_off); // switch off Lora, GPS, display
|
AXP192_power(pmu_power_off); // switch off Lora, GPS, display
|
||||||
}
|
#ifdef HAS_BUTTON
|
||||||
|
// short press -> esp32 deep sleep mode, must be exited by user button
|
||||||
|
if (pmu.isPekeyShortPressIrq())
|
||||||
|
enter_deepsleep(0, HAS_BUTTON);
|
||||||
|
#endif
|
||||||
|
|
||||||
pmu.clearIrqStatus();
|
pmu.clearIrqStatus();
|
||||||
|
|
||||||
@ -69,6 +67,8 @@ void AXP192_powerevent_IRQ(void) {
|
|||||||
void AXP192_power(pmu_power_t powerlevel) {
|
void AXP192_power(pmu_power_t powerlevel) {
|
||||||
switch (powerlevel) {
|
switch (powerlevel) {
|
||||||
case pmu_power_off:
|
case pmu_power_off:
|
||||||
|
pmu.setChargerLedFunction(XPOWER_CHGLED_CTRL_MANUAL);
|
||||||
|
pmu.setChargingLedFreq(XPOWERS_CHG_LED_DISABLE);
|
||||||
pmu.shutdown();
|
pmu.shutdown();
|
||||||
break;
|
break;
|
||||||
case pmu_power_sleep:
|
case pmu_power_sleep:
|
||||||
@ -152,7 +152,7 @@ void AXP192_init(void) {
|
|||||||
);
|
);
|
||||||
#endif // PMU_INT
|
#endif // PMU_INT
|
||||||
|
|
||||||
// set charging parameterss according to user settings if we have (see power.h)
|
// set charging parameters according to user settings if we have (see power.h)
|
||||||
#ifdef PMU_CHG_CURRENT
|
#ifdef PMU_CHG_CURRENT
|
||||||
pmu.setChargeCurrent(PMU_CHG_CURRENT);
|
pmu.setChargeCurrent(PMU_CHG_CURRENT);
|
||||||
pmu.setChargerVoltageLimit(PMU_CHG_CUTOFF);
|
pmu.setChargerVoltageLimit(PMU_CHG_CUTOFF);
|
||||||
|
@ -105,20 +105,14 @@ void enter_deepsleep(const uint64_t wakeup_sec, gpio_num_t wakeup_gpio) {
|
|||||||
RTC_runmode = RUNMODE_SLEEP;
|
RTC_runmode = RUNMODE_SLEEP;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// show message on display
|
|
||||||
#ifdef HAS_DISPLAY
|
|
||||||
dp_message("-GOING TO SLEEP-", 7, true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// validate wake up pin, if we have
|
// validate wake up pin, if we have
|
||||||
if (!GPIO_IS_VALID_GPIO(wakeup_gpio))
|
if (!GPIO_IS_VALID_GPIO(wakeup_gpio))
|
||||||
wakeup_gpio = GPIO_NUM_MAX;
|
wakeup_gpio = GPIO_NUM_MAX;
|
||||||
|
|
||||||
// stop further enqueuing of senddata and MAC processing
|
// stop further enqueuing of senddata and MAC processing
|
||||||
// -> skipped, because shutting down bluedroid stack tends to crash
|
libpax_counter_stop();
|
||||||
// libpax_counter_stop();
|
|
||||||
|
|
||||||
// switch off any power consuming hardware
|
// switch off any power consuming hardware
|
||||||
#if (HAS_SDS011)
|
#if (HAS_SDS011)
|
||||||
sds011_sleep();
|
sds011_sleep();
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user