diff --git a/variants/lilygo_twatch_s3/TWatchS3Board.cpp b/variants/lilygo_twatch_s3/TWatchS3Board.cpp index 59fd8726..0e60aca4 100644 --- a/variants/lilygo_twatch_s3/TWatchS3Board.cpp +++ b/variants/lilygo_twatch_s3/TWatchS3Board.cpp @@ -96,10 +96,12 @@ void TWatchS3Board::begin() { } bool TWatchS3Board::power_init() { - PMU = new XPowersAXP2101(Wire, PIN_BOARD_SDA, PIN_BOARD_SCL, I2C_ADDR_PMU); + _axp = new XPowersAXP2101(Wire, PIN_BOARD_SDA, PIN_BOARD_SCL, I2C_ADDR_PMU); + PMU = _axp; // same object; see the note in TWatchS3Board.h if (!PMU->init()) { MESH_DEBUG_PRINTLN("Warning: Failed to find AXP2101 power management"); - delete PMU; + delete _axp; + _axp = NULL; PMU = NULL; return false; } @@ -152,7 +154,7 @@ bool TWatchS3Board::power_init() { // Matches the 2S ON / 6S OFF behaviour printed on LilyGo's own pin diagram. PMU->setPowerKeyPressOnTime(XPOWERS_POWERON_2S); PMU->setPowerKeyPressOffTime(XPOWERS_POWEROFF_6S); - PMU->setIrqLevelTime(XPOWERS_AXP2101_IRQ_TIME_1S); + _axp->setIrqLevelTime(XPOWERS_AXP2101_IRQ_TIME_1S); // not on XPowersLibInterface PMU->disableIRQ(XPOWERS_AXP2101_ALL_IRQ); PMU->clearIrqStatus(); diff --git a/variants/lilygo_twatch_s3/TWatchS3Board.h b/variants/lilygo_twatch_s3/TWatchS3Board.h index 42645e88..63d55818 100644 --- a/variants/lilygo_twatch_s3/TWatchS3Board.h +++ b/variants/lilygo_twatch_s3/TWatchS3Board.h @@ -10,14 +10,20 @@ // LilyGo T-Watch S3 board (non-GPS, 470 mAh). // -// Power is managed by an AXP2101 PMU on the main I2C bus. The PMU is held as the -// concrete XPowersAXP2101 rather than XPowersLibInterface because PMUButton -// needs isPekeyNegativeIrq()/isPekeyPositiveIrq(), which the interface does not -// declare. +// Power is managed by an AXP2101 PMU on the main I2C bus. Two pointers to the +// same object are kept, because XPowersLib splits its API by access specifier: +// PMU (XPowersLibInterface*) -- the power-channel ops (setPowerChannelVoltage, +// enable/disablePowerOutput, isPowerChannelEnable) are PROTECTED on +// XPowersAXP2101 and only reachable through the interface. +// _axp (XPowersAXP2101*) -- setIrqLevelTime() and the PWRON press/release +// edges isPekeyNegativeIrq()/isPekeyPositiveIrq() are AXP2101-only and +// absent from the interface. +// Everything else is public on both. class SensorBMA423; // full include kept in the .cpp to avoid a BLE-build header clash class TWatchS3Board : public ESP32Board { - XPowersAXP2101* PMU = NULL; + XPowersLibInterface* PMU = NULL; + XPowersAXP2101* _axp = NULL; // same object as PMU, concrete type SensorBMA423* _accel = nullptr; static volatile bool _tilt_flag; static void IRAM_ATTR onTiltISR(); // defined in the .cpp (IRAM relocation) @@ -31,7 +37,7 @@ public: bool tiltFired(); // The AXP2101 handle, for PMUButton. NULL if the PMU failed to init. - XPowersAXP2101* getPMU() { return PMU; } + XPowersAXP2101* getPMU() { return _axp; } void enterDeepSleep(uint32_t secs, int pin_wake_btn) { esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); diff --git a/variants/lilygo_twatch_s3/platformio.ini b/variants/lilygo_twatch_s3/platformio.ini index cd0adca4..18f0784e 100644 --- a/variants/lilygo_twatch_s3/platformio.ini +++ b/variants/lilygo_twatch_s3/platformio.ini @@ -48,8 +48,10 @@ build_flags = -D AUTO_SHUTDOWN_MILLIVOLTS=2800 -D ARDUINO_LOOP_STACK_SIZE=32768 ; ---- No GPS ---- - ; HAS_GPS and ENV_INCLUDE_GPS are deliberately left undefined. The watch map - ; screen, the GPS home page and the BLDO1 rail control are all gated on them. + ; HAS_GPS is deliberately left undefined, which drops the watch map screen. + ; ENV_INCLUDE_GPS must be explicitly zeroed: sensor_base defaults it to 1, and + ; it gates gpsStream, board.gpsPowerOn/Off and the GPS home page. + -D ENV_INCLUDE_GPS=0 -D ENV_INCLUDE_AHTX0=0 -D ENV_INCLUDE_BME280=0 -D ENV_INCLUDE_BMP280=0 diff --git a/variants/lilygo_twatch_s3/variant.h b/variants/lilygo_twatch_s3/variant.h index 30915516..57bafc0a 100644 --- a/variants/lilygo_twatch_s3/variant.h +++ b/variants/lilygo_twatch_s3/variant.h @@ -80,8 +80,18 @@ #define SDCARD_CS -1 // ----------------------------------------------------------------------------- -// GPS: none. HAS_GPS and ENV_INCLUDE_GPS are left undefined in platformio.ini, -// which drops the map screen, the GPS home page and the BLDO1 rail control. -// The optional external GPS shield lands on GPIO41 (RX) / GPIO42 (TX) if it is -// ever wired up. +// GPS: none. HAS_GPS and ENV_INCLUDE_GPS are left undefined / zeroed in +// platformio.ini, which drops the map screen, the GPS home page and the BLDO1 +// rail control. The optional external GPS shield lands on GPIO41 (RX) / +// GPIO42 (TX) if it is ever wired up. // ----------------------------------------------------------------------------- +// #define HAS_GPS 1 +// #define GPS_BAUDRATE 38400 +// #define GPS_RX_PIN 41 +// #define GPS_TX_PIN 42 + +// Fallback for code that references GPS_BAUDRATE without a HAS_GPS guard +// (e.g. MyMesh.cpp "gps.baud" CLI command) +#ifndef GPS_BAUDRATE +#define GPS_BAUDRATE 9600 +#endif diff --git a/variants/lilygo_twatch_s3_plus/platformio.ini b/variants/lilygo_twatch_s3_plus/platformio.ini index d6dd8a59..fefaeeb3 100644 --- a/variants/lilygo_twatch_s3_plus/platformio.ini +++ b/variants/lilygo_twatch_s3_plus/platformio.ini @@ -93,7 +93,7 @@ lib_deps = ; off until toggled on ("gps on"); maps, tiles and the on-screen keyboard are ; deferred to later phases. ; --------------------------------------------------------------------------- -[env:meck_twatch_standalone] +[env:meck_twatch_s3_plus_standalone] extends = LilyGo_TWatchS3Plus build_flags = ${LilyGo_TWatchS3Plus.build_flags} @@ -128,9 +128,9 @@ lib_ignore = ; Contacts stay PSRAM-allocated via initContacts(), covering the BLE stack's ; internal-SRAM use. ESP32_CPU_FREQ=80 sets the boot clock low; note that ; CPUPowerManager already governs the idle clock to 80 MHz at runtime. -; Flash: pio run -e meck_twatch_ble -t upload +; Flash: pio run -e meck_twatch_s3_plus_ble -t upload ; --------------------------------------------------------------------------- -[env:meck_twatch_ble] +[env:meck_twatch_s3_plus_ble] extends = LilyGo_TWatchS3Plus build_flags = ${LilyGo_TWatchS3Plus.build_flags}