first code for TBeam Supreme
This commit is contained in:
parent
53eb701728
commit
7aadb4a0d8
|
|
@ -42,6 +42,21 @@ check_flags =
|
|||
check_skip_packages = yes
|
||||
board_build.partitions = no_ota.csv
|
||||
|
||||
[esp32dev_base]
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
|
||||
[esp32s3_base]
|
||||
board = esp32-s3-devkitc-1
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-DARDUINO_USB_MODE=1
|
||||
-DARDUINO_USB_CDC_ON_BOOT=1
|
||||
;-UARDUINO_USB_CDC_ON_BOOT
|
||||
;-UARDUINO_USB_DFU_ON_BOOT
|
||||
;-UARDUINO_USB_MSC_ON_BOOT
|
||||
;-DCORE_DEBUG_LEVEL=0
|
||||
|
||||
[env:ttgo-t-beam-v1_2]
|
||||
board = ttgo-t-beam
|
||||
build_flags = -Werror -Wall -DTTGO_T_Beam_V1_2
|
||||
|
|
@ -76,4 +91,10 @@ build_flags = -Werror -Wall -DTTGO_T_Beam_V1_2_SX1262
|
|||
|
||||
[env:ttgo-t-beam-v0_7]
|
||||
board = ttgo-t-beam
|
||||
build_flags = -Werror -Wall -DTTGO_T_Beam_V0_7
|
||||
build_flags = -Werror -Wall -DTTGO_T_Beam_V0_7
|
||||
|
||||
[env:ttgo_t_beam_S3_SUPREME_V3]
|
||||
board = esp32-s3-devkitc-1
|
||||
build_flags = ${esp32s3_base.build_flags}
|
||||
-DTTGO_T_Beam_S3_SUPREME_V3
|
||||
-DBOARD_HAS_PSRAM
|
||||
|
|
@ -27,12 +27,14 @@
|
|||
Configuration Config;
|
||||
HardwareSerial neo6m_gps(1);
|
||||
TinyGPSPlus gps;
|
||||
#ifndef TTGO_T_Beam_S3_SUPREME_V3
|
||||
BluetoothSerial SerialBT;
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262)
|
||||
#endif
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
OneButton userButton = OneButton(BUTTON_PIN, true, true);
|
||||
#endif
|
||||
|
||||
String versionDate = "2023.12.31";
|
||||
String versionDate = "2024.01.01";
|
||||
|
||||
int myBeaconsIndex = 0;
|
||||
int myBeaconsSize = Config.beacons.size();
|
||||
|
|
@ -140,11 +142,13 @@ void setup() {
|
|||
if (Config.bluetoothType==0) {
|
||||
BLE_Utils::setup();
|
||||
} else {
|
||||
#ifndef TTGO_T_Beam_S3_SUPREME_V3
|
||||
BLUETOOTH_Utils::setup();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!Config.simplifiedTrackerMode) {
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262)
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
userButton.attachClick(BUTTON_Utils::singlePress);
|
||||
userButton.attachLongPressStart(BUTTON_Utils::longPress);
|
||||
userButton.attachDoubleClick(BUTTON_Utils::doublePress);
|
||||
|
|
@ -189,7 +193,9 @@ void loop() {
|
|||
if (Config.bluetoothType==0) {
|
||||
BLE_Utils::sendToLoRa();
|
||||
} else {
|
||||
#ifndef TTGO_T_Beam_S3_SUPREME_V3
|
||||
BLUETOOTH_Utils::sendToLoRa();
|
||||
#endif
|
||||
}
|
||||
|
||||
int currentSpeed = (int) gps.speed.kmph();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@
|
|||
|
||||
#define ssd1306 //comment this line with "//" when using SH1106 screen instead of SSD1306
|
||||
|
||||
#if defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
#undef ssd1306
|
||||
#endif
|
||||
|
||||
#ifdef ssd1306
|
||||
#include <Adafruit_SSD1306.h>
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -41,7 +41,11 @@ namespace GPS_Utils {
|
|||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "GPS disabled");
|
||||
return;
|
||||
}
|
||||
#if defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
neo6m_gps.begin(9600, SERIAL_8N1, GPS_RX, GPS_TX);
|
||||
#else
|
||||
neo6m_gps.begin(9600, SERIAL_8N1, GPS_TX, GPS_RX);
|
||||
#endif
|
||||
}
|
||||
|
||||
void calculateDistanceCourse(String Callsign, double checkpointLatitude, double checkPointLongitude) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ SX1268 radio = new Module(RADIO_CS_PIN, RADIO_DIO1_PIN, RADIO_RST_PIN, RADIO_BUS
|
|||
bool transmissionFlag = true;
|
||||
bool enableInterrupt = true;
|
||||
#endif
|
||||
#if defined(TTGO_T_Beam_V1_2_SX1262)
|
||||
#if defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
SX1262 radio = new Module(RADIO_CS_PIN, RADIO_DIO1_PIN, RADIO_RST_PIN, RADIO_BUSY_PIN);
|
||||
bool transmissionFlag = true;
|
||||
bool enableInterrupt = true;
|
||||
|
|
@ -25,13 +25,13 @@ bool enableInterrupt = true;
|
|||
namespace LoRa_Utils {
|
||||
|
||||
void setFlag(void) {
|
||||
#if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262)
|
||||
#if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
transmissionFlag = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void setup() {
|
||||
#if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262)
|
||||
#if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "Set SPI pins!");
|
||||
SPI.begin(RADIO_SCLK_PIN, RADIO_MISO_PIN, RADIO_MOSI_PIN);
|
||||
float freq = (float)Config.loramodule.frequency/1000000;
|
||||
|
|
@ -46,7 +46,7 @@ namespace LoRa_Utils {
|
|||
radio.setSpreadingFactor(Config.loramodule.spreadingFactor);
|
||||
radio.setBandwidth(Config.loramodule.signalBandwidth);
|
||||
radio.setCodingRate(Config.loramodule.codingRate4);
|
||||
#if defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2_SX1262)
|
||||
#if defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
state = radio.setOutputPower(Config.loramodule.power + 2); // values available: 10, 17, 22 --> if 20 in tracker_conf.json it will be updated to 22.
|
||||
#endif
|
||||
#ifdef ESP32_DIY_1W_LoRa_GPS
|
||||
|
|
@ -99,7 +99,7 @@ namespace LoRa_Utils {
|
|||
if (Config.notification.buzzerActive && Config.notification.txBeep) {
|
||||
NOTIFICATION_Utils::beaconTxBeep();
|
||||
}
|
||||
#if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262)
|
||||
#if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
int state = radio.transmit("\x3c\xff\x01" + newPacket);
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
//Serial.println(F("success!"));
|
||||
|
|
@ -146,7 +146,7 @@ namespace LoRa_Utils {
|
|||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa Rx", "---> %s", packet.c_str());
|
||||
}
|
||||
#endif
|
||||
#if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262)
|
||||
#if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
if (transmissionFlag) {
|
||||
transmissionFlag = false;
|
||||
radio.startReceive();
|
||||
|
|
|
|||
|
|
@ -169,7 +169,9 @@ namespace MSG_Utils {
|
|||
if (Config.bluetoothType==0) {
|
||||
BLE_Utils::sendToPhone(packet.text.substring(3));
|
||||
} else {
|
||||
#ifndef TTGO_T_Beam_S3_SUPREME_V3
|
||||
BLUETOOTH_Utils::sendPacket(packet.text.substring(3));
|
||||
#endif
|
||||
}
|
||||
|
||||
if (digirepeaterActive && lastReceivedPacket.addressee!=currentBeacon->callsign) {
|
||||
|
|
|
|||
|
|
@ -5,9 +5,11 @@
|
|||
#undef OLED_SCL
|
||||
#undef OLED_RST
|
||||
|
||||
#ifndef TTGO_T_Beam_S3_SUPREME_V3
|
||||
#define OLED_SDA 21
|
||||
#define OLED_SCL 22
|
||||
#define OLED_RST 16
|
||||
#endif
|
||||
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2_SX1262)
|
||||
#define GPS_RX 12
|
||||
|
|
@ -65,4 +67,70 @@
|
|||
#define BUTTON_PIN -1
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
#define OLED_SDA 17
|
||||
#define OLED_SCL 18
|
||||
#define OLED_RST 16
|
||||
|
||||
#define SDA 17
|
||||
#define SCL 18
|
||||
|
||||
#define I2C1_SDA 42
|
||||
#define I2C1_SCL 41
|
||||
#define PMU_IRQ 40
|
||||
#define IRQ_PIN 40
|
||||
|
||||
|
||||
#define GPS_RX 9
|
||||
#define GPS_TX 8
|
||||
#define GPS_WAKEUP_PIN 7
|
||||
#define GPS_1PPS_PIN 6
|
||||
|
||||
#define BUTTON_PIN 0
|
||||
#define BUTTON_PIN_MASK GPIO_SEL_0
|
||||
#define BUTTON_CONUT (1)
|
||||
#define BUTTON_ARRAY {BUTTON_PIN}
|
||||
|
||||
|
||||
#define RADIO_SCLK_PIN (12)
|
||||
#define RADIO_MISO_PIN (13)
|
||||
#define RADIO_MOSI_PIN (11)
|
||||
#define RADIO_CS_PIN (10)
|
||||
#define RADIO_DIO0_PIN (-1)
|
||||
#define RADIO_RST_PIN (5)
|
||||
#define RADIO_DIO1_PIN (1)
|
||||
#define RADIO_BUSY_PIN (4)
|
||||
|
||||
|
||||
#define SPI_MOSI (35)
|
||||
#define SPI_SCK (36)
|
||||
#define SPI_MISO (37)
|
||||
#define SPI_CS (47)
|
||||
#define IMU_CS (34)
|
||||
#define IMU_INT (33)
|
||||
|
||||
#define SDCARD_MOSI SPI_MOSI
|
||||
#define SDCARD_MISO SPI_MISO
|
||||
#define SDCARD_SCLK SPI_SCK
|
||||
#define SDCARD_CS SPI_CS
|
||||
|
||||
#define PIN_NONE (-1)
|
||||
#define RTC_INT (14)
|
||||
|
||||
#define GPS_BAUD_RATE 9600
|
||||
|
||||
#define HAS_SDCARD
|
||||
#define HAS_GPS
|
||||
#define HAS_DISPLAY
|
||||
#define HAS_PMU
|
||||
|
||||
#define __HAS_SPI1__
|
||||
#define __HAS_SENSOR__
|
||||
|
||||
#define PMU_WIRE_PORT Wire1
|
||||
#define DISPLAY_MODEL U8G2_SH1106_128X64_NONAME_F_HW_I2C
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,15 +1,24 @@
|
|||
#include "configuration.h"
|
||||
#include "power_utils.h"
|
||||
#include "pins_config.h"
|
||||
#include "logger.h"
|
||||
|
||||
#ifndef TTGO_T_Beam_S3_SUPREME_V3
|
||||
#define I2C_SDA 21
|
||||
#define I2C_SCL 22
|
||||
#define IRQ_PIN 35
|
||||
#endif
|
||||
|
||||
#if defined(TTGO_T_Beam_V1_0)
|
||||
#ifdef TTGO_T_Beam_S3_SUPREME_V3
|
||||
#define I2C1_SDA 42
|
||||
#define I2C1_SCL 41
|
||||
#define IRQ_PIN 40
|
||||
#endif
|
||||
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
XPowersAXP192 PMU;
|
||||
#endif
|
||||
#if defined(TTGO_T_Beam_V1_2)
|
||||
#if defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
XPowersAXP2101 PMU;
|
||||
#endif
|
||||
|
||||
|
|
@ -17,7 +26,8 @@ extern Configuration Config;
|
|||
extern logging::Logger logger;
|
||||
extern bool disableGPS;
|
||||
|
||||
float lora32BatReadingCorr = 6.5; // % of correction to higher value to reflect the real battery voltage (adjust this to your needs)
|
||||
bool pmuInterrupt;
|
||||
float lora32BatReadingCorr = 6.5; // % of correction to higher value to reflect the real battery voltage (adjust this to your needs)
|
||||
|
||||
namespace POWER_Utils {
|
||||
|
||||
|
|
@ -25,6 +35,10 @@ namespace POWER_Utils {
|
|||
String batteryVoltage = "";
|
||||
String batteryChargeDischargeCurrent = "";
|
||||
|
||||
void setPMUFlag() {
|
||||
pmuInterrupt = true;
|
||||
}
|
||||
|
||||
double getBatteryVoltage() {
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS)
|
||||
int adc_value;
|
||||
|
|
@ -33,7 +47,7 @@ namespace POWER_Utils {
|
|||
voltage = (adc_value * 3.3 ) / 4095.0; // the battery voltage is divided by 2 with two 100kOhm resistors and connected to ADC1 Channel 7 -> pin 35
|
||||
return (2 * (voltage + 0.1)) * (1 + (lora32BatReadingCorr/100)); // 2 x voltage divider/+0.1 because ESP32 nonlinearity ~100mV ADC offset/extra correction
|
||||
#endif
|
||||
#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)
|
||||
#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(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
return PMU.getBattVoltage() / 1000.0;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -51,28 +65,28 @@ namespace POWER_Utils {
|
|||
}
|
||||
|
||||
void enableChgLed() {
|
||||
#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)
|
||||
#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(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
PMU.setChargingLedMode(XPOWERS_CHG_LED_ON);
|
||||
#endif
|
||||
}
|
||||
|
||||
void disableChgLed() {
|
||||
#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)
|
||||
#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(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
PMU.setChargingLedMode(XPOWERS_CHG_LED_OFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool isChargeing() {
|
||||
bool isCharging() {
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS)
|
||||
return 0;
|
||||
#endif
|
||||
#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)
|
||||
#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(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
return PMU.isCharging();
|
||||
#endif
|
||||
}
|
||||
|
||||
void handleChargingLed() {
|
||||
if (isChargeing()) {
|
||||
if (isCharging()) {
|
||||
enableChgLed();
|
||||
} else {
|
||||
disableChgLed();
|
||||
|
|
@ -89,7 +103,7 @@ namespace POWER_Utils {
|
|||
}
|
||||
return -1.0 * PMU.getBattDischargeCurrent();
|
||||
#endif
|
||||
#if defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_2_SX1262)
|
||||
#if defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
return PMU.getBatteryPercent();
|
||||
#endif
|
||||
}
|
||||
|
|
@ -102,7 +116,7 @@ namespace POWER_Utils {
|
|||
return false;
|
||||
}
|
||||
#endif
|
||||
#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)
|
||||
#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(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
return PMU.isBatteryConnect();
|
||||
#endif
|
||||
}
|
||||
|
|
@ -115,7 +129,7 @@ namespace POWER_Utils {
|
|||
#if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS)
|
||||
batteryVoltage = String(getBatteryVoltage(), 2);
|
||||
#endif
|
||||
#if defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_2_SX1262)
|
||||
#if defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
batteryVoltage = String(PMU.getBattVoltage());
|
||||
#endif
|
||||
batteryChargeDischargeCurrent = String(getBatteryChargeDischargeCurrent(), 0);
|
||||
|
|
@ -124,13 +138,13 @@ namespace POWER_Utils {
|
|||
|
||||
void batteryManager() {
|
||||
obtainBatteryInfo();
|
||||
#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)
|
||||
#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(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
handleChargingLed();
|
||||
#endif
|
||||
}
|
||||
|
||||
void activateMeasurement() {
|
||||
#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)
|
||||
#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(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
PMU.disableTSPinMeasure();
|
||||
PMU.enableBattDetection();
|
||||
PMU.enableVbusVoltageMeasure();
|
||||
|
|
@ -148,6 +162,10 @@ namespace POWER_Utils {
|
|||
PMU.setALDO3Voltage(3300);
|
||||
PMU.enableALDO3();
|
||||
#endif
|
||||
#if defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
PMU.setALDO4Voltage(3300);
|
||||
PMU.enableALDO4();
|
||||
#endif
|
||||
}
|
||||
|
||||
void deactivateGPS() {
|
||||
|
|
@ -157,6 +175,9 @@ namespace POWER_Utils {
|
|||
#if defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_2_SX1262)
|
||||
PMU.disableALDO3();
|
||||
#endif
|
||||
#if defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
PMU.disableALDO4();
|
||||
#endif
|
||||
}
|
||||
|
||||
void activateLoRa() {
|
||||
|
|
@ -168,6 +189,10 @@ namespace POWER_Utils {
|
|||
PMU.setALDO2Voltage(3300);
|
||||
PMU.enableALDO2();
|
||||
#endif
|
||||
#if defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
PMU.setALDO3Voltage(3300);
|
||||
PMU.enableALDO3();
|
||||
#endif
|
||||
}
|
||||
|
||||
void deactivateLoRa() {
|
||||
|
|
@ -177,6 +202,9 @@ namespace POWER_Utils {
|
|||
#if defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_2_SX1262)
|
||||
PMU.disableALDO2();
|
||||
#endif
|
||||
#if defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
PMU.disableALDO3();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool begin(TwoWire &port) {
|
||||
|
|
@ -196,6 +224,7 @@ namespace POWER_Utils {
|
|||
}
|
||||
return result;
|
||||
#endif
|
||||
|
||||
#if defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_2_SX1262)
|
||||
bool result = PMU.begin(Wire, AXP2101_SLAVE_ADDRESS, I2C_SDA, I2C_SCL);
|
||||
if (result) {
|
||||
|
|
@ -215,6 +244,25 @@ namespace POWER_Utils {
|
|||
}
|
||||
return result;
|
||||
#endif
|
||||
|
||||
#if defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
bool result = PMU.begin(Wire1, AXP2101_SLAVE_ADDRESS, I2C1_SDA, I2C1_SCL);
|
||||
if (result) {
|
||||
PMU.disableDC2();
|
||||
PMU.disableDC3();
|
||||
PMU.disableDC4();
|
||||
PMU.disableDC5();
|
||||
PMU.disableBLDO1();
|
||||
PMU.disableBLDO2();
|
||||
PMU.disableDLDO1();
|
||||
PMU.disableDLDO2();
|
||||
PMU.setDC1Voltage(3300);
|
||||
PMU.enableDC1();
|
||||
PMU.setALDO1Voltage(2300); // screen brightness???
|
||||
PMU.disableIRQ(XPOWERS_AXP2101_ALL_IRQ);
|
||||
}
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
void setup() {
|
||||
|
|
@ -238,6 +286,7 @@ namespace POWER_Utils {
|
|||
PMU.setChargerConstantCurr(XPOWERS_AXP192_CHG_CUR_780MA);
|
||||
PMU.setSysPowerDownVoltage(2600);
|
||||
#endif
|
||||
|
||||
#if defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_2_SX1262)
|
||||
Wire.begin(SDA, SCL);
|
||||
if (begin(Wire)) {
|
||||
|
|
@ -245,6 +294,21 @@ namespace POWER_Utils {
|
|||
} else {
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "AXP2101", "init failed!");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
#ifdef I2C1_SDA
|
||||
Wire1.begin(I2C1_SDA, I2C1_SCL);
|
||||
#endif
|
||||
Wire.begin(SDA, SCL);
|
||||
if (begin(Wire1)) {
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "AXP2101", "init done!");
|
||||
} else {
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "AXP2101", "init failed!");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
activateLoRa();
|
||||
if (disableGPS) {
|
||||
deactivateGPS();
|
||||
|
|
@ -261,7 +325,7 @@ namespace POWER_Utils {
|
|||
}
|
||||
|
||||
void lowerCpuFrequency() {
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262)
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
if (setCpuFrequencyMhz(80)) {
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "CPU frequency set to 80MHz");
|
||||
} else {
|
||||
|
|
@ -271,7 +335,7 @@ namespace POWER_Utils {
|
|||
}
|
||||
|
||||
void shutdown() {
|
||||
#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)
|
||||
#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(TTGO_T_Beam_S3_SUPREME_V3)
|
||||
PMU.shutdown();
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace POWER_Utils {
|
|||
void enableChgLed();
|
||||
void disableChgLed();
|
||||
|
||||
bool isChargeing();
|
||||
bool isCharging();
|
||||
void handleChargingLed();
|
||||
double getBatteryChargeDischargeCurrent();
|
||||
bool isBatteryConnected();
|
||||
|
|
|
|||
Loading…
Reference in New Issue