From ad244bc771106874a3a9a8fd62eae909efba9532 Mon Sep 17 00:00:00 2001 From: "Hansi, dl9rdz" Date: Wed, 30 Dec 2020 13:52:58 +0100 Subject: [PATCH] minor improvements (display, m10) --- RX_FSK/RX_FSK.ino | 4 ++-- RX_FSK/data/config.txt | 7 ++++--- RX_FSK/data/screens2.txt | 14 +++++++------- RX_FSK/version.h | 2 +- libraries/SondeLib/Display.cpp | 23 +++++++++++++++-------- libraries/SondeLib/M10M20.cpp | 2 ++ libraries/SondeLib/Sonde.cpp | 22 +++++++++++++++------- 7 files changed, 46 insertions(+), 28 deletions(-) diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index 60c2f55..702c555 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -1497,8 +1497,8 @@ void setup() setupConfigData(); // configuration must be read first due to OLED ports!!! // NOT TTGO v1 (fingerprint 64) or Heltec v1/v2 board (fingerprint 4) - // and NOT TTGO Lora32 v2.1_1.6 (fingerprint 31) - if ( (sonde.fingerprint != 31) && ((sonde.fingerprint & 16) == 16) ) { + // and NOT TTGO Lora32 v2.1_1.6 (fingerprint 31/63) + if ( ( (sonde.fingerprint&(64+31)) != 31) && ((sonde.fingerprint & 16) == 16) ) { // FOr T-Beam 1.0 for (int i = 0; i < 10; i++) { // try multiple times Wire.begin(21, 22); diff --git a/RX_FSK/data/config.txt b/RX_FSK/data/config.txt index 1caa7c0..1c212aa 100644 --- a/RX_FSK/data/config.txt +++ b/RX_FSK/data/config.txt @@ -27,8 +27,8 @@ tft_orient=1 #gps_rxd=-1 gps_txd=-1 -# Show AFC value (for RS41 only, maybe also DFM, but useful for RS92 or M10) -# showafc=1 +# Show AFC value (for RS41 and M10/M20, maybe also DFM, but not useful for RS92) +showafc=1 # Frequency correction, in Hz # freqofs=0 #-------------------------------# @@ -42,7 +42,8 @@ wifi=3 kisstnc.active = 1 # which screens file to use (0: screens.txt, i>0: screens${i}.txt -screenfile=0 +# 0: old version; 1: for OLED, 2: for TFT; 3: for TFT (portrait mode) +# screenfile=2 # display configuration. List of "displays" # first entry: "Scanner" display # second entry: default "Receiver" display diff --git a/RX_FSK/data/screens2.txt b/RX_FSK/data/screens2.txt index 0841679..735720f 100644 --- a/RX_FSK/data/screens2.txt +++ b/RX_FSK/data/screens2.txt @@ -107,7 +107,7 @@ key2action=#,#,#,# timeaction=#,D,+ fonts=5,6 0,0=XScan -0,8,-3=S#: +0,5,-3=S#: 0,9,5.5=T 3,0=F MHz 5,0,16=S @@ -120,11 +120,11 @@ key1action=+,0,F,W key2action=>,#,#,# timeaction=#,#,0 color=FFD700 -0,0=Is +0,0,10.5=Is color=0000FF 0,11,-5.5=f -1,1,6=c -1,12.5,-4=t +1,0,4=t +1,10.5,-6=c color=00ff00 2,0,7=L 4,0,7=O @@ -209,12 +209,12 @@ color=e0e0e0 0.5,0=XScanning... #Row 2 3,0=xIndex -4,0=S/ +4,0,8=S/ 3,9=xSite 4,9=S #Row 3 6,0=xType -7,0=T +7,0,6=T 6,9=xFrequency 7,9=F #Row 4 @@ -362,7 +362,7 @@ color=639AFF fonts=0,5 color=285454 11.5,0=xIP ADDRESS: -10.9,22,-15=N +10.9,7,-15=N #Footer color=FF0000 12.7,18=bVV diff --git a/RX_FSK/version.h b/RX_FSK/version.h index b0f0765..31d7487 100644 --- a/RX_FSK/version.h +++ b/RX_FSK/version.h @@ -1,4 +1,4 @@ const char *version_name = "rdzTTGOsonde"; const char *version_id = "devel20201230"; const int SPIFFS_MAJOR=2; -const int SPIFFS_MINOR=7; +const int SPIFFS_MINOR=8; diff --git a/libraries/SondeLib/Display.cpp b/libraries/SondeLib/Display.cpp index 8322893..c8524f4 100644 --- a/libraries/SondeLib/Display.cpp +++ b/libraries/SondeLib/Display.cpp @@ -269,7 +269,7 @@ void U8x8Display::welcome() { drawString(8 - strlen(version_name) / 2, 0, version_name); drawString(8 - strlen(version_id) / 2, 2, version_id); setFont(FONT_SMALL); - drawString(0, 4, "RS41/92,DFM,M10"); + drawString(0, 4, "RS41/92,DFM,Mx0"); drawString(0, 6, "by Hansi, DL9RDZ"); } @@ -386,6 +386,8 @@ void ILI9225Display::getDispSize(uint8_t *height, uint8_t *width, uint8_t *lines } } +// Note: alignright means that there is a box from x to x+(-width), with text right-justified +// x is the *left* corner! not the right... void ILI9225Display::drawString(uint8_t x, uint8_t y, const char *s, int16_t width, uint16_t fg, uint16_t bg) { int16_t w,h; boolean alignright=false; @@ -402,9 +404,9 @@ void ILI9225Display::drawString(uint8_t x, uint8_t y, const char *s, int16_t wid w = tft->getTextWidth(s); if( width==WIDTH_AUTO ) { width = w; } if( width > w ) { - tft->fillRectangle(x - width, y, x - w, y + h - 1, bg); + tft->fillRectangle(x, y, x + width - w, y + h - 1, bg); } - tft->drawText(x - w, y, s, fg); + tft->drawText(x + width - w, y, s, fg); } else { int curx = tft->drawText(x, y, s, fg); if( width==WIDTH_AUTO ) { return; } @@ -419,9 +421,14 @@ void ILI9225Display::drawString(uint8_t x, uint8_t y, const char *s, int16_t wid tft->getGFXTextExtent(s, x, y + gfxoffsets[findex-3].yofs, &w, &h); if(width==WIDTH_AUTO) { width=w; } if(alignright) { - if(w > width) width = w; - x -= width; - DebugPrintf(DEBUG_DISPLAY, "Reducing x by width %d, its now %d\n", width, x); + if(w > width) { + // fast drawBitmap does bad things if not within viewport + // Maybe better truncate on the right? (TODO) + x = x - w + width; if(x<0) x=0; + width = w; + } + //x -= width; + //DebugPrintf(DEBUG_DISPLAY, "Reducing x by width %d, its now %d\n", width, x); } } @@ -496,10 +503,10 @@ void ILI9225Display::welcome() { setFont(5); int l=3*22; if(sonde.config.tft_orient&1) { - drawString(0, 1*22, "RS41/92,DFM,M10"); + drawString(0, 1*22, "RS41/92,DFM,M10/20"); } else { drawString(0, 1*22, "RS41,RS92,"); - drawString(0, 2*22, "DFM,M10"); + drawString(0, 2*22, "DFM,M10/20"); l+=22; } drawString(0, l, version_id); diff --git a/libraries/SondeLib/M10M20.cpp b/libraries/SondeLib/M10M20.cpp index 078e9ab..b6ddb40 100644 --- a/libraries/SondeLib/M10M20.cpp +++ b/libraries/SondeLib/M10M20.cpp @@ -387,11 +387,13 @@ void M10M20::processM10data(uint8_t dt) // 45 20 7x => M20 if(rxp==2 && dataptr[0]==0x45 && dataptr[1]==0x20) { isM20 = true; } if(isM20) { + memcpy(sonde.si()->typestr, "M20", 4); if(rxp>=M20_FRAMELEN) { rxsearching = true; haveNewFrame = decodeframeM20(dataptr); } } else { + memcpy(sonde.si()->typestr, "M10", 4); if(rxp>=M10_FRAMELEN) { rxsearching = true; haveNewFrame = decodeframeM10(dataptr); diff --git a/libraries/SondeLib/Sonde.cpp b/libraries/SondeLib/Sonde.cpp index 14734e9..f716cd5 100644 --- a/libraries/SondeLib/Sonde.cpp +++ b/libraries/SondeLib/Sonde.cpp @@ -84,6 +84,7 @@ void Sonde::defaultConfig() { config.tft_orient = 1; config.button2_axp = 0; config.norx_timeout = 20; + config.screenfile = 1; if(initlevels[16]==0) { config.oled_sda = 4; config.oled_scl = 15; @@ -124,6 +125,7 @@ void Sonde::defaultConfig() { config.tft_rs = 2; config.tft_cs = 0; config.spectrum = -1; // no spectrum for now on large display + config.screenfile = 2; } else { // OLED display, pins 21,22 ok... config.disptype = 0; @@ -144,6 +146,7 @@ void Sonde::defaultConfig() { config.tft_rs = 2; config.tft_cs = 0; config.spectrum = -1; // no spectrum for now on large display + config.screenfile = 2; } } } else { @@ -509,16 +512,21 @@ void Sonde::receive() { // If action is to move to a different sonde index, we do update things here, set activate // to force the sx1278 task to call sonde.setup(), and pass information about sonde to // main loop (display update...) - if(action == ACT_NEXTSONDE || action==ACT_PREVSONDE || (action>64&&action<128) ) { + if(action == ACT_DISPLAY_SCANNER || action == ACT_NEXTSONDE || action==ACT_PREVSONDE || (action>64&&action<128) ) { // handled here... - if(action==ACT_NEXTSONDE||action==ACT_PREVSONDE) - nextRxSonde(); - else - nextRxFreq( action-64 ); - action = ACT_SONDE(rxtask.currentSonde); + if(action==ACT_DISPLAY_SCANNER) { + // nothing to do here, be re-call setup() for M10/M20 for repeating AFC + } + else { + if(action==ACT_NEXTSONDE||action==ACT_PREVSONDE) + nextRxSonde(); + else + nextRxFreq( action-64 ); + action = ACT_SONDE(rxtask.currentSonde); + } if(rxtask.activate==-1) { // race condition here. maybe better use mutex. TODO - rxtask.activate = action; + rxtask.activate = ACT_SONDE(rxtask.currentSonde); } } res = (action<<8) | (res&0xff);