mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-04-04 14:08:36 +00:00
CodeCleaning
This commit is contained in:
parent
53461f289c
commit
886b661a62
11 changed files with 477 additions and 477 deletions
|
|
@ -3,16 +3,16 @@
|
|||
#include "pins_config.h"
|
||||
|
||||
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
|
||||
#define I2C_SDA 21
|
||||
#define I2C_SCL 22
|
||||
#define IRQ_PIN 35
|
||||
#define I2C_SDA 21
|
||||
#define I2C_SCL 22
|
||||
#define IRQ_PIN 35
|
||||
#endif
|
||||
|
||||
#ifdef HAS_AXP192
|
||||
XPowersAXP192 PMU;
|
||||
XPowersAXP192 PMU;
|
||||
#endif
|
||||
#ifdef HAS_AXP2101
|
||||
XPowersAXP2101 PMU;
|
||||
XPowersAXP2101 PMU;
|
||||
#endif
|
||||
|
||||
extern Configuration Config;
|
||||
|
|
@ -26,111 +26,111 @@ namespace POWER_Utils {
|
|||
|
||||
void activateMeasurement() {
|
||||
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
|
||||
PMU.disableTSPinMeasure();
|
||||
PMU.enableBattDetection();
|
||||
PMU.enableVbusVoltageMeasure();
|
||||
PMU.enableBattVoltageMeasure();
|
||||
PMU.enableSystemVoltageMeasure();
|
||||
PMU.disableTSPinMeasure();
|
||||
PMU.enableBattDetection();
|
||||
PMU.enableVbusVoltageMeasure();
|
||||
PMU.enableBattVoltageMeasure();
|
||||
PMU.enableSystemVoltageMeasure();
|
||||
#endif
|
||||
}
|
||||
|
||||
void activateLoRa() {
|
||||
#ifdef HAS_AXP192
|
||||
PMU.setLDO2Voltage(3300);
|
||||
PMU.enableLDO2();
|
||||
PMU.setLDO2Voltage(3300);
|
||||
PMU.enableLDO2();
|
||||
#endif
|
||||
#ifdef HAS_AXP2101
|
||||
PMU.setALDO2Voltage(3300);
|
||||
PMU.enableALDO2();
|
||||
PMU.setALDO2Voltage(3300);
|
||||
PMU.enableALDO2();
|
||||
#endif
|
||||
}
|
||||
|
||||
void deactivateLoRa() {
|
||||
#ifdef HAS_AXP192
|
||||
PMU.disableLDO2();
|
||||
PMU.disableLDO2();
|
||||
#endif
|
||||
#ifdef HAS_AXP2101
|
||||
PMU.disableALDO2();
|
||||
PMU.disableALDO2();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool begin(TwoWire &port) {
|
||||
#if defined(HAS_AXP192)
|
||||
bool result = PMU.begin(Wire, AXP192_SLAVE_ADDRESS, I2C_SDA, I2C_SCL);
|
||||
if (result) {
|
||||
PMU.disableDC2();
|
||||
PMU.disableLDO2();
|
||||
PMU.disableLDO3();
|
||||
PMU.setDC1Voltage(3300);
|
||||
PMU.enableDC1();
|
||||
PMU.setProtectedChannel(XPOWERS_DCDC3);
|
||||
PMU.disableIRQ(XPOWERS_AXP192_ALL_IRQ);
|
||||
}
|
||||
return result;
|
||||
bool result = PMU.begin(Wire, AXP192_SLAVE_ADDRESS, I2C_SDA, I2C_SCL);
|
||||
if (result) {
|
||||
PMU.disableDC2();
|
||||
PMU.disableLDO2();
|
||||
PMU.disableLDO3();
|
||||
PMU.setDC1Voltage(3300);
|
||||
PMU.enableDC1();
|
||||
PMU.setProtectedChannel(XPOWERS_DCDC3);
|
||||
PMU.disableIRQ(XPOWERS_AXP192_ALL_IRQ);
|
||||
}
|
||||
return result;
|
||||
#elif defined(HAS_AXP2101)
|
||||
bool result = PMU.begin(Wire, AXP2101_SLAVE_ADDRESS, I2C_SDA, I2C_SCL);
|
||||
if (result) {
|
||||
PMU.disableDC2();
|
||||
PMU.disableDC3();
|
||||
PMU.disableDC4();
|
||||
PMU.disableDC5();
|
||||
PMU.disableALDO1();
|
||||
PMU.disableALDO4();
|
||||
PMU.disableBLDO1();
|
||||
PMU.disableBLDO2();
|
||||
PMU.disableDLDO1();
|
||||
PMU.disableDLDO2();
|
||||
PMU.setDC1Voltage(3300);
|
||||
PMU.enableDC1();
|
||||
PMU.setButtonBatteryChargeVoltage(3300);
|
||||
PMU.enableButtonBatteryCharge();
|
||||
PMU.disableIRQ(XPOWERS_AXP2101_ALL_IRQ);
|
||||
}
|
||||
return result;
|
||||
bool result = PMU.begin(Wire, AXP2101_SLAVE_ADDRESS, I2C_SDA, I2C_SCL);
|
||||
if (result) {
|
||||
PMU.disableDC2();
|
||||
PMU.disableDC3();
|
||||
PMU.disableDC4();
|
||||
PMU.disableDC5();
|
||||
PMU.disableALDO1();
|
||||
PMU.disableALDO4();
|
||||
PMU.disableBLDO1();
|
||||
PMU.disableBLDO2();
|
||||
PMU.disableDLDO1();
|
||||
PMU.disableDLDO2();
|
||||
PMU.setDC1Voltage(3300);
|
||||
PMU.enableDC1();
|
||||
PMU.setButtonBatteryChargeVoltage(3300);
|
||||
PMU.enableButtonBatteryCharge();
|
||||
PMU.disableIRQ(XPOWERS_AXP2101_ALL_IRQ);
|
||||
}
|
||||
return result;
|
||||
#else
|
||||
return true;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void setup() {
|
||||
#ifdef HAS_AXP192
|
||||
Wire.begin(SDA, SCL);
|
||||
if (begin(Wire)) {
|
||||
Serial.println("AXP192 init done!");
|
||||
} else {
|
||||
Serial.println("AXP192 init failed!");
|
||||
}
|
||||
activateLoRa();
|
||||
activateMeasurement();
|
||||
PMU.setChargerTerminationCurr(XPOWERS_AXP192_CHG_ITERM_LESS_10_PERCENT);
|
||||
PMU.setChargeTargetVoltage(XPOWERS_AXP192_CHG_VOL_4V2);
|
||||
PMU.setChargerConstantCurr(XPOWERS_AXP192_CHG_CUR_780MA);
|
||||
PMU.setSysPowerDownVoltage(2600);
|
||||
Wire.begin(SDA, SCL);
|
||||
if (begin(Wire)) {
|
||||
Serial.println("AXP192 init done!");
|
||||
} else {
|
||||
Serial.println("AXP192 init failed!");
|
||||
}
|
||||
activateLoRa();
|
||||
activateMeasurement();
|
||||
PMU.setChargerTerminationCurr(XPOWERS_AXP192_CHG_ITERM_LESS_10_PERCENT);
|
||||
PMU.setChargeTargetVoltage(XPOWERS_AXP192_CHG_VOL_4V2);
|
||||
PMU.setChargerConstantCurr(XPOWERS_AXP192_CHG_CUR_780MA);
|
||||
PMU.setSysPowerDownVoltage(2600);
|
||||
#endif
|
||||
|
||||
#ifdef HAS_AXP2101
|
||||
Wire.begin(SDA, SCL);
|
||||
if (begin(Wire)) {
|
||||
Serial.println("AXP2101 init done!");
|
||||
} else {
|
||||
Serial.println("AXP2101 init failed!");
|
||||
}
|
||||
activateLoRa();
|
||||
activateMeasurement();
|
||||
PMU.setPrechargeCurr(XPOWERS_AXP2101_PRECHARGE_200MA);
|
||||
PMU.setChargerTerminationCurr(XPOWERS_AXP2101_CHG_ITERM_25MA);
|
||||
PMU.setChargeTargetVoltage(XPOWERS_AXP2101_CHG_VOL_4V2);
|
||||
PMU.setChargerConstantCurr(XPOWERS_AXP2101_CHG_CUR_800MA);
|
||||
PMU.setSysPowerDownVoltage(2600);
|
||||
Wire.begin(SDA, SCL);
|
||||
if (begin(Wire)) {
|
||||
Serial.println("AXP2101 init done!");
|
||||
} else {
|
||||
Serial.println("AXP2101 init failed!");
|
||||
}
|
||||
activateLoRa();
|
||||
activateMeasurement();
|
||||
PMU.setPrechargeCurr(XPOWERS_AXP2101_PRECHARGE_200MA);
|
||||
PMU.setChargerTerminationCurr(XPOWERS_AXP2101_CHG_ITERM_25MA);
|
||||
PMU.setChargeTargetVoltage(XPOWERS_AXP2101_CHG_VOL_4V2);
|
||||
PMU.setChargerConstantCurr(XPOWERS_AXP2101_CHG_CUR_800MA);
|
||||
PMU.setSysPowerDownVoltage(2600);
|
||||
#endif
|
||||
|
||||
#ifdef BATTERY_PIN
|
||||
pinMode(BATTERY_PIN, INPUT);
|
||||
pinMode(BATTERY_PIN, INPUT);
|
||||
#endif
|
||||
|
||||
#ifdef INTERNAL_LED_PIN
|
||||
pinMode(INTERNAL_LED_PIN, OUTPUT);
|
||||
pinMode(INTERNAL_LED_PIN, OUTPUT);
|
||||
#endif
|
||||
|
||||
if (Config.externalVoltageMeasurement) {
|
||||
|
|
@ -138,16 +138,16 @@ namespace POWER_Utils {
|
|||
}
|
||||
|
||||
#ifdef 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);
|
||||
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
|
||||
|
||||
#ifdef ADC_CTRL
|
||||
pinMode(ADC_CTRL, OUTPUT);
|
||||
pinMode(ADC_CTRL, OUTPUT);
|
||||
#endif
|
||||
|
||||
#ifdef HELTEC_WIRELESS_TRACKER
|
||||
Wire.begin(BOARD_I2C_SDA, BOARD_I2C_SCL);
|
||||
Wire.begin(BOARD_I2C_SDA, BOARD_I2C_SCL);
|
||||
#endif
|
||||
|
||||
delay(1000);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue