From 684253ce0ed20f91ac232f3696d4126881637744 Mon Sep 17 00:00:00 2001 From: Eben van Ellewee Date: Mon, 29 Mar 2021 08:47:42 +0200 Subject: [PATCH] Display Battery Volts TTGO 2.1.6 --- RX_FSK/RX_FSK.ino | 1 + libraries/SondeLib/Display.cpp | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index 1738764..02c39f9 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -1767,6 +1767,7 @@ void setup() axp.clearIRQ(); } int ndevices = scanI2Cdevice(); + if (sonde.fingerprint == 31) { pinMode(35, INPUT); } if (sonde.fingerprint != 17 || ndevices > 0) break; // only retry for fingerprint 17 (startup problems of new t-beam with oled) delay(500); } diff --git a/libraries/SondeLib/Display.cpp b/libraries/SondeLib/Display.cpp index f4cbb40..a6a34a4 100644 --- a/libraries/SondeLib/Display.cpp +++ b/libraries/SondeLib/Display.cpp @@ -1445,7 +1445,23 @@ void Display::drawGPS(DispEntry *de) { void Display::drawBatt(DispEntry *de) { float val; char buf[30]; - if(!axp192_found) return; + // if(!axp192_found) return; + if (!axp192_found && sonde.fingerprint == 31) + { + xSemaphoreTake(axpSemaphore, portMAX_DELAY); + switch (de->extra[0]) + { + case 'V': + val = (float)(analogRead(35)) / 4095 * 2 * 3.3 * 1.1; + snprintf(buf, 30, "%.2f%s", val, de->extra + 1); + break; + default: + *buf = 0; + } + xSemaphoreGive(axpSemaphore); + rdis->setFont(de->fmt); + drawString(de, buf); + } else { xSemaphoreTake( axpSemaphore, portMAX_DELAY ); switch(de->extra[0]) { @@ -1487,6 +1503,7 @@ void Display::drawBatt(DispEntry *de) { xSemaphoreGive( axpSemaphore ); rdis->setFont(de->fmt); drawString(de, buf); + } } void Display::drawText(DispEntry *de) {