From 04a7f8989121a4a8645f2078ebc6033a20484c89 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Thu, 2 May 2024 12:57:18 -0400 Subject: [PATCH] code cleaning in power_utils --- src/LoRa_APRS_iGate.cpp | 16 ---------------- src/pins_config.h | 2 +- src/power_utils.cpp | 23 +++++++++++++++++++---- src/utils.cpp | 2 +- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index dcd56e94..cb29a93e 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -66,27 +66,11 @@ String firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seven void setup() { Serial.begin(115200); - - #ifdef BATTERY_PIN - pinMode(BATTERY_PIN, INPUT); - #endif - #ifdef INTERNAL_LED_PIN - pinMode(INTERNAL_LED_PIN, OUTPUT); - #endif - if (Config.externalVoltageMeasurement) { - pinMode(Config.externalVoltagePin, INPUT); - } - #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(HELTEC_V3) POWER_Utils::setup(); - #endif - delay(1000); Utils::setupDisplay(); - Config.check(); - LoRa_Utils::setup(); Utils::validateFreqs(); - iGateBeaconPacket = GPS_Utils::generateBeacon(); iGateLoRaBeaconPacket = GPS_Utils::generateiGateLoRaBeacon(); diff --git a/src/pins_config.h b/src/pins_config.h index 8f2d50e0..d3b4c7e0 100644 --- a/src/pins_config.h +++ b/src/pins_config.h @@ -140,7 +140,7 @@ #if defined(HELTEC_V3) #define INTERNAL_LED_PIN 35 #define BATTERY_PIN 1 -#define VExt_CTRL 36 +#define VEXT_CTRL 36 #define ADC_CTRL 37 #endif #if defined(ESP32_DIY_LoRa) || defined(ESP32_DIY_1W_LoRa) diff --git a/src/power_utils.cpp b/src/power_utils.cpp index 92442f6b..880ef2ca 100644 --- a/src/power_utils.cpp +++ b/src/power_utils.cpp @@ -94,7 +94,6 @@ namespace POWER_Utils { void setup() { - Wire.end(); #ifdef HAS_AXP192 Wire.begin(SDA, SCL); if (begin(Wire)) { @@ -126,11 +125,27 @@ namespace POWER_Utils { PMU.setSysPowerDownVoltage(2600); #endif - #if defined(HELTEC_V3) - pinMode(VExt_CTRL,OUTPUT); // this is for GPS and TFT screen on Wireless_Tracker and only for Oled in Heltec V3 - digitalWrite(VExt_CTRL, HIGH); + #ifdef BATTERY_PIN + pinMode(BATTERY_PIN, INPUT); + #endif + + #ifdef INTERNAL_LED_PIN + pinMode(INTERNAL_LED_PIN, OUTPUT); + #endif + + if (Config.externalVoltageMeasurement) { + pinMode(Config.externalVoltagePin, INPUT); + } + + #if defined(VEXT_CTRL) + pinMode(VEXT_CTRL,OUTPUT); // this is for GPS and TFT screen on Wireless_Tracker and only for Oled in Heltec V3 + digitalWrite(VEXT_CTRL, HIGH); + #endif + + #if defined(ADC_CTRL) pinMode(ADC_CTRL, OUTPUT); #endif + delay(1000); } } \ No newline at end of file diff --git a/src/utils.cpp b/src/utils.cpp index e6b9ec87..12ae6fb4 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -115,7 +115,7 @@ namespace Utils { beaconPacket += Config.beacon.comment; secondaryBeaconPacket += Config.beacon.comment; - #if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(HELTEC_HTCT62) || defined(HELTEC_V3) || defined(ESP32_DIY_LoRa_A7670) || defined(TTGO_T_LORA32_V2_1_915) + #ifdef BATTERY_PIN if (Config.sendBatteryVoltage) { beaconPacket += " Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V"; secondaryBeaconPacket += " Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V";