diff --git a/platformio.ini b/platformio.ini index b74bb1f..cf83902 100644 --- a/platformio.ini +++ b/platformio.ini @@ -35,6 +35,7 @@ check_tool = cppcheck check_flags = cppcheck: --suppress=*:*.pio\* --inline-suppr -DCPPCHECK check_skip_packages = yes +board_build.partitions = no_ota.csv [env:ttgo-t-beam-v1] board = ttgo-t-beam @@ -48,6 +49,6 @@ build_flags = -Werror -Wall -DTTGO_T_Beam_V0_7 board = ttgo-t-beam build_flags = -Werror -Wall -DTTGO_T_Beam_V1_2 -[env:ttgo-t-beam-v2_1] +[env:ttgo-t-lora-v2_1] board = ttgo-lora32-v21 build_flags = -Werror -Wall -DTTGO_T_LORA_V2_1 diff --git a/src/LoRa_APRS_Tracker.cpp b/src/LoRa_APRS_Tracker.cpp index 83a41c5..70d12fa 100644 --- a/src/LoRa_APRS_Tracker.cpp +++ b/src/LoRa_APRS_Tracker.cpp @@ -1,9 +1,7 @@ -#ifdef ESP32 -#include -#endif -#include +#include #include #include +#include #include #include #include @@ -26,9 +24,10 @@ Configuration Config; PowerManagement powerManagement; HardwareSerial neo6m_gps(1); TinyGPSPlus gps; +BluetoothSerial SerialBT; OneButton userButton = OneButton(BUTTON_PIN, true, true); -String versionDate = "2023.08.01 "; +String versionDate = "2023.08.04"; int myBeaconsIndex = 0; int myBeaconsSize = Config.beacons.size(); @@ -83,10 +82,7 @@ void setup() { //LoRa_Utils::setup(); WiFi.mode(WIFI_OFF); - btStop(); - logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "WiFi and BT controller stopped"); - esp_bt_controller_disable(); - logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "BT controller disabled"); + logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "WiFi controller stopped"); userButton.attachClick(BUTTON_Utils::singlePress); userButton.attachLongPressStart(BUTTON_Utils::longPress); diff --git a/src/pins_config.h b/src/pins_config.h index 0600315..66dc4e6 100644 --- a/src/pins_config.h +++ b/src/pins_config.h @@ -9,16 +9,22 @@ #define OLED_SCL 22 #define OLED_RST 16 +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) +#define GPS_RX 12 +#define GPS_TX 34 #define BUTTON_PIN 38 // The middle button GPIO on the T-Beam +#endif #ifdef TTGO_T_Beam_V0_7 #define GPS_RX 15 #define GPS_TX 12 +#define BUTTON_PIN 38 #endif -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SH1106) -#define GPS_RX 12 -#define GPS_TX 34 +#ifdef TTGO_T_LORA_V2_1 +#define GPS_RX -1 +#define GPS_TX -1 +#define BUTTON_PIN -1 #endif -#endif +#endif \ No newline at end of file diff --git a/src/power_utils.cpp b/src/power_utils.cpp index 7827d1c..1d2c5e7 100644 --- a/src/power_utils.cpp +++ b/src/power_utils.cpp @@ -8,7 +8,7 @@ extern logging::Logger logger; // cppcheck-suppress unusedFunction bool PowerManagement::begin(TwoWire &port) { -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106) +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) bool result = axp.begin(port, AXP192_SLAVE_ADDRESS); if (!result) { axp.setDCDC1Voltage(3300); @@ -38,7 +38,7 @@ bool PowerManagement::begin(TwoWire &port) { // cppcheck-suppress unusedFunction void PowerManagement::activateLoRa() { -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106) +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) axp.setPowerOutPut(AXP192_LDO2, AXP202_ON); #endif #ifdef TTGO_T_Beam_V1_2 @@ -49,7 +49,7 @@ void PowerManagement::activateLoRa() { // cppcheck-suppress unusedFunction void PowerManagement::deactivateLoRa() { -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106) +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) axp.setPowerOutPut(AXP192_LDO2, AXP202_OFF); #endif #ifdef TTGO_T_Beam_V1_2 @@ -59,8 +59,8 @@ void PowerManagement::deactivateLoRa() { // cppcheck-suppress unusedFunction void PowerManagement::activateGPS() { -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106) - axp.setPowerOutPut(AXP192_LDO2, AXP202_ON); +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) + axp.setPowerOutPut(AXP192_LDO3, AXP202_ON); #endif #ifdef TTGO_T_Beam_V1_2 PMU.setALDO3Voltage(3300); @@ -70,8 +70,8 @@ void PowerManagement::activateGPS() { // cppcheck-suppress unusedFunction void PowerManagement::deactivateGPS() { -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106) - axp.setPowerOutPut(AXP192_LDO2, AXP202_OFF); +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) + axp.setPowerOutPut(AXP192_LDO3, AXP202_OFF); #endif #ifdef TTGO_T_Beam_V1_2 PMU.disableALDO3(); @@ -80,35 +80,35 @@ void PowerManagement::deactivateGPS() { // cppcheck-suppress unusedFunction void PowerManagement::activateOLED() { -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106) +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON); #endif } // cppcheck-suppress unusedFunction void PowerManagement::decativateOLED() { -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106) +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) axp.setPowerOutPut(AXP192_DCDC1, AXP202_OFF); #endif } // cppcheck-suppress unusedFunction void PowerManagement::disableChgLed() { -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106) +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) axp.setChgLEDMode(AXP20X_LED_OFF); #endif } // cppcheck-suppress unusedFunction void PowerManagement::enableChgLed() { -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106) +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) axp.setChgLEDMode(AXP20X_LED_LOW_LEVEL); #endif } // cppcheck-suppress unusedFunction void PowerManagement::activateMeasurement() { -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106) +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) axp.adc1Enable(AXP202_BATT_CUR_ADC1 | AXP202_BATT_VOL_ADC1, true); #endif #ifdef TTGO_T_Beam_V1_2 @@ -122,14 +122,14 @@ void PowerManagement::activateMeasurement() { // cppcheck-suppress unusedFunction void PowerManagement::deactivateMeasurement() { -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106) +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) axp.adc1Enable(AXP202_BATT_CUR_ADC1 | AXP202_BATT_VOL_ADC1, false); #endif } // cppcheck-suppress unusedFunction double PowerManagement::getBatteryVoltage() { -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106) +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) return axp.getBattVoltage() / 1000.0; #endif #ifdef TTGO_T_Beam_V1_2 @@ -139,7 +139,7 @@ double PowerManagement::getBatteryVoltage() { // cppcheck-suppress unusedFunction double PowerManagement::getBatteryChargeDischargeCurrent() { -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106) +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) if (axp.isChargeing()) { return axp.getBattChargeCurrent(); } @@ -151,7 +151,7 @@ double PowerManagement::getBatteryChargeDischargeCurrent() { } bool PowerManagement::isBatteryConnected() { -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106) +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) return axp.isBatteryConnect(); #endif #ifdef TTGO_T_Beam_V1_2 @@ -160,7 +160,7 @@ bool PowerManagement::isBatteryConnected() { } bool PowerManagement::isChargeing() { -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106) +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) return axp.isChargeing(); #endif #ifdef TTGO_T_Beam_V1_2 @@ -169,7 +169,7 @@ bool PowerManagement::isChargeing() { } void PowerManagement::setup() { -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106) +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) Wire.begin(SDA, SCL); if (!begin(Wire)) { logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "AXP192", "init done!"); @@ -199,7 +199,7 @@ void PowerManagement::setup() { } void PowerManagement::lowerCpuFrequency() { -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SH1106) +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_LORA_V2_1) if (setCpuFrequencyMhz(80)) { logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "CPU frequency set to 80MHz"); } else { @@ -221,7 +221,7 @@ void PowerManagement::obtainBatteryInfo() { if (!(rate_limit_check_battery++ % 60)) BatteryIsConnected = isBatteryConnected(); if (BatteryIsConnected) { - #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106) + #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) batteryVoltage = String(getBatteryVoltage(), 2); #endif #ifdef TTGO_T_Beam_V1_2 @@ -244,7 +244,7 @@ bool PowerManagement::getBatteryInfoIsConnected() { } void PowerManagement::batteryManager() { -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SH1106) +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_LORA_V2_1) obtainBatteryInfo(); handleChargingLed(); #endif diff --git a/src/power_utils.h b/src/power_utils.h index 1713bda..84dd45d 100644 --- a/src/power_utils.h +++ b/src/power_utils.h @@ -2,7 +2,7 @@ #define POWER_UTILS_H_ #include -#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106) +#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) #include #endif #ifdef TTGO_T_Beam_V1_2 @@ -49,7 +49,7 @@ private: bool isBatteryConnected(); - #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106) + #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1) AXP20X_Class axp; #endif #ifdef TTGO_T_Beam_V1_2