Heltec WT has battery now
This commit is contained in:
parent
8874f34cfa
commit
19ab840161
|
|
@ -317,6 +317,7 @@ void show_display(String header, String line1, String line2, String line3, Strin
|
|||
void show_display(String header, String line1, String line2, String line3, String line4, String line5, int wait) {
|
||||
#ifdef HAS_TFT
|
||||
cleanTFT();
|
||||
//tft.setTextColor(TFT_RED,TFT_BLACK);
|
||||
tft.setTextColor(TFT_WHITE,TFT_BLACK);
|
||||
tft.setTextSize(2);
|
||||
tft.setCursor(0, 0);
|
||||
|
|
|
|||
|
|
@ -589,7 +589,7 @@ namespace MENU_Utils {
|
|||
if (POWER_Utils::getBatteryInfoIsConnected()) {
|
||||
String batteryVoltage = POWER_Utils::getBatteryInfoVoltage();
|
||||
String batteryCharge = POWER_Utils::getBatteryInfoCurrent();
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_LORA32_V2_1_GPS) || defined(TTGO_T_LORA32_V2_1_TNC)
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_LORA32_V2_1_GPS) || defined(TTGO_T_LORA32_V2_1_TNC) || defined(HELTEC_V3_GPS) || defined(HELTEC_WIRELESS_TRACKER)
|
||||
sixthRowMainMenu = "Bat: " + batteryVoltage + "V";
|
||||
#endif
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268)
|
||||
|
|
|
|||
|
|
@ -86,23 +86,6 @@
|
|||
#define RADIO_BUSY_PIN 4
|
||||
#endif
|
||||
|
||||
#ifdef HELTEC_V3_GPS
|
||||
#define OLED_SDA 17
|
||||
#define OLED_SCL 18
|
||||
#define OLED_RST 21
|
||||
#define GPS_RX 47
|
||||
#define GPS_TX 48
|
||||
#define BUTTON_PIN 0
|
||||
#define RADIO_SCLK_PIN 9
|
||||
#define RADIO_MISO_PIN 11
|
||||
#define RADIO_MOSI_PIN 10
|
||||
#define RADIO_CS_PIN 8
|
||||
#define RADIO_RST_PIN 12
|
||||
#define RADIO_DIO1_PIN 14
|
||||
#define RADIO_BUSY_PIN 13
|
||||
#define BATTERY_PIN 1
|
||||
#endif
|
||||
|
||||
#ifdef OE5HWN_MeshCom
|
||||
#define GPS_RX 17
|
||||
#define GPS_TX 16
|
||||
|
|
@ -134,15 +117,34 @@
|
|||
#define BATTERY_PIN 1
|
||||
#endif
|
||||
|
||||
#ifdef HELTEC_V3_GPS
|
||||
#define OLED_SDA 17
|
||||
#define OLED_SCL 18
|
||||
#define OLED_RST 21
|
||||
#define GPS_RX 47
|
||||
#define GPS_TX 48
|
||||
#define BUTTON_PIN 0
|
||||
#define BATTERY_PIN 1
|
||||
#define VExt_CTRL 36
|
||||
#define ADC_CTRL 37
|
||||
#define RADIO_SCLK_PIN 9
|
||||
#define RADIO_MISO_PIN 11
|
||||
#define RADIO_MOSI_PIN 10
|
||||
#define RADIO_CS_PIN 8
|
||||
#define RADIO_RST_PIN 12
|
||||
#define RADIO_DIO1_PIN 14
|
||||
#define RADIO_BUSY_PIN 13
|
||||
#endif
|
||||
|
||||
#ifdef HELTEC_WIRELESS_TRACKER
|
||||
#define VGNSS_CTRL 3 // Heltec Tracker needs this (pulled low?) for GPS and TFT
|
||||
#define GPS_RX 34
|
||||
#define GPS_TX 33
|
||||
#define GPS_PPS 36
|
||||
#define GPS_RESET 35
|
||||
#define BUTTON_PIN 0
|
||||
//#define BATTERY_PIN 1
|
||||
//#define ADC_CTRL 2 // active HIGH, powers the voltage divider. Only on V05 = V1.1
|
||||
#define BATTERY_PIN 1
|
||||
#define ADC_CTRL 2 // active HIGH, powers the voltage divider. Only on V05 = V1.1
|
||||
#define VExt_CTRL 3 // Heltec Tracker needs this (pulled low?) for GPS and TFT
|
||||
#define RADIO_SCLK_PIN 9
|
||||
#define RADIO_MISO_PIN 11
|
||||
#define RADIO_MOSI_PIN 10
|
||||
|
|
|
|||
|
|
@ -50,15 +50,12 @@ namespace POWER_Utils {
|
|||
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
|
||||
return PMU.getBattVoltage() / 1000.0;
|
||||
#endif
|
||||
#if defined(HELTEC_V3_GPS) || defined(ESP32_C3_DIY_LoRa_GPS)
|
||||
#if defined(HELTEC_V3_GPS) || defined(HELTEC_WIRELESS_TRACKER) || defined(ESP32_C3_DIY_LoRa_GPS)
|
||||
int adc_value = analogRead(BATTERY_PIN);
|
||||
double voltage = (adc_value * 3.3) / 4095.0;
|
||||
double inputDivider = (1.0 / (390.0 + 100.0)) * 100.0; // The voltage divider is a 390k + 100k resistor in series, 100k on the low side.
|
||||
return (voltage / inputDivider) + 0.3; // Yes, this offset is excessive, but the ADC on the ESP32s3 is quite inaccurate and noisy. Adjust to own measurements.
|
||||
#endif
|
||||
#ifdef HELTEC_WIRELESS_TRACKER
|
||||
return 0;
|
||||
#endif
|
||||
return (voltage / inputDivider) + 0.285; // Yes, this offset is excessive, but the ADC on the ESP32s3 is quite inaccurate and noisy. Adjust to own measurements.
|
||||
#endif
|
||||
}
|
||||
|
||||
String getBatteryInfoVoltage() {
|
||||
|
|
@ -135,7 +132,7 @@ namespace POWER_Utils {
|
|||
if (!(rate_limit_check_battery++ % 60))
|
||||
BatteryIsConnected = isBatteryConnected();
|
||||
if (BatteryIsConnected) {
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA32_V2_1_GPS) || defined(TTGO_T_LORA32_V2_1_TNC) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(HELTEC_V3_GPS) || defined(OE5HWN_MeshCom)
|
||||
#if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA32_V2_1_GPS) || defined(TTGO_T_LORA32_V2_1_TNC) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(HELTEC_V3_GPS) || defined(HELTEC_WIRELESS_TRACKER) || defined(OE5HWN_MeshCom)
|
||||
batteryVoltage = String(getBatteryVoltage(), 2);
|
||||
#endif
|
||||
#ifdef HAS_AXP2101
|
||||
|
|
@ -333,12 +330,13 @@ namespace POWER_Utils {
|
|||
PMU.setChargerConstantCurr(XPOWERS_AXP2101_CHG_CUR_800MA);
|
||||
PMU.setSysPowerDownVoltage(2600);
|
||||
#endif
|
||||
#ifdef HELTEC_V3_GPS
|
||||
pinMode(BATTERY_PIN, INPUT); // This could or should be elsewhere, but this was my point of entry.
|
||||
#endif
|
||||
#ifdef HELTEC_WIRELESS_TRACKER
|
||||
pinMode(VGNSS_CTRL,OUTPUT); // this is for GPS and TFT screen
|
||||
digitalWrite(VGNSS_CTRL, HIGH);
|
||||
|
||||
#if defined(HELTEC_V3_GPS) || defined(HELTEC_WIRELESS_TRACKER)
|
||||
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(ADC_CTRL, OUTPUT);
|
||||
digitalWrite(ADC_CTRL, HIGH);
|
||||
pinMode(BATTERY_PIN, INPUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue