mirror of
https://github.com/lora-aprs/LoRa_APRS_Tracker.git
synced 2026-02-05 15:24:27 +01:00
Update for T-Beam v1.2 + QOL
After some tests, I could only find an 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... And a little QOL Update - i dont need the display to be always on... Push the middle Button (IO38) and the OLED Display will be deactivated or activated. (It was desired with the Issues)
This commit is contained in:
parent
91319291b1
commit
57ec8ad28c
|
|
@ -1,3 +1,11 @@
|
|||
# Ive updated Peterus's LoRa Software to the new T-Beam v1.2
|
||||
|
||||
The new MPU hasnt the same functions as the old one - so the Ampere Meter isnt working anymore. Its a "nice to have" for me - so ive removed it...
|
||||
Nothing more to say ^^
|
||||
|
||||
And a little QOL Update - i dont need the display to be always on... Push the middle Button (IO38) and the OLED Display will be deactivated or activated. (It was desired with the Issues)
|
||||
|
||||
|
||||
# LoRa APRS Tracker
|
||||
|
||||
The LoRa APRS Tracker will work with very cheep hardware which you can buy from amazon, ebay or aliexpress.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
@ -29,6 +29,8 @@ TinyGPSPlus gps;
|
|||
void setup_gps();
|
||||
void load_config();
|
||||
void setup_lora();
|
||||
bool OLED_deactivated = false;
|
||||
int OLED_deactivatedTime = 0;
|
||||
|
||||
String create_lat_aprs(RawDegrees lat);
|
||||
String create_long_aprs(RawDegrees lng);
|
||||
|
|
@ -64,12 +66,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,9 +85,9 @@ 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();
|
||||
setup_lora();
|
||||
|
||||
|
|
@ -131,6 +134,26 @@ void loop() {
|
|||
}
|
||||
}
|
||||
|
||||
pinMode(GPIO_NUM_38, INPUT_PULLUP);
|
||||
int btn_pressenIO38 = analogRead(GPIO_NUM_38);
|
||||
if(btn_pressenIO38 != 4095){
|
||||
if(OLED_deactivatedTime >= 180){
|
||||
if(OLED_deactivated) {
|
||||
OLED_deactivated = false;
|
||||
awake_display();
|
||||
OLED_deactivatedTime = 0;
|
||||
} else {
|
||||
OLED_deactivated = true;
|
||||
sleep_display();
|
||||
OLED_deactivatedTime = 0;
|
||||
};
|
||||
} else {
|
||||
OLED_deactivatedTime += 1;
|
||||
};
|
||||
} else {
|
||||
OLED_deactivatedTime = 0;
|
||||
};
|
||||
|
||||
bool gps_time_update = gps.time.isUpdated();
|
||||
bool gps_loc_update = gps.location.isUpdated();
|
||||
static bool gps_loc_update_valid = false;
|
||||
|
|
@ -178,7 +201,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 +351,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
|
||||
|
|
|
|||
|
|
@ -11,6 +11,15 @@ extern logging::Logger logger;
|
|||
|
||||
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RST);
|
||||
|
||||
void sleep_display()
|
||||
{
|
||||
display.ssd1306_command(SSD1306_DISPLAYOFF);
|
||||
};
|
||||
void awake_display()
|
||||
{
|
||||
display.ssd1306_command(SSD1306_DISPLAYON);
|
||||
};
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void setup_display() {
|
||||
pinMode(OLED_RST, OUTPUT);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
#define DISPLAY_H_
|
||||
|
||||
void setup_display();
|
||||
void sleep_display();
|
||||
void awake_display();
|
||||
void display_toggle(bool toggle);
|
||||
|
||||
void show_display(String header, int wait = 0);
|
||||
|
|
|
|||
|
|
@ -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,165 @@ 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
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
PMU.enableDC1();
|
||||
#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
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
PMU.disableDC1();
|
||||
#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
|
||||
|
|
|
|||
Loading…
Reference in a new issue