1.3
This commit is contained in:
parent
2eaa294303
commit
08756e8564
|
|
@ -35,6 +35,7 @@ check_tool = cppcheck
|
|||
check_flags =
|
||||
cppcheck: --suppress=*:*.pio\* --inline-suppr -DCPPCHECK
|
||||
check_skip_packages = yes
|
||||
board_build.partitions = no_ota.csv
|
||||
|
||||
[env:ttgo-t-beam-v1]
|
||||
board = ttgo-t-beam
|
||||
|
|
@ -48,6 +49,6 @@ build_flags = -Werror -Wall -DTTGO_T_Beam_V0_7
|
|||
board = ttgo-t-beam
|
||||
build_flags = -Werror -Wall -DTTGO_T_Beam_V1_2
|
||||
|
||||
[env:ttgo-t-beam-v2_1]
|
||||
[env:ttgo-t-lora-v2_1]
|
||||
board = ttgo-lora32-v21
|
||||
build_flags = -Werror -Wall -DTTGO_T_LORA_V2_1
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
#ifdef ESP32
|
||||
#include <esp_bt.h>
|
||||
#endif
|
||||
#include <Arduino.h>
|
||||
#include <BluetoothSerial.h>
|
||||
#include <OneButton.h>
|
||||
#include <TinyGPS++.h>
|
||||
#include <Arduino.h>
|
||||
#include <logger.h>
|
||||
#include <WiFi.h>
|
||||
#include <LoRa.h>
|
||||
|
|
@ -26,9 +24,10 @@ Configuration Config;
|
|||
PowerManagement powerManagement;
|
||||
HardwareSerial neo6m_gps(1);
|
||||
TinyGPSPlus gps;
|
||||
BluetoothSerial SerialBT;
|
||||
OneButton userButton = OneButton(BUTTON_PIN, true, true);
|
||||
|
||||
String versionDate = "2023.08.01 ";
|
||||
String versionDate = "2023.08.04";
|
||||
|
||||
int myBeaconsIndex = 0;
|
||||
int myBeaconsSize = Config.beacons.size();
|
||||
|
|
@ -83,10 +82,7 @@ void setup() {
|
|||
//LoRa_Utils::setup();
|
||||
|
||||
WiFi.mode(WIFI_OFF);
|
||||
btStop();
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "WiFi and BT controller stopped");
|
||||
esp_bt_controller_disable();
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "BT controller disabled");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "WiFi controller stopped");
|
||||
|
||||
userButton.attachClick(BUTTON_Utils::singlePress);
|
||||
userButton.attachLongPressStart(BUTTON_Utils::longPress);
|
||||
|
|
|
|||
|
|
@ -9,16 +9,22 @@
|
|||
#define OLED_SCL 22
|
||||
#define OLED_RST 16
|
||||
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2)
|
||||
#define GPS_RX 12
|
||||
#define GPS_TX 34
|
||||
#define BUTTON_PIN 38 // The middle button GPIO on the T-Beam
|
||||
#endif
|
||||
|
||||
#ifdef TTGO_T_Beam_V0_7
|
||||
#define GPS_RX 15
|
||||
#define GPS_TX 12
|
||||
#define BUTTON_PIN 38
|
||||
#endif
|
||||
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#define GPS_RX 12
|
||||
#define GPS_TX 34
|
||||
#ifdef TTGO_T_LORA_V2_1
|
||||
#define GPS_RX -1
|
||||
#define GPS_TX -1
|
||||
#define BUTTON_PIN -1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -8,7 +8,7 @@ extern logging::Logger logger;
|
|||
|
||||
// cppcheck-suppress unusedFunction
|
||||
bool PowerManagement::begin(TwoWire &port) {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
bool result = axp.begin(port, AXP192_SLAVE_ADDRESS);
|
||||
if (!result) {
|
||||
axp.setDCDC1Voltage(3300);
|
||||
|
|
@ -38,7 +38,7 @@ bool PowerManagement::begin(TwoWire &port) {
|
|||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::activateLoRa() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON);
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
@ -49,7 +49,7 @@ void PowerManagement::activateLoRa() {
|
|||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::deactivateLoRa() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
axp.setPowerOutPut(AXP192_LDO2, AXP202_OFF);
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
@ -59,8 +59,8 @@ void PowerManagement::deactivateLoRa() {
|
|||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::activateGPS() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON);
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
axp.setPowerOutPut(AXP192_LDO3, AXP202_ON);
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
PMU.setALDO3Voltage(3300);
|
||||
|
|
@ -70,8 +70,8 @@ void PowerManagement::activateGPS() {
|
|||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::deactivateGPS() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
axp.setPowerOutPut(AXP192_LDO2, AXP202_OFF);
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
axp.setPowerOutPut(AXP192_LDO3, AXP202_OFF);
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
PMU.disableALDO3();
|
||||
|
|
@ -80,35 +80,35 @@ void PowerManagement::deactivateGPS() {
|
|||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::activateOLED() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON);
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::decativateOLED() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
axp.setPowerOutPut(AXP192_DCDC1, AXP202_OFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::disableChgLed() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
axp.setChgLEDMode(AXP20X_LED_OFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::enableChgLed() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
axp.setChgLEDMode(AXP20X_LED_LOW_LEVEL);
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::activateMeasurement() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
axp.adc1Enable(AXP202_BATT_CUR_ADC1 | AXP202_BATT_VOL_ADC1, true);
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
@ -122,14 +122,14 @@ void PowerManagement::activateMeasurement() {
|
|||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::deactivateMeasurement() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
axp.adc1Enable(AXP202_BATT_CUR_ADC1 | AXP202_BATT_VOL_ADC1, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
double PowerManagement::getBatteryVoltage() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
return axp.getBattVoltage() / 1000.0;
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
@ -139,7 +139,7 @@ double PowerManagement::getBatteryVoltage() {
|
|||
|
||||
// cppcheck-suppress unusedFunction
|
||||
double PowerManagement::getBatteryChargeDischargeCurrent() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
if (axp.isChargeing()) {
|
||||
return axp.getBattChargeCurrent();
|
||||
}
|
||||
|
|
@ -151,7 +151,7 @@ double PowerManagement::getBatteryChargeDischargeCurrent() {
|
|||
}
|
||||
|
||||
bool PowerManagement::isBatteryConnected() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
return axp.isBatteryConnect();
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
@ -160,7 +160,7 @@ bool PowerManagement::isBatteryConnected() {
|
|||
}
|
||||
|
||||
bool PowerManagement::isChargeing() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
return axp.isChargeing();
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
@ -169,7 +169,7 @@ bool PowerManagement::isChargeing() {
|
|||
}
|
||||
|
||||
void PowerManagement::setup() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
Wire.begin(SDA, SCL);
|
||||
if (!begin(Wire)) {
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "AXP192", "init done!");
|
||||
|
|
@ -199,7 +199,7 @@ void PowerManagement::setup() {
|
|||
}
|
||||
|
||||
void PowerManagement::lowerCpuFrequency() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_LORA_V2_1)
|
||||
if (setCpuFrequencyMhz(80)) {
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "CPU frequency set to 80MHz");
|
||||
} else {
|
||||
|
|
@ -221,7 +221,7 @@ void PowerManagement::obtainBatteryInfo() {
|
|||
if (!(rate_limit_check_battery++ % 60))
|
||||
BatteryIsConnected = isBatteryConnected();
|
||||
if (BatteryIsConnected) {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
batteryVoltage = String(getBatteryVoltage(), 2);
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
@ -244,7 +244,7 @@ bool PowerManagement::getBatteryInfoIsConnected() {
|
|||
}
|
||||
|
||||
void PowerManagement::batteryManager() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_LORA_V2_1)
|
||||
obtainBatteryInfo();
|
||||
handleChargingLed();
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define POWER_UTILS_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
#include <axp20x.h>
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
@ -49,7 +49,7 @@ private:
|
|||
|
||||
bool isBatteryConnected();
|
||||
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA_V2_1)
|
||||
AXP20X_Class axp;
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
|
|
|
|||
Loading…
Reference in New Issue