Replace TBEAM_V10 macro guards with more appropriate HAS_AXP192. Also eliminates symbol redefinition of AXP192_SLAVE_ADDRESS

raytac-diy
Thomas Göttgens 2022-08-08 16:13:38 +02:00
rodzic 401b5d92aa
commit 6382f67b89
6 zmienionych plików z 12 dodań i 14 usunięć

Wyświetl plik

@ -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;

Wyświetl plik

@ -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");

Wyświetl plik

@ -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

Wyświetl plik

@ -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();

Wyświetl plik

@ -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

Wyświetl plik

@ -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
#define HAS_AXP192