From 0632cbfa7988b1ec5b83fc0b1039f30dc4061f99 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Tue, 27 Jun 2023 20:54:31 -0400 Subject: [PATCH] test1 fail --- data/tracker_config.json | 6 +-- platformio.ini | 19 ++++++++- src/pins_config.h | 5 +++ src/power_utils.cpp | 86 ++++++++++++++++++++++++++++++++++------ src/power_utils.h | 11 +++++ 5 files changed, 109 insertions(+), 18 deletions(-) diff --git a/data/tracker_config.json b/data/tracker_config.json index 38b9ccb..3f386a0 100644 --- a/data/tracker_config.json +++ b/data/tracker_config.json @@ -1,7 +1,7 @@ { "beacons": [ { - "callsign": "NOCALL-7", + "callsign": "CD2RXU-6", "symbol": "[", "comment": "", "smart_beacon": { @@ -17,7 +17,7 @@ } }, { - "callsign": "NOCALL-7", + "callsign": "CD2RXU-6", "symbol": ">", "comment": "", "smart_beacon": { @@ -33,7 +33,7 @@ } }, { - "callsign": "NOCALL-7", + "callsign": "CD2RXU-6", "symbol": "b", "comment": "", "smart_beacon": { diff --git a/platformio.ini b/platformio.ini index b962fad..d3215dd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1,5 +1,15 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + [platformio] -default_envs = ttgo-t-beam-v1 +default_envs = ttgo-t-beam-v1_2 [env] platform = espressif32 @ 6.3.1 @@ -18,8 +28,9 @@ lib_deps = paulstoffregen/Time @ 1.6.1 shaggydog/OneButton @ 1.5.0 peterus/esp-logger @ 1.0.0 + lewisxhe/XPowersLib@^0.1.7 check_tool = cppcheck -check_flags = +check_flags = cppcheck: --suppress=*:*.pio\* --inline-suppr -DCPPCHECK check_skip_packages = yes @@ -30,3 +41,7 @@ build_flags = -Werror -Wall -DTTGO_T_Beam_V1_0 [env:ttgo-t-beam-v0_7] board = ttgo-t-beam build_flags = -Werror -Wall -DTTGO_T_Beam_V0_7 + +[env:ttgo-t-beam-v1_2] +board = ttgo-t-beam +build_flags = -Werror -Wall -DTTGO_T_Beam_V1_2 diff --git a/src/pins_config.h b/src/pins_config.h index 88e47ab..994d166 100644 --- a/src/pins_config.h +++ b/src/pins_config.h @@ -21,4 +21,9 @@ #define GPS_TX 34 #endif +#ifdef TTGO_T_Beam_V1_2 +#define GPS_RX 12 +#define GPS_TX 34 +#endif + #endif diff --git a/src/power_utils.cpp b/src/power_utils.cpp index 0dcb97c..34d04bf 100644 --- a/src/power_utils.cpp +++ b/src/power_utils.cpp @@ -1,86 +1,129 @@ #include "power_utils.h" #include "logger.h" +#define I2C_SDA 21 +#define I2C_SCL 22 + extern logging::Logger logger; // cppcheck-suppress unusedFunction bool PowerManagement::begin(TwoWire &port) { + #ifdef TTGO_T_Beam_V1_0 bool result = axp.begin(port, AXP192_SLAVE_ADDRESS); if (!result) { axp.setDCDC1Voltage(3300); } return result; + #endif + #ifdef TTGO_T_Beam_V1_2 + bool result = PMU.begin(Wire, AXP2101_SLAVE_ADDRESS, I2C_SDA, I2C_SCL); + if (!result) { + PMU.setDC3Voltage(3000); + PMU.enableDC3(); + PMU.setDC2Voltage(3000); + PMU.enableDC2(); + PMU.setDC1Voltage(3000); + PMU.enableDC1(); + } + return result; + #endif } // cppcheck-suppress unusedFunction void PowerManagement::activateLoRa() { + #ifdef TTGO_T_Beam_V1_0 axp.setPowerOutPut(AXP192_LDO2, AXP202_ON); + #endif + #ifdef TTGO_T_Beam_V1_2 + PMU.setALDO2Voltage(3300); + PMU.enableALDO2(); + #endif } // cppcheck-suppress unusedFunction void PowerManagement::deactivateLoRa() { + #ifdef TTGO_T_Beam_V1_0 axp.setPowerOutPut(AXP192_LDO2, AXP202_OFF); + #endif + #ifdef TTGO_T_Beam_V1_2 + PMU.disableALDO2(); + #endif } // cppcheck-suppress unusedFunction void PowerManagement::activateGPS() { - axp.setPowerOutPut(AXP192_LDO3, AXP202_ON); + #ifdef TTGO_T_Beam_V1_0 + axp.setPowerOutPut(AXP192_LDO2, AXP202_ON); + #endif + #ifdef TTGO_T_Beam_V1_2 + PMU.setALDO3Voltage(3300); + PMU.enableALDO3(); + #endif } // cppcheck-suppress unusedFunction void PowerManagement::deactivateGPS() { - axp.setPowerOutPut(AXP192_LDO3, AXP202_OFF); + #ifdef TTGO_T_Beam_V1_0 + axp.setPowerOutPut(AXP192_LDO2, AXP202_OFF); + #endif + #ifdef TTGO_T_Beam_V1_2 + PMU.disableALDO3(); + #endif } // cppcheck-suppress unusedFunction void PowerManagement::activateOLED() { - axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON); + //axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON); } // cppcheck-suppress unusedFunction void PowerManagement::decativateOLED() { - axp.setPowerOutPut(AXP192_DCDC1, AXP202_OFF); + //axp.setPowerOutPut(AXP192_DCDC1, AXP202_OFF); } // cppcheck-suppress unusedFunction void PowerManagement::disableChgLed() { - axp.setChgLEDMode(AXP20X_LED_OFF); + //axp.setChgLEDMode(AXP20X_LED_OFF); } // cppcheck-suppress unusedFunction void PowerManagement::enableChgLed() { - axp.setChgLEDMode(AXP20X_LED_LOW_LEVEL); + //axp.setChgLEDMode(AXP20X_LED_LOW_LEVEL); } // cppcheck-suppress unusedFunction void PowerManagement::activateMeasurement() { - axp.adc1Enable(AXP202_BATT_CUR_ADC1 | AXP202_BATT_VOL_ADC1, true); + //axp.adc1Enable(AXP202_BATT_CUR_ADC1 | AXP202_BATT_VOL_ADC1, true); } // cppcheck-suppress unusedFunction void PowerManagement::deactivateMeasurement() { - axp.adc1Enable(AXP202_BATT_CUR_ADC1 | AXP202_BATT_VOL_ADC1, false); + //axp.adc1Enable(AXP202_BATT_CUR_ADC1 | AXP202_BATT_VOL_ADC1, false); } // cppcheck-suppress unusedFunction double PowerManagement::getBatteryVoltage() { - return axp.getBattVoltage() / 1000.0; + //return axp.getBattVoltage() / 1000.0; + return 1.0; } // cppcheck-suppress unusedFunction double PowerManagement::getBatteryChargeDischargeCurrent() { - if (axp.isChargeing()) { + /*if (axp.isChargeing()) { return axp.getBattChargeCurrent(); } - return -1.0 * axp.getBattDischargeCurrent(); + return -1.0 * axp.getBattDischargeCurrent();*/ + return 1.0; } bool PowerManagement::isBatteryConnected() { - return axp.isBatteryConnect(); + //return axp.isBatteryConnect(); + return true; } bool PowerManagement::isChargeing() { - return axp.isChargeing(); + //return axp.isChargeing(); + return true; } void PowerManagement::setup() { @@ -96,6 +139,23 @@ void PowerManagement::setup() { activateGPS(); activateMeasurement(); #endif +#ifdef TTGO_T_Beam_V1_2 + Wire.begin(SDA, SCL); + if (!begin(Wire)) { + logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "AXP2101", "init done!"); + } else { + logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "AXP2101", "init failed!"); + } + Serial.println("activando LoRa"); + activateLoRa(); + Serial.println("activando OLED"); + activateOLED(); + Serial.println("activando GPS"); + activateGPS(); + Serial.println("activando Measurement"); + activateMeasurement(); + Serial.println("activado"); +#endif } void PowerManagement::lowerCpuFrequency() { diff --git a/src/power_utils.h b/src/power_utils.h index 65eb9a1..0f78cb4 100644 --- a/src/power_utils.h +++ b/src/power_utils.h @@ -2,7 +2,13 @@ #define POWER_UTILS_H_ #include +#ifdef TTGO_T_Beam_V1_0 #include +#endif +#ifdef TTGO_T_Beam_V1_2 +#define XPOWERS_CHIP_AXP2101 +#include "XPowersLib.h" +#endif class PowerManagement { public: @@ -42,7 +48,12 @@ private: bool isBatteryConnected(); + #ifdef TTGO_T_Beam_V1_0 AXP20X_Class axp; + #endif + #ifdef TTGO_T_Beam_V1_2 + XPowersPMU PMU; + #endif bool BatteryIsConnected; String batteryVoltage;