Skip to content

Commit

Permalink
code cleaning in power_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
richonguzman committed May 2, 2024
1 parent d744f0a commit 04a7f89
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
16 changes: 0 additions & 16 deletions src/LoRa_APRS_iGate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/pins_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 19 additions & 4 deletions src/power_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ namespace POWER_Utils {


void setup() {
Wire.end();
#ifdef HAS_AXP192
Wire.begin(SDA, SCL);
if (begin(Wire)) {
Expand Down Expand Up @@ -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);
}

}
2 changes: 1 addition & 1 deletion src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 04a7f89

Please sign in to comment.