From ef115e1ad49436da61f5fb5a29dd7f12adf1064d Mon Sep 17 00:00:00 2001 From: richonguzman Date: Wed, 6 Dec 2023 13:56:04 -0300 Subject: [PATCH] add TNC mode --- platformio.ini | 2 +- src/power_utils.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/platformio.ini b/platformio.ini index 568c806..ee00d6e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -57,7 +57,7 @@ build_flags = -Werror -Wall -DTTGO_T_Beam_V1_0_SX1268 board = ttgo-t-beam build_flags = -Werror -Wall -DTTGO_T_Beam_V1_2 -[env:ttgo-t-lora-v2_1] +[env:ttgo-t-lora-v2_1_TNC] board = ttgo-lora32-v21 build_flags = -Werror -Wall -DTTGO_T_LORA_V2_1_TNC diff --git a/src/power_utils.cpp b/src/power_utils.cpp index 99821d4..ef7ed51 100644 --- a/src/power_utils.cpp +++ b/src/power_utils.cpp @@ -10,7 +10,7 @@ extern logging::Logger logger; // cppcheck-suppress unusedFunction bool PowerManagement::begin(TwoWire &port) { - #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1) + #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) return true; // Currently there is no init for V0.7 boards(they only measure battery voltage). #endif #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) @@ -133,7 +133,7 @@ void PowerManagement::deactivateMeasurement() { // cppcheck-suppress unusedFunction double PowerManagement::getBatteryVoltage() { - #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1) + #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) // the battery voltage is divided by 2 with two 100kOhm resistors and connected to ADC1 Channel 7 -> pin 35 // the measured voltage is inaccurate du to known nonlinearity and ~100mV offset of the ESP32 A/D converter int adc_value; @@ -155,7 +155,7 @@ double PowerManagement::getBatteryVoltage() { // cppcheck-suppress unusedFunction double PowerManagement::getBatteryChargeDischargeCurrent() { - #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1) + #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) return 0; #endif #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) @@ -170,7 +170,7 @@ double PowerManagement::getBatteryChargeDischargeCurrent() { } bool PowerManagement::isBatteryConnected() { - #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1) + #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) if(getBatteryVoltage() > 1.0) { return true; } else { @@ -186,7 +186,7 @@ bool PowerManagement::isBatteryConnected() { } bool PowerManagement::isChargeing() { - #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1) + #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) return 0; #endif #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) @@ -239,7 +239,7 @@ void PowerManagement::setup() { } void PowerManagement::lowerCpuFrequency() { - #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1) + #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) if (setCpuFrequencyMhz(80)) { logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "CPU frequency set to 80MHz"); } else { @@ -261,7 +261,7 @@ void PowerManagement::obtainBatteryInfo() { if (!(rate_limit_check_battery++ % 60)) BatteryIsConnected = isBatteryConnected(); if (BatteryIsConnected) { - #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) + #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) batteryVoltage = String(getBatteryVoltage(), 2); #endif #ifdef TTGO_T_Beam_V1_2