From 684253ce0ed20f91ac232f3696d4126881637744 Mon Sep 17 00:00:00 2001 From: Eben van Ellewee Date: Mon, 29 Mar 2021 08:47:42 +0200 Subject: [PATCH 1/6] 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) { From 2db65cc2bdda2e411850734282ea6efe433c2c23 Mon Sep 17 00:00:00 2001 From: Eben van Ellewee Date: Mon, 29 Mar 2021 09:55:34 +0200 Subject: [PATCH 2/6] fix if statement --- libraries/SondeLib/Display.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/SondeLib/Display.cpp b/libraries/SondeLib/Display.cpp index a6a34a4..a8b54fc 100644 --- a/libraries/SondeLib/Display.cpp +++ b/libraries/SondeLib/Display.cpp @@ -1445,7 +1445,7 @@ void Display::drawGPS(DispEntry *de) { void Display::drawBatt(DispEntry *de) { float val; char buf[30]; - // if(!axp192_found) return; + if(!axp192_found && sonde.fingerprint != 31) return; if (!axp192_found && sonde.fingerprint == 31) { xSemaphoreTake(axpSemaphore, portMAX_DELAY); From 519c656cb0eeddb20c02dd69c2e92e222c0438d4 Mon Sep 17 00:00:00 2001 From: Eben van Ellewee Date: Tue, 30 Mar 2021 20:58:50 +0200 Subject: [PATCH 3/6] Edited OLED Battery screen to show just Volts --- RX_FSK/data/screens1.txt | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/RX_FSK/data/screens1.txt b/RX_FSK/data/screens1.txt index 0c425d8..9704bc1 100644 --- a/RX_FSK/data/screens1.txt +++ b/RX_FSK/data/screens1.txt @@ -203,7 +203,7 @@ timeaction=#,#,# 7,0=gV 7,2=xd= 7,4=gD -7,12=gI° +7,12=gI° ############ @BatteryOLED @@ -211,16 +211,17 @@ timer=-1,-1,-1 key1action=+,0,F,W key2action=>,#,#,# timeaction=#,#,# -fonts=0,1 -0,0=xBat.Status: -0,12=bS -1,0=xBatt: -1,6=bVV -2,0=bCmA (charge) -3,0=bDmA (disch.) -4,0=xUSB: -4,5=bUV -5,5=bImA -6,0=xTemp: -6,5=bT C +fonts=1,1 +0,0=xBattery Status +0,16=bS +2,0=xVoltage: +fonts=7,7 +6,10=bVV +#2,0=bCmA (charge) +#3,0=bDmA (disch.) +#4,0=xUSB: +#4,5=bUV +#5,5=bImA +#6,0=xTemp: +#6,5=bT C From 4e6514c2776ff575c9f3633cb1b1ec08aa6af288 Mon Sep 17 00:00:00 2001 From: "Hansi, dl9rdz" Date: Thu, 9 Sep 2021 16:26:44 +0200 Subject: [PATCH 4/6] enhancements for large ILI9341 display --- RX_FSK/version.h | 2 +- libraries/SondeLib/Display.cpp | 20 +- libraries/SondeLib/Display.h | 24 +- libraries/SondeLib/fonts/FreeSans18pt7b.h | 451 ++++++++++++++++++++++ 4 files changed, 475 insertions(+), 22 deletions(-) create mode 100644 libraries/SondeLib/fonts/FreeSans18pt7b.h diff --git a/RX_FSK/version.h b/RX_FSK/version.h index 7b40172..a4fbf21 100644 --- a/RX_FSK/version.h +++ b/RX_FSK/version.h @@ -1,4 +1,4 @@ const char *version_name = "rdzTTGOsonde"; -const char *version_id = "devel20210907"; +const char *version_id = "devel20210908"; const int SPIFFS_MAJOR=2; const int SPIFFS_MINOR=14; diff --git a/libraries/SondeLib/Display.cpp b/libraries/SondeLib/Display.cpp index 2422b9a..727c2b0 100644 --- a/libraries/SondeLib/Display.cpp +++ b/libraries/SondeLib/Display.cpp @@ -16,6 +16,7 @@ extern const char *version_id; #include #include #include +#include #include #include @@ -252,11 +253,11 @@ void U8x8Display::getDispSize(uint8_t *height, uint8_t *width, uint8_t *lineskip if(colskip) *colskip = 1; } -void U8x8Display::drawString(uint8_t x, uint8_t y, const char *s, int16_t width, uint16_t fg, uint16_t bg) { +void U8x8Display::drawString(uint16_t x, uint16_t y, const char *s, int16_t width, uint16_t fg, uint16_t bg) { u8x8->drawString(x, y, s); } -void U8x8Display::drawTile(uint8_t x, uint8_t y, uint8_t cnt, uint8_t *tile_ptr) { +void U8x8Display::drawTile(uint16_t x, uint16_t y, uint8_t cnt, uint8_t *tile_ptr) { u8x8->drawTile(x, y, cnt, tile_ptr); } @@ -278,7 +279,7 @@ void U8x8Display::welcome() { } static String previp; -void U8x8Display::drawIP(uint8_t x, uint8_t y, int16_t width, uint16_t fg, uint16_t bg) { +void U8x8Display::drawIP(uint16_t x, uint16_t y, int16_t width, uint16_t fg, uint16_t bg) { if(!previp.equals(sonde.ipaddr)) { // ip address has changed // create tiles @@ -305,7 +306,7 @@ void U8x8Display::drawIP(uint8_t x, uint8_t y, int16_t width, uint16_t fg, uint1 } // len must be multiple of 2, size is fixed for u8x8 display -void U8x8Display::drawQS(uint8_t x, uint8_t y, uint8_t len, uint8_t /*size*/, uint8_t *stat, uint16_t fg, uint16_t bg) { +void U8x8Display::drawQS(uint16_t x, uint16_t y, uint8_t len, uint8_t /*size*/, uint8_t *stat, uint16_t fg, uint16_t bg) { for(int i=0; istartWrite(); @@ -599,7 +601,7 @@ void ILI9225Display::welcome() { drawString(0, l+2*22, "by Hansi, DL9RDZ"); } -void ILI9225Display::drawIP(uint8_t x, uint8_t y, int16_t width, uint16_t fg, uint16_t bg) { +void ILI9225Display::drawIP(uint16_t x, uint16_t y, int16_t width, uint16_t fg, uint16_t bg) { char buf[20]; if(sonde.isAP) strcpy(buf, "A "); else *buf=0; strncat(buf, sonde.ipaddr.c_str(), 16); @@ -607,7 +609,7 @@ void ILI9225Display::drawIP(uint8_t x, uint8_t y, int16_t width, uint16_t fg, ui } // size: 3=> 3x5 symbols; 4=> 4x7 symbols -void ILI9225Display::drawQS(uint8_t x, uint8_t y, uint8_t len, uint8_t size, uint8_t *stat, uint16_t fg, uint16_t bg) { +void ILI9225Display::drawQS(uint16_t x, uint16_t y, uint8_t len, uint8_t size, uint8_t *stat, uint16_t fg, uint16_t bg) { if(size<3) size=3; if(size>4) size=4; const uint16_t width = len*(size+1); @@ -634,7 +636,7 @@ void ILI9225Display::drawQS(uint8_t x, uint8_t y, uint8_t len, uint8_t size, uin #if 1 #else // TO BE REMOVED -void MY_ILI9225::drawTile(uint8_t x, uint8_t y, uint8_t cnt, uint8_t *tile_ptr) { +void MY_ILI9225::drawTile(uint16_t x, uint16_t y, uint8_t cnt, uint8_t *tile_ptr) { int i,j; startWrite(); for(i=0; i' + {1047, 15, 26, 19, 3, -25}, // 0x3F '?' + {1096, 32, 31, 36, 1, -25}, // 0x40 '@' + {1220, 22, 26, 23, 1, -25}, // 0x41 'A' + {1292, 19, 26, 23, 3, -25}, // 0x42 'B' + {1354, 22, 26, 25, 1, -25}, // 0x43 'C' + {1426, 20, 26, 24, 3, -25}, // 0x44 'D' + {1491, 18, 26, 22, 3, -25}, // 0x45 'E' + {1550, 17, 26, 21, 3, -25}, // 0x46 'F' + {1606, 24, 26, 27, 1, -25}, // 0x47 'G' + {1684, 19, 26, 25, 3, -25}, // 0x48 'H' + {1746, 3, 26, 10, 4, -25}, // 0x49 'I' + {1756, 14, 26, 18, 1, -25}, // 0x4A 'J' + {1802, 20, 26, 24, 3, -25}, // 0x4B 'K' + {1867, 15, 26, 20, 3, -25}, // 0x4C 'L' + {1916, 24, 26, 30, 3, -25}, // 0x4D 'M' + {1994, 20, 26, 26, 3, -25}, // 0x4E 'N' + {2059, 25, 26, 27, 1, -25}, // 0x4F 'O' + {2141, 18, 26, 23, 3, -25}, // 0x50 'P' + {2200, 25, 28, 27, 1, -25}, // 0x51 'Q' + {2288, 20, 26, 25, 3, -25}, // 0x52 'R' + {2353, 20, 26, 23, 1, -25}, // 0x53 'S' + {2418, 19, 26, 22, 1, -25}, // 0x54 'T' + {2480, 19, 26, 25, 3, -25}, // 0x55 'U' + {2542, 21, 26, 23, 1, -25}, // 0x56 'V' + {2611, 32, 26, 33, 0, -25}, // 0x57 'W' + {2715, 21, 26, 23, 1, -25}, // 0x58 'X' + {2784, 23, 26, 24, 0, -25}, // 0x59 'Y' + {2859, 19, 26, 22, 1, -25}, // 0x5A 'Z' + {2921, 6, 33, 10, 2, -25}, // 0x5B '[' + {2946, 10, 26, 10, 0, -25}, // 0x5C '\' + {2979, 6, 33, 10, 1, -25}, // 0x5D ']' + {3004, 13, 13, 16, 2, -24}, // 0x5E '^' + {3026, 21, 2, 19, -1, 5}, // 0x5F '_' + {3032, 7, 5, 9, 1, -25}, // 0x60 '`' + {3037, 17, 19, 19, 1, -18}, // 0x61 'a' + {3078, 16, 26, 20, 2, -25}, // 0x62 'b' + {3130, 16, 19, 18, 1, -18}, // 0x63 'c' + {3168, 17, 26, 20, 1, -25}, // 0x64 'd' + {3224, 16, 19, 19, 1, -18}, // 0x65 'e' + {3262, 7, 26, 10, 1, -25}, // 0x66 'f' + {3285, 16, 27, 19, 1, -18}, // 0x67 'g' + {3339, 15, 26, 19, 2, -25}, // 0x68 'h' + {3388, 3, 26, 8, 2, -25}, // 0x69 'i' + {3398, 6, 34, 9, 0, -25}, // 0x6A 'j' + {3424, 16, 26, 18, 2, -25}, // 0x6B 'k' + {3476, 3, 26, 7, 2, -25}, // 0x6C 'l' + {3486, 24, 19, 28, 2, -18}, // 0x6D 'm' + {3543, 15, 19, 19, 2, -18}, // 0x6E 'n' + {3579, 17, 19, 19, 1, -18}, // 0x6F 'o' + {3620, 16, 25, 20, 2, -18}, // 0x70 'p' + {3670, 17, 25, 20, 1, -18}, // 0x71 'q' + {3724, 9, 19, 12, 2, -18}, // 0x72 'r' + {3746, 14, 19, 17, 2, -18}, // 0x73 's' + {3780, 7, 23, 10, 1, -22}, // 0x74 't' + {3801, 15, 19, 19, 2, -18}, // 0x75 'u' + {3837, 17, 19, 17, 0, -18}, // 0x76 'v' + {3878, 25, 19, 25, 0, -18}, // 0x77 'w' + {3938, 16, 19, 17, 0, -18}, // 0x78 'x' + {3976, 17, 27, 17, 0, -18}, // 0x79 'y' + {4034, 15, 19, 17, 1, -18}, // 0x7A 'z' + {4070, 8, 33, 12, 1, -25}, // 0x7B '{' + {4103, 2, 33, 9, 3, -25}, // 0x7C '|' + {4112, 8, 33, 12, 3, -25}, // 0x7D '}' + {4145, 15, 7, 18, 1, -15}}; // 0x7E '~' + +const GFXfont FreeSans18pt7b PROGMEM = {(uint8_t *)FreeSans18pt7bBitmaps, + (GFXglyph *)FreeSans18pt7bGlyphs, 0x20, + 0x7E, 42}; + +// Approx. 4831 bytes From aa315d545a6aec1f975748001905da4fa09fa6fd Mon Sep 17 00:00:00 2001 From: "Hansi, dl9rdz" Date: Thu, 9 Sep 2021 22:34:50 +0200 Subject: [PATCH 5/6] revert screens to include all info --- RX_FSK/data/screens1.txt | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/RX_FSK/data/screens1.txt b/RX_FSK/data/screens1.txt index fa85afa..47b9321 100644 --- a/RX_FSK/data/screens1.txt +++ b/RX_FSK/data/screens1.txt @@ -203,7 +203,7 @@ timeaction=#,#,# 7,0=gV 7,2=xd= 7,4=gD -7,12=gI° +7,12=gI° ############ @BatteryOLED @@ -211,17 +211,16 @@ timer=-1,-1,-1 key1action=+,0,F,W key2action=>,#,#,# timeaction=#,#,# -fonts=1,1 -0,0=xBattery Status -0,16=bS -2,0=xVoltage: -fonts=7,7 -6,10=bVV -#2,0=bCmA (charge) -#3,0=bDmA (disch.) -#4,0=xUSB: -#4,5=bUV -#5,5=bImA -#6,0=xTemp: -#6,5=bT C +fonts=0,1 +0,0=xBat.Status: +0,12=bS +1,0=xBatt: +1,6=bVV +2,0=bCmA (charge) +3,0=bDmA (disch.) +4,0=xUSB: +4,5=bUV +5,5=bImA +6,0=xTemp: +6,5=bT C From c42204a5796f32f29766b73e6e7af560b104a4f2 Mon Sep 17 00:00:00 2001 From: "Hansi, dl9rdz" Date: Thu, 9 Sep 2021 23:25:15 +0200 Subject: [PATCH 6/6] +configurable batt adc, revert screens1.txt --- RX_FSK/RX_FSK.ino | 4 +++- RX_FSK/version.h | 2 +- libraries/SondeLib/Display.cpp | 10 +++------- libraries/SondeLib/Sonde.cpp | 5 +++++ libraries/SondeLib/Sonde.h | 1 + 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index 101735a..a1f8dc1 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -632,6 +632,7 @@ struct st_configitems config_list[] = { {"led_pout", "LED output port", 0, &sonde.config.led_pout}, {"gps_rxd", "GPS RXD pin (-1 to disable)", 0, &sonde.config.gps_rxd}, {"gps_txd", "GPS TXD pin (not really needed)", 0, &sonde.config.gps_txd}, + {"batt_adc", "Battery measurement pin", 0, &sonde.config.batt_adc}, #if 1 {"sx1278_ss", "SX1278 SS", 0, &sonde.config.sx1278_ss}, {"sx1278_miso", "SX1278 MISO", 0, &sonde.config.sx1278_miso}, @@ -720,6 +721,7 @@ const char *createConfigForm() { HTMLBODY(ptr, "config.html"); strcat(ptr, ""); for (int i = 0; i < N_CONFIG; i++) { + Serial.printf("%d: %s -- %d\n", i, config_list[i].label, strlen(ptr)); switch (config_list[i].type) { case -5: // Heading addConfigHeading(ptr, config_list[i].label); @@ -1929,11 +1931,11 @@ 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); } } + if (sonde.config.batt_adc>=0) { pinMode(sonde.config.batt_adc, INPUT); } if (sonde.config.power_pout >= 0) { // for a heltec v2, pull GPIO21 low for display power pinMode(sonde.config.power_pout & 127, OUTPUT); digitalWrite(sonde.config.power_pout & 127, sonde.config.power_pout & 128 ? 1 : 0); diff --git a/RX_FSK/version.h b/RX_FSK/version.h index a4fbf21..e356351 100644 --- a/RX_FSK/version.h +++ b/RX_FSK/version.h @@ -1,4 +1,4 @@ const char *version_name = "rdzTTGOsonde"; -const char *version_id = "devel20210908"; +const char *version_id = "devel20210908b"; const int SPIFFS_MAJOR=2; const int SPIFFS_MINOR=14; diff --git a/libraries/SondeLib/Display.cpp b/libraries/SondeLib/Display.cpp index 31098f0..e86ec1e 100644 --- a/libraries/SondeLib/Display.cpp +++ b/libraries/SondeLib/Display.cpp @@ -1560,24 +1560,20 @@ void Display::drawGPS(DispEntry *de) { void Display::drawBatt(DispEntry *de) { float val; char buf[30]; - if(!axp192_found && sonde.fingerprint != 31) return; - if (!axp192_found && sonde.fingerprint == 31) - { - xSemaphoreTake(axpSemaphore, portMAX_DELAY); + if (!axp192_found) { + if (sonde.config.batt_adc<0) return; switch (de->extra[0]) { case 'V': - val = (float)(analogRead(35)) / 4095 * 2 * 3.3 * 1.1; + val = (float)(analogRead(sonde.config.batt_adc)) / 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]) { case 'S': diff --git a/libraries/SondeLib/Sonde.cpp b/libraries/SondeLib/Sonde.cpp index 516c2a7..eefed49 100644 --- a/libraries/SondeLib/Sonde.cpp +++ b/libraries/SondeLib/Sonde.cpp @@ -89,6 +89,7 @@ void Sonde::defaultConfig() { // Seems like on startup, GPIO4 is 1 on v1 boards, 0 on v2.1 boards? config.gps_rxd = -1; config.gps_txd = -1; + config.batt_adc = -1; config.sx1278_ss = SS; // default SS pin, on all TTGOs config.sx1278_miso = MISO; config.sx1278_mosi = MOSI; @@ -202,9 +203,11 @@ void Sonde::defaultConfig() { } } } else { + // Likely a TTGO V2.1_1.6 config.button_pin = 2 + 128; // GPIO2 / T2 config.button2_pin = 14 + 128; // GPIO14 / T6 config.led_pout = 25; + config.batt_adc = 35; } } // @@ -307,6 +310,8 @@ void Sonde::setConfig(const char *cfg) { config.gps_rxd = atoi(val); } else if(strcmp(cfg,"gps_txd")==0) { config.gps_txd = atoi(val); + } else if(strcmp(cfg,"batt_adc")==0) { + config.batt_adc = atoi(val); } else if(strcmp(cfg,"sx1278_ss")==0) { config.sx1278_ss = atoi(val); } else if(strcmp(cfg,"sx1278_miso")==0) { diff --git a/libraries/SondeLib/Sonde.h b/libraries/SondeLib/Sonde.h index a578dc1..097a5cb 100644 --- a/libraries/SondeLib/Sonde.h +++ b/libraries/SondeLib/Sonde.h @@ -216,6 +216,7 @@ typedef struct st_rdzconfig { int tft_spifreq; // SPI transfer speed (default 40M is out of spec for some TFT) int gps_rxd; // GPS module RXD pin. We expect 9600 baud NMEA data. int gps_txd; // GPS module TXD pin + int batt_adc; // Pin for ADC battery measurement (GPIO35 on TTGO V2.1_1.6) int sx1278_ss; // SPI slave select for sx1278 int sx1278_miso; // SPI MISO for sx1278 int sx1278_mosi; // SPI MOSI for sx1278
OptionValue