From 6382f67b89be97c1c311e34c57bae7a557b17f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 8 Aug 2022 16:13:38 +0200 Subject: [PATCH] Replace TBEAM_V10 macro guards with more appropriate HAS_AXP192. Also eliminates symbol redefinition of AXP192_SLAVE_ADDRESS --- src/Power.cpp | 10 ++++------ src/debug/i2cScan.h | 2 +- src/main.cpp | 2 +- src/shutdown.h | 2 +- src/sleep.cpp | 8 ++++---- variants/tbeam/variant.h | 2 +- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index d471955b..1b8dd293 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -7,9 +7,7 @@ #include "utils.h" #include "buzz/buzz.h" -#ifdef TBEAM_V10 -// FIXME. nasty hack cleanup how we load axp192 -#undef AXP192_SLAVE_ADDRESS +#ifdef HAS_AXP192 #include "axp20x.h" AXP20X_Class axp; @@ -221,7 +219,7 @@ bool Power::setup() void Power::shutdown() { -#ifdef TBEAM_V10 +#ifdef HAS_AXP192 DEBUG_MSG("Shutting down\n"); axp.setChgLEDMode(AXP20X_LED_OFF); axp.shutdown(); @@ -293,7 +291,7 @@ int32_t Power::runOnce() { readPowerStatus(); -#ifdef TBEAM_V10 +#ifdef HAS_AXP192 // 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 axp.readIRQ(); @@ -343,7 +341,7 @@ int32_t Power::runOnce() */ bool Power::axp192Init() { -#ifdef TBEAM_V10 +#ifdef HAS_AXP192 if (axp192_found) { if (!axp.begin(Wire, AXP192_SLAVE_ADDRESS)) { batteryLevel = &axp; diff --git a/src/debug/i2cScan.h b/src/debug/i2cScan.h index 3d737c69..2b50f16e 100644 --- a/src/debug/i2cScan.h +++ b/src/debug/i2cScan.h @@ -110,7 +110,7 @@ void scanI2Cdevice(void) screen_found = addr; DEBUG_MSG("st7567 display found\n"); } -#ifdef AXP192_SLAVE_ADDRESS +#ifdef HAS_AXP192 if (addr == AXP192_SLAVE_ADDRESS) { axp192_found = true; DEBUG_MSG("axp192 PMU found\n"); diff --git a/src/main.cpp b/src/main.cpp index 66c4021c..ec50ea02 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -307,7 +307,7 @@ void setup() setupModules(); // Do this after service.init (because that clears error_code) -#ifdef AXP192_SLAVE_ADDRESS +#ifdef HAS_AXP192 if (!axp192_found) RECORD_CRITICALERROR(CriticalErrorCode_NoAXP192); // Record a hardware fault for missing hardware #endif diff --git a/src/shutdown.h b/src/shutdown.h index 4c82b16c..306f84d2 100644 --- a/src/shutdown.h +++ b/src/shutdown.h @@ -35,7 +35,7 @@ void powerCommandsCheck() if (shutdownAtMsec && millis() > shutdownAtMsec) { DEBUG_MSG("Shutting down from admin command\n"); -#ifdef TBEAM_V10 +#ifdef HAS_AXP192 if (axp192_found == true) { playShutdownMelody(); power->shutdown(); diff --git a/src/sleep.cpp b/src/sleep.cpp index e02bb8b3..06e0fa82 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -21,7 +21,7 @@ esp_sleep_source_t wakeCause; // the reason we booted this time #endif -#ifdef TBEAM_V10 +#ifdef HAS_AXP192 #include "axp20x.h" extern AXP20X_Class axp; #endif @@ -80,7 +80,7 @@ void setLed(bool ledOn) digitalWrite(LED_PIN, ledOn ^ LED_INVERTED); #endif -#ifdef TBEAM_V10 +#ifdef HAS_AXP192 if (axp192_found) { // blink the axp led axp.setChgLEDMode(ledOn ? AXP20X_LED_LOW_LEVEL : AXP20X_LED_OFF); @@ -92,7 +92,7 @@ void setGPSPower(bool on) { DEBUG_MSG("Setting GPS power=%d\n", on); -#ifdef TBEAM_V10 +#ifdef HAS_AXP192 if (axp192_found) axp.setPowerOutPut(AXP192_LDO3, on ? AXP202_ON : AXP202_OFF); // GPS main power #endif @@ -187,7 +187,7 @@ void doDeepSleep(uint64_t msecToWake) digitalWrite(VEXT_ENABLE, 1); // turn off the display power #endif -#ifdef TBEAM_V10 +#ifdef HAS_AXP192 if (axp192_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 diff --git a/variants/tbeam/variant.h b/variants/tbeam/variant.h index 11bc21f4..8a3a0b4c 100644 --- a/variants/tbeam/variant.h +++ b/variants/tbeam/variant.h @@ -34,4 +34,4 @@ // Leave undefined to disable our PMU IRQ handler. DO NOT ENABLE THIS because the pmuirq can cause sperious interrupts // and waking from light sleep // #define PMU_IRQ 35 -#define AXP192_SLAVE_ADDRESS 0x34 \ No newline at end of file +#define HAS_AXP192 \ No newline at end of file