From e84a5872b57f591f16d80b510dd9568c4e41f0c3 Mon Sep 17 00:00:00 2001 From: "Hansi, dl9rdz" Date: Wed, 22 May 2019 22:13:14 +0200 Subject: [PATCH] new configurable display code, finetuning --- libraries/SondeLib/Display.cpp | 51 +++++++++++++++++++++++++++++++++- libraries/SondeLib/Display.h | 2 ++ libraries/SondeLib/Sonde.cpp | 36 ++---------------------- 3 files changed, 55 insertions(+), 34 deletions(-) diff --git a/libraries/SondeLib/Display.cpp b/libraries/SondeLib/Display.cpp index 4893dfc..5403df5 100644 --- a/libraries/SondeLib/Display.cpp +++ b/libraries/SondeLib/Display.cpp @@ -8,6 +8,24 @@ extern Sonde sonde; extern U8X8_SSD1306_128X64_NONAME_SW_I2C *u8x8; +const char *sondeTypeStr[5] = { "DFM6", "DFM9", "RS41" }; + +byte myIP_tiles[8*11]; +static uint8_t ap_tile[8]={0x00,0x04,0x22,0x92, 0x92, 0x22, 0x04, 0x00}; + +static const uint8_t font[10][5]={ + 0x3E, 0x51, 0x49, 0x45, 0x3E, // 0 + 0x00, 0x42, 0x7F, 0x40, 0x00, // 1 + 0x42, 0x61, 0x51, 0x49, 0x46, // 2 + 0x21, 0x41, 0x45, 0x4B, 0x31, // 3 + 0x18, 0x14, 0x12, 0x7F, 0x10, // 4 + 0x27, 0x45, 0x45, 0x45, 0x39, // 5 + 0x3C, 0x4A, 0x49, 0x49, 0x30, // 6 + 0x01, 0x01, 0x79, 0x05, 0x03, // 7 + 0x36, 0x49, 0x49, 0x49, 0x36, // 8 + 0x06, 0x49, 0x39, 0x29, 0x1E }; // 9; .=0x40 + + static unsigned char kmh_tiles[] U8X8_PROGMEM = { 0x1F, 0x04, 0x0A, 0x11, 0x00, 0x1F, 0x02, 0x04, 0x42, 0x3F, 0x10, 0x08, 0xFC, 0x22, 0x20, 0xF8 }; @@ -39,7 +57,7 @@ DispEntry searchLayout[] = { {0, 8, FONT_LARGE, disp.drawType}, {3, 0, FONT_LARGE, disp.drawFreq, " MHz"}, {5, 0, FONT_LARGE, disp.drawSite}, - {7, 8, 0, disp.drawIP}, + {7, 5, 0, disp.drawIP}, {-1, -1, -1, NULL}, }; DispEntry legacyLayout[] = { @@ -185,6 +203,8 @@ void Display::drawAFC(DispEntry *de) { u8x8->drawString(de->x, de->y, buf+strlen(buf)-8); } void Display::drawIP(DispEntry *de) { + u8x8->drawTile(de->x, de->y, 11, myIP_tiles); + } void Display::drawSite(DispEntry *de) { SETFONT(de->fmt); @@ -199,6 +219,30 @@ void Display::drawText(DispEntry *de) { u8x8->drawString(de->x, de->y, de->extra); } + +void Display::clearIP() { + memset(myIP_tiles, 0, 11*8); +} + +void Display::setIP(const char *ip, bool AP) { + memset(myIP_tiles, 0, 11*8); + int len = strlen(ip); + int pix = (len-3)*6+6; + int tp = 80-pix+8; + if(AP) memcpy(myIP_tiles+(tp<16?0:8), ap_tile, 8); + for(int i=0; ifunc != NULL; di++) { if(di->func != disp.drawLat && di->func != disp.drawLon) continue; @@ -237,6 +281,11 @@ void Display::updateDisplayRXConfig() { } } void Display::updateDisplayIP() { + for(DispEntry *di=layout; di->func != NULL; di++) { + if(di->func != disp.drawIP) continue; + Serial.printf("updateDisplayIP: %d %d\n",di->x, di->y); + di->func(di); + } } void Display::updateDisplay() { diff --git a/libraries/SondeLib/Display.h b/libraries/SondeLib/Display.h index 5c76daa..6ad7b67 100644 --- a/libraries/SondeLib/Display.h +++ b/libraries/SondeLib/Display.h @@ -38,6 +38,8 @@ public: static void drawTelemetry(DispEntry *de); static void drawGPSdist(DispEntry *de); static void drawText(DispEntry *de); + void clearIP(); + void setIP(const char *ip, bool AP); void updateDisplayPos(); void updateDisplayPos2(); void updateDisplayID(); diff --git a/libraries/SondeLib/Sonde.cpp b/libraries/SondeLib/Sonde.cpp index 48e2bfd..a324364 100644 --- a/libraries/SondeLib/Sonde.cpp +++ b/libraries/SondeLib/Sonde.cpp @@ -11,22 +11,6 @@ extern U8X8_SSD1306_128X64_NONAME_SW_I2C *u8x8; extern SX1278FSK sx1278; //SondeInfo si = { STYPE_RS41, 403.450, "P1234567", true, 48.1234, 14.9876, 543, 3.97, -0.5, true, 120 }; -const char *sondeTypeStr[5] = { "DFM6", "DFM9", "RS41" }; - -byte myIP_tiles[8*11]; -static uint8_t ap_tile[8]={0x00,0x04,0x22,0x92, 0x92, 0x22, 0x04, 0x00}; - -static const uint8_t font[10][5]={ - 0x3E, 0x51, 0x49, 0x45, 0x3E, // 0 - 0x00, 0x42, 0x7F, 0x40, 0x00, // 1 - 0x42, 0x61, 0x51, 0x49, 0x46, // 2 - 0x21, 0x41, 0x45, 0x4B, 0x31, // 3 - 0x18, 0x14, 0x12, 0x7F, 0x10, // 4 - 0x27, 0x45, 0x45, 0x45, 0x39, // 5 - 0x3C, 0x4A, 0x49, 0x49, 0x30, // 6 - 0x01, 0x01, 0x79, 0x05, 0x03, // 7 - 0x36, 0x49, 0x49, 0x49, 0x36, // 8 - 0x06, 0x49, 0x39, 0x29, 0x1E }; // 9; .=0x40 Sonde::Sonde() { config.button_pin = 0; @@ -165,25 +149,11 @@ void Sonde::setConfig(const char *cfg) { } void Sonde::clearIP() { - memset(myIP_tiles, 0, 11*8); + disp.clearIP(); } void Sonde::setIP(const char *ip, bool AP) { - memset(myIP_tiles, 0, 11*8); - int len = strlen(ip); - int pix = (len-3)*6+6; - int tp = 80-pix+8; - if(AP) memcpy(myIP_tiles+(tp<16?0:8), ap_tile, 8); - for(int i=0; idrawTile(5, 7, 11, myIP_tiles); + disp.updateDisplayIP(); } // Probing RS41