kopia lustrzana https://github.com/lora-aprs/LoRa_APRS_Tracker
Update for T-Beam V1.2
After a quick test, I could only find a incorrect ampere meter. I didn't find any function in the new PMU - so yeah, it's a just "nice to know" for me so I removed it. Maybe someone can program it somehow, but I've tried a lot...pull/111/head
rodzic
91319291b1
commit
56423d4f63
|
@ -18,11 +18,16 @@ lib_deps =
|
|||
paulstoffregen/Time @ 1.6
|
||||
shaggydog/OneButton @ 1.5.0
|
||||
peterus/esp-logger @ 1.0.0
|
||||
lewisxhe/XPowersLib@^0.1.8
|
||||
check_tool = cppcheck
|
||||
check_flags =
|
||||
cppcheck: --suppress=*:*.pio\* --inline-suppr -DCPPCHECK
|
||||
check_skip_packages = yes
|
||||
|
||||
[env:ttgo-t-beam-v1_2]
|
||||
board = ttgo-t-beam
|
||||
build_flags = -Werror -Wall -DTTGO_T_Beam_V1_2
|
||||
|
||||
[env:ttgo-t-beam-v1]
|
||||
board = ttgo-t-beam
|
||||
build_flags = -Werror -Wall -DTTGO_T_Beam_V1_0
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "pins.h"
|
||||
#include "power_management.h"
|
||||
|
||||
#define VERSION "22.19.0"
|
||||
#define VERSION "23.09.08"
|
||||
|
||||
logging::Logger logger;
|
||||
|
||||
|
@ -64,12 +64,13 @@ static void toggle_display() {
|
|||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef TTGO_T_Beam_V1_0
|
||||
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2)
|
||||
Wire.begin(SDA, SCL);
|
||||
if (!powerManagement.begin(Wire)) {
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "AXP192", "init done!");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "PMU", "init done!");
|
||||
} else {
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "AXP192", "init failed!");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "PMU", "init failed!");
|
||||
}
|
||||
powerManagement.activateLoRa();
|
||||
powerManagement.activateOLED();
|
||||
|
@ -82,7 +83,7 @@ void setup() {
|
|||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "Version: " VERSION);
|
||||
setup_display();
|
||||
|
||||
show_display("OE5BPA", "LoRa APRS Tracker", "by Peter Buchegger", "Version: " VERSION, 2000);
|
||||
show_display("OE5BPA", "LoRa APRS Tracker", "by Peter Buchegger", "Updated by HrSh3rl0ck", "Version: " VERSION, 2000);
|
||||
load_config();
|
||||
|
||||
setup_gps();
|
||||
|
@ -178,7 +179,7 @@ void loop() {
|
|||
static bool BatteryIsConnected = false;
|
||||
static String batteryVoltage = "";
|
||||
static String batteryChargeCurrent = "";
|
||||
#ifdef TTGO_T_Beam_V1_0
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2)
|
||||
static unsigned int rate_limit_check_battery = 0;
|
||||
if (!(rate_limit_check_battery++ % 60))
|
||||
BatteryIsConnected = powerManagement.isBatteryConnect();
|
||||
|
@ -328,7 +329,17 @@ void loop() {
|
|||
|
||||
if (gps_time_update) {
|
||||
|
||||
show_display(BeaconMan.getCurrentBeaconConfig()->callsign, createDateString(now()) + " " + createTimeString(now()), String("Sats: ") + gps.satellites.value() + " HDOP: " + gps.hdop.hdop(), String("Next Bcn: ") + (BeaconMan.getCurrentBeaconConfig()->smart_beacon.active ? "~" : "") + createTimeString(nextBeaconTimeStamp), BatteryIsConnected ? (String("Bat: ") + batteryVoltage + "V, " + batteryChargeCurrent + "mA") : "Powered via USB", String("Smart Beacon: " + getSmartBeaconState()));
|
||||
show_display(BeaconMan.getCurrentBeaconConfig()->callsign,
|
||||
createDateString(now()) + " " + createTimeString(now()),
|
||||
String("Sats: ") + gps.satellites.value() + " HDOP: " + gps.hdop.hdop(),
|
||||
String("Next Bcn: ") + (BeaconMan.getCurrentBeaconConfig()->smart_beacon.active ? "~" : "") + createTimeString(nextBeaconTimeStamp),
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0)
|
||||
BatteryIsConnected ? (String("Bat: ") + batteryVoltage + "V, " + batteryChargeCurrent + "mA") : "Powered via USB",
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
BatteryIsConnected ? (String("Bat: ") + batteryVoltage + "V") : "Powered via USB",
|
||||
#endif
|
||||
String("Smart Beacon: " + getSmartBeaconState()));
|
||||
|
||||
if (BeaconMan.getCurrentBeaconConfig()->smart_beacon.active) {
|
||||
// Change the Tx internal based on the current speed
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#define GPS_TX 12
|
||||
#endif
|
||||
|
||||
#ifdef TTGO_T_Beam_V1_0
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2)
|
||||
#define GPS_RX 12
|
||||
#define GPS_TX 34
|
||||
#endif
|
||||
|
|
|
@ -7,80 +7,159 @@ PowerManagement::PowerManagement() {
|
|||
|
||||
// cppcheck-suppress unusedFunction
|
||||
bool PowerManagement::begin(TwoWire &port) {
|
||||
bool result = axp.begin(port, AXP192_SLAVE_ADDRESS);
|
||||
if (!result) {
|
||||
axp.setDCDC1Voltage(3300);
|
||||
}
|
||||
return result;
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0)
|
||||
bool result = axp.begin(port, AXP192_SLAVE_ADDRESS);
|
||||
if (!result) {
|
||||
axp.setDCDC1Voltage(3300);
|
||||
}
|
||||
return result;
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
bool result = PMU.begin(Wire, AXP2101_SLAVE_ADDRESS, 21, 22);
|
||||
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();
|
||||
}
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::activateLoRa() {
|
||||
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON);
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0)
|
||||
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON);
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
PMU.setALDO2Voltage(3300);
|
||||
PMU.enableALDO2();
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::deactivateLoRa() {
|
||||
axp.setPowerOutPut(AXP192_LDO2, AXP202_OFF);
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0)
|
||||
axp.setPowerOutPut(AXP192_LDO2, AXP202_OFF);
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
PMU.disableALDO2();
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::activateGPS() {
|
||||
axp.setPowerOutPut(AXP192_LDO3, AXP202_ON);
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0)
|
||||
axp.setPowerOutPut(AXP192_LDO3, AXP202_ON);
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
PMU.setALDO3Voltage(3300);
|
||||
PMU.enableALDO3();
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::deactivateGPS() {
|
||||
axp.setPowerOutPut(AXP192_LDO3, AXP202_OFF);
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0)
|
||||
axp.setPowerOutPut(AXP192_LDO3, AXP202_OFF);
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
PMU.disableALDO3();
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::activateOLED() {
|
||||
axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON);
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0)
|
||||
axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON);
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::decativateOLED() {
|
||||
axp.setPowerOutPut(AXP192_DCDC1, AXP202_OFF);
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0)
|
||||
axp.setPowerOutPut(AXP192_DCDC1, AXP202_OFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::disableChgLed() {
|
||||
axp.setChgLEDMode(AXP20X_LED_OFF);
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0)
|
||||
axp.setChgLEDMode(AXP20X_LED_OFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::enableChgLed() {
|
||||
axp.setChgLEDMode(AXP20X_LED_LOW_LEVEL);
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0)
|
||||
axp.setChgLEDMode(AXP20X_LED_LOW_LEVEL);
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::activateMeasurement() {
|
||||
axp.adc1Enable(AXP202_BATT_CUR_ADC1 | AXP202_BATT_VOL_ADC1, true);
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0)
|
||||
axp.adc1Enable(AXP202_BATT_CUR_ADC1 | AXP202_BATT_VOL_ADC1, true);
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
PMU.enableBattDetection();
|
||||
PMU.enableVbusVoltageMeasure();
|
||||
PMU.enableBattVoltageMeasure();
|
||||
PMU.enableSystemVoltageMeasure();
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::deactivateMeasurement() {
|
||||
axp.adc1Enable(AXP202_BATT_CUR_ADC1 | AXP202_BATT_VOL_ADC1, false);
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0)
|
||||
axp.adc1Enable(AXP202_BATT_CUR_ADC1 | AXP202_BATT_VOL_ADC1, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
double PowerManagement::getBatteryVoltage() {
|
||||
return axp.getBattVoltage() / 1000.0;
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0)
|
||||
return axp.getBattVoltage() / 1000.0;
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
return PMU.getBattVoltage() / 1000.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
double PowerManagement::getBatteryChargeDischargeCurrent() {
|
||||
if (axp.isChargeing()) {
|
||||
return axp.getBattChargeCurrent();
|
||||
}
|
||||
return -1.0 * axp.getBattDischargeCurrent();
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0)
|
||||
if (axp.isChargeing()) {
|
||||
return axp.getBattChargeCurrent();
|
||||
}
|
||||
return -1.0 * axp.getBattDischargeCurrent();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool PowerManagement::isBatteryConnect() {
|
||||
return axp.isBatteryConnect();
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0)
|
||||
return axp.isBatteryConnect();
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
return PMU.isBatteryConnect();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PowerManagement::isChargeing() {
|
||||
return axp.isChargeing();
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0)
|
||||
return axp.isChargeing();
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
return PMU.isCharging();
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -2,7 +2,17 @@
|
|||
#define POWER_MANAGEMENT_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <axp20x.h>
|
||||
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0)
|
||||
#include <axp20x.h>
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
#define XPOWERS_CHIP_AXP2101
|
||||
#include <XPowersLib.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
class PowerManagement {
|
||||
public:
|
||||
|
@ -31,7 +41,12 @@ public:
|
|||
bool isChargeing();
|
||||
|
||||
private:
|
||||
AXP20X_Class axp;
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0)
|
||||
AXP20X_Class axp;
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
XPowersPMU PMU;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Ładowanie…
Reference in New Issue