Display Battery Volts TTGO 2.1.6

This commit is contained in:
Eben van Ellewee 2021-03-29 08:47:42 +02:00
parent cd3b34c494
commit 684253ce0e
2 changed files with 19 additions and 1 deletions

View File

@ -1767,6 +1767,7 @@ void setup()
axp.clearIRQ(); axp.clearIRQ();
} }
int ndevices = scanI2Cdevice(); 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) if (sonde.fingerprint != 17 || ndevices > 0) break; // only retry for fingerprint 17 (startup problems of new t-beam with oled)
delay(500); delay(500);
} }

View File

@ -1445,7 +1445,23 @@ void Display::drawGPS(DispEntry *de) {
void Display::drawBatt(DispEntry *de) { void Display::drawBatt(DispEntry *de) {
float val; float val;
char buf[30]; 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 ); xSemaphoreTake( axpSemaphore, portMAX_DELAY );
switch(de->extra[0]) { switch(de->extra[0]) {
@ -1487,6 +1503,7 @@ void Display::drawBatt(DispEntry *de) {
xSemaphoreGive( axpSemaphore ); xSemaphoreGive( axpSemaphore );
rdis->setFont(de->fmt); rdis->setFont(de->fmt);
drawString(de, buf); drawString(de, buf);
}
} }
void Display::drawText(DispEntry *de) { void Display::drawText(DispEntry *de) {