Simplify HAS_PMU macro definition

raytac-diy
lewishe 2022-09-08 10:36:53 +08:00
rodzic 9244d03cf9
commit 35c77ef99c
7 zmienionych plików z 15 dodań i 12 usunięć

Wyświetl plik

@ -128,7 +128,7 @@ class ButtonThread : public concurrency::OSThread
#endif
// If user button is held down for 5 seconds, shutdown the device.
if ((millis() - longPressTime > 5 * 1000) && (longPressTime > 0)) {
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
#ifdef HAS_PMU
if (pmu_found == true) {
setLed(false);
power->shutdown();

Wyświetl plik

@ -7,7 +7,7 @@
#include "utils.h"
#include "buzz/buzz.h"
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
#ifdef HAS_PMU
#include "XPowersLibInterface.hpp"
#include "XPowersAXP2101.tpp"
#include "XPowersAXP192.tpp"
@ -235,7 +235,7 @@ void Power::shutdown()
{
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
#ifdef HAS_PMU
DEBUG_MSG("Shutting down\n");
if(PMU){
PMU->setChargingLedMode(XPOWERS_CHG_LED_OFF);
@ -309,7 +309,7 @@ int32_t Power::runOnce()
{
readPowerStatus();
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
#ifdef HAS_PMU
// WE no longer use the IRQ line to wake the CPU (due to false wakes from sleep), but we do poll
// the IRQ status by reading the registers over I2C
if(PMU){
@ -366,7 +366,7 @@ int32_t Power::runOnce()
bool Power::axpChipInit()
{
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
#ifdef HAS_PMU
if (!PMU) {
PMU = new XPowersAXP2101(Wire, I2C_SDA, I2C_SCL);

Wyświetl plik

@ -115,7 +115,7 @@ void scanI2Cdevice(void)
screen_found = addr;
DEBUG_MSG("st7567 display found\n");
}
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
#ifdef HAS_PMU
if (addr == XPOWERS_AXP192_AXP2101_ADDRESS) {
pmu_found = true;
DEBUG_MSG("axp192/axp2101 PMU found\n");

Wyświetl plik

@ -301,7 +301,7 @@ void setup()
setupModules();
// Do this after service.init (because that clears error_code)
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
#ifdef HAS_PMU
if (!pmu_found)
RECORD_CRITICALERROR(CriticalErrorCode_NoAXP192); // Record a hardware fault for missing hardware
#endif

Wyświetl plik

@ -34,6 +34,9 @@
#define HAS_RTC 1
#endif
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
#define HAS_PMU
#endif
//
// set HW_VENDOR
//

Wyświetl plik

@ -35,7 +35,7 @@ void powerCommandsCheck()
if (shutdownAtMsec && millis() > shutdownAtMsec) {
DEBUG_MSG("Shutting down from admin command\n");
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
#ifdef HAS_PMU
if (pmu_found == true) {
playShutdownMelody();
power->shutdown();

Wyświetl plik

@ -19,7 +19,7 @@
esp_sleep_source_t wakeCause; // the reason we booted this time
#endif
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
#ifdef HAS_PMU
#include "XPowersLibInterface.hpp"
extern XPowersLibInterface *PMU;
#endif
@ -78,7 +78,7 @@ void setLed(bool ledOn)
digitalWrite(LED_PIN, ledOn ^ LED_INVERTED);
#endif
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
#ifdef HAS_PMU
if (pmu_found) {
// blink the axp led
PMU->setChargingLedMode(ledOn ? XPOWERS_CHG_LED_ON : XPOWERS_CHG_LED_OFF);
@ -90,7 +90,7 @@ void setGPSPower(bool on)
{
DEBUG_MSG("Setting GPS power=%d\n", on);
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
#ifdef HAS_PMU
if (pmu_found){
#ifdef LILYGO_TBEAM_S3_CORE
on ? PMU->enablePowerOutput(XPOWERS_ALDO4) : PMU->disablePowerOutput(XPOWERS_ALDO4);
@ -190,7 +190,7 @@ void doDeepSleep(uint64_t msecToWake)
digitalWrite(VEXT_ENABLE, 1); // turn off the display power
#endif
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
#ifdef HAS_PMU
if (pmu_found) {
// Obsolete comment: from back when we we used to receive lora packets while CPU was in deep sleep.
// We no longer do that, because our light-sleep current draws are low enough and it provides fast start/low cost