From c44988ef6e34fabb98c58624d144019320a4a8ea Mon Sep 17 00:00:00 2001 From: oh3bsg Date: Mon, 13 Feb 2023 18:27:07 +0200 Subject: [PATCH] display removed --- RX_FSK/RX_FSK.ino | 259 ++++++++++++++++++----------------- RX_FSK/data/index.html | 5 + RX_FSK/data/networks.txt | 4 +- RX_FSK/data/qrg.txt | 16 +-- RX_FSK/data/spectrum.html | 129 +++++++++++++++++ RX_FSK/src/Display.cpp | 2 + RX_FSK/src/Display.h | 4 +- RX_FSK/src/Scanner.cpp | 22 +-- RX_FSK/src/ShFreqImport.cpp | 2 +- RX_FSK/src/Sonde.cpp | 37 ++--- RX_FSK/src/TFT22_ILI9225.cpp | 4 +- RX_FSK/src/TFT22_ILI9225.h | 3 +- RX_FSK/src/geteph.cpp | 20 +-- RX_FSK/src/gfxfont.h | 2 + RX_FSK/src/headless.c | 20 +++ RX_FSK/src/headless.h | 19 +++ platformio.ini | 22 +++ 17 files changed, 390 insertions(+), 180 deletions(-) create mode 100644 RX_FSK/data/spectrum.html create mode 100644 RX_FSK/src/headless.c create mode 100644 RX_FSK/src/headless.h diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index f061b08..7d1794a 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -16,7 +16,8 @@ #include "src/SX1278FSK.h" #include "src/Sonde.h" -#include "src/Display.h" +//#include "src/Display.h" +#include "src\headless.h" #include "src/Scanner.h" #include "src/geteph.h" #include "src/rs92gps.h" @@ -82,6 +83,8 @@ const char *dfmSubtypeStrSH[16] = { NULL, NULL, NULL, NULL, NULL, NULL, #define APRS_MOBILE_STATION_UPDATE_TIME (20*1000) unsigned long time_last_aprs_update = 0; +#define EARTH_RADIUS (6371000.0F) + #if FEATURE_SONDEHUB #define SONDEHUB_STATION_UPDATE_TIME (60*60*1000) // 60 min #define SONDEHUB_MOBILE_STATION_UPDATE_TIME (30*1000) // 30 sec @@ -102,7 +105,6 @@ enum { SH_LOC_OFF, SH_LOC_FIXED, SH_LOC_CHASE, SH_LOC_AUTO }; #define MIN_LOC_AUTO_DIST 200 /* meter */ #define SH_LOC_AUTO_IS_CHASE ( gpsPos.valid && ( (isnan(sonde.config.rxlat) || isnan(sonde.config.rxlon) ) || \ calcLatLonDist( gpsPos.lat, gpsPos.lon, sonde.config.rxlat, sonde.config.rxlon ) > MIN_LOC_AUTO_DIST ) ) -extern float calcLatLonDist(float lat1, float lon1, float lat2, float lon2); // KISS over TCP for communicating with APRSdroid WiFiServer tncserver(14580); @@ -147,6 +149,15 @@ void WiFiEvent(WiFiEvent_t event); char buffer[85]; MicroNMEA nmea(buffer, sizeof(buffer)); +//float calcLatLonDist(float lat1, float lon1, float lat2, float lon2); + +float calcLatLonDist(float lat1, float lon1, float lat2, float lon2) { + float x = radians(lon1-lon2) * cos( radians((lat1+lat2)/2) ); + float y = radians(lat2-lat1); + float d = sqrt(x*x+y*y)*EARTH_RADIUS; + return d; +} + // Read line from file, independent of line termination (LF or CR LF) String readLine(Stream &stream) { String s = stream.readStringUntil('\n'); @@ -715,10 +726,10 @@ const char *createConfigForm() { strcat(ptr, "
"); strcat(ptr, ""); strcat(ptr, " + + + + diff --git a/RX_FSK/src/Display.cpp b/RX_FSK/src/Display.cpp index 706e8f0..d1f38ac 100644 --- a/RX_FSK/src/Display.cpp +++ b/RX_FSK/src/Display.cpp @@ -1,3 +1,4 @@ +#if 0 #include "../features.h" #include #include @@ -1780,3 +1781,4 @@ void Display::updateDisplay() { } Display disp = Display(); +#endif // 0 \ No newline at end of file diff --git a/RX_FSK/src/Display.h b/RX_FSK/src/Display.h index 5178621..d6d7aa3 100644 --- a/RX_FSK/src/Display.h +++ b/RX_FSK/src/Display.h @@ -1,3 +1,4 @@ +#if 0 #ifndef Display_h #define Display_h @@ -199,4 +200,5 @@ public: extern Display disp; -#endif +#endif +#endif // 0 diff --git a/RX_FSK/src/Scanner.cpp b/RX_FSK/src/Scanner.cpp index 64039f9..7ec01a2 100644 --- a/RX_FSK/src/Scanner.cpp +++ b/RX_FSK/src/Scanner.cpp @@ -1,10 +1,10 @@ #include "Scanner.h" -#include +//#include #include "SX1278FSK.h" #include "Sonde.h" -#include "Display.h" +//#include "Display.h" double STARTF; @@ -80,19 +80,19 @@ void Scanner::plotResult() yofs = 2; if (sonde.config.marker != 0) { itoa((sonde.config.startfreq), buf, 10); - disp.rdis->drawString(0, 1, buf); - disp.rdis->drawString(scanconfig.PLOT_W/2-10, 1, "MHz"); + //disp.rdis->drawString(0, 1, buf); + //disp.rdis->drawString(scanconfig.PLOT_W/2-10, 1, "MHz"); itoa((sonde.config.startfreq + 6), buf, 10); - disp.rdis->drawString(scanconfig.PLOT_W-15, 1, buf); + //disp.rdis->drawString(scanconfig.PLOT_W-15, 1, buf); } } else { if (sonde.config.marker != 0) { itoa((sonde.config.startfreq), buf, 10); - disp.rdis->drawString(0, 1, buf); - disp.rdis->drawString(7, 1, "MHz"); + //disp.rdis->drawString(0, 1, buf); + //disp.rdis->drawString(7, 1, "MHz"); itoa((sonde.config.startfreq + 6), buf, 10); - disp.rdis->drawString(13, 1, buf); + //disp.rdis->drawString(13, 1, buf); } } uint8_t row[scanconfig.PLOT_H8*8]; @@ -108,15 +108,15 @@ void Scanner::plotResult() // don't overwrite MHz marker text if(i<3*8 || (i>=7*8&&i<10*8) || i>=13*8) continue; } - disp.rdis->drawTile(i/8, y+yofs, 1, row+8*y); + //disp.rdis->drawTile(i/8, y+yofs, 1, row+8*y); } } if(ISTFT) { // large TFT sprintf(buf, "Peak: %03.3f MHz", peakf*0.000001); - disp.rdis->drawString(0, (yofs+scanconfig.PLOT_H8+1)*8, buf); + //disp.rdis->drawString(0, (yofs+scanconfig.PLOT_H8+1)*8, buf); } else { sprintf(buf, "Peak: %03.3fMHz", peakf*0.000001); - disp.rdis->drawString(0, 7, buf); + //disp.rdis->drawString(0, 7, buf); } } diff --git a/RX_FSK/src/ShFreqImport.cpp b/RX_FSK/src/ShFreqImport.cpp index 3e5983b..774fc98 100644 --- a/RX_FSK/src/ShFreqImport.cpp +++ b/RX_FSK/src/ShFreqImport.cpp @@ -7,6 +7,7 @@ #include "ShFreqImport.h" #include "Sonde.h" +//#include "headless.h" static int ppos; static int quotes; @@ -25,7 +26,6 @@ static int valuepos; static int importState; static float homelat, homelon; - // Map SondeHub type string to Stype. -1 for not supported types. int ShFreqImport::stringToStype(const char *type) { if(type[2]=='4') return STYPE_RS41; diff --git a/RX_FSK/src/Sonde.cpp b/RX_FSK/src/Sonde.cpp index 832d072..5832c20 100644 --- a/RX_FSK/src/Sonde.cpp +++ b/RX_FSK/src/Sonde.cpp @@ -1,5 +1,5 @@ -#include -#include +//#include +//#include #include "Sonde.h" #include "RS41.h" @@ -8,7 +8,7 @@ #include "M10M20.h" #include "MP3H.h" #include "SX1278FSK.h" -#include "Display.h" +//#include "Display.h" #include uint8_t debug = 255-8-16; @@ -106,7 +106,7 @@ void Sonde::defaultConfig() { config.button2_axp = 0; config.norx_timeout = 20; config.screenfile = 1; - config.tft_spifreq = SPI_DEFAULT_FREQ; + //config.tft_spifreq = SPI_DEFAULT_FREQ; if(initlevels[16]==0) { config.oled_sda = 4; config.oled_scl = 15; @@ -507,11 +507,12 @@ void Sonde::receive() { int event = getKeyPressEvent(); if (!event) event = timeoutEvent(si); - int action = (event==EVT_NONE) ? ACT_NONE : disp.layout->actions[event]; + //int action = (event==EVT_NONE) ? ACT_NONE : disp.layout->actions[event]; //if(action!=ACT_NONE) { Serial.printf("event %x: action is %x\n", event, action); } // 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 0 if(action == ACT_DISPLAY_SCANNER || action == ACT_NEXTSONDE || action==ACT_PREVSONDE || (action>64&&action<128) ) { // handled here... if(action==ACT_DISPLAY_SCANNER) { @@ -529,8 +530,9 @@ void Sonde::receive() { rxtask.activate = ACT_SONDE(rxtask.currentSonde); } } - Serial.printf("Sonde:receive(): result %d (%s), event %02x => action %02x\n", res, (res<=3)?RXstr[res]:"?", event, action); - res = (action<<8) | (res&0xff); +#endif // 0 + //Serial.printf("Sonde:receive(): result %d (%s), event %02x => action %02x\n", res, (res<=3)?RXstr[res]:"?", event, action); + //res = (action<<8) | (res&0xff); // let waitRXcomplete resume... rxtask.receiveResult = res; } @@ -548,7 +550,7 @@ rxloop: if( rxtask.receiveResult == RX_UPDATERSSI ) { rxtask.receiveResult = 0xFFFF; Serial.printf("RSSI update: %d/2\n", sonde.si()->rssi); - disp.updateDisplayRSSI(); + //disp.updateDisplayRSSI(); goto rxloop; } @@ -594,6 +596,7 @@ uint8_t Sonde::timeoutEvent(SondeInfo *si) { now, si->rxStart, disp.layout->timeouts[1], now, si->norxStart, disp.layout->timeouts[2], si->lastState); #endif +#if 0 if(disp.layout->timeouts[0]>=0 && now - si->viewStart >= disp.layout->timeouts[0]) { Serial.println("Sonde::timeoutEvent: View"); return EVT_VIEWTO; @@ -606,6 +609,7 @@ uint8_t Sonde::timeoutEvent(SondeInfo *si) { Serial.println("Sonde::timeoutEvent: NORX"); return EVT_NORXTO; } +#endif // 0 return 0; } @@ -631,7 +635,7 @@ uint8_t Sonde::updateState(uint8_t event) { } else if(event==ACT_DISPLAY_NEXT) { int i; for(i=0; config.display[i]!=-1; i++) { - if(config.display[i] == disp.layoutIdx) break; + //if(config.display[i] == disp.layoutIdx) break; } if(config.display[i]==-1 || config.display[i+1]==-1) { //unknown index, or end of list => loop to start @@ -641,13 +645,13 @@ uint8_t Sonde::updateState(uint8_t event) { } } if(n>=0 && n=disp.nLayouts) { - Serial.println("WARNNG: next layout out of range"); - n = config.display[1]; - } + //if(n>=disp.nLayouts) { + // Serial.println("WARNNG: next layout out of range"); + // n = config.display[1]; + //} Serial.printf("Setting display mode %d\n", n); - disp.setLayout(n); - sonde.clearDisplay(); + //disp.setLayout(n); + //sonde.clearDisplay(); return 0xFF; } @@ -679,6 +683,7 @@ void Sonde::clearAllData(SondeInfo *si) { si->d.temperature = si->d.tempRHSensor = si->d.relativeHumidity = si->d.pressure = si->d.batteryVoltage = NAN; } +#if 0 void Sonde::updateDisplayPos() { disp.updateDisplayPos(); } @@ -715,7 +720,7 @@ void Sonde::updateDisplay() void Sonde::clearDisplay() { disp.rdis->clear(); } - +#endif // 0 SondeType Sonde::realType(SondeInfo *si) { if(TYPE_IS_METEO(si->type) && si->d.subtype>0 ) { return si->d.subtype==1 ? STYPE_M10:STYPE_M20; } else return si->type; diff --git a/RX_FSK/src/TFT22_ILI9225.cpp b/RX_FSK/src/TFT22_ILI9225.cpp index 45bc551..f196c22 100644 --- a/RX_FSK/src/TFT22_ILI9225.cpp +++ b/RX_FSK/src/TFT22_ILI9225.cpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0 // original source: https://github.com/Nkawu/TFT22_ILI9225 - +#if 0 #include "TFT22_ILI9225.h" @@ -1416,4 +1416,4 @@ void TFT22_ILI9225::getGFXTextExtent(STRING str, int16_t x, int16_t y, int16_t * } if(*w>0) (*w)--; } - +#endif // 0 diff --git a/RX_FSK/src/TFT22_ILI9225.h b/RX_FSK/src/TFT22_ILI9225.h index ce4acd3..e07aa2f 100644 --- a/RX_FSK/src/TFT22_ILI9225.h +++ b/RX_FSK/src/TFT22_ILI9225.h @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0 // original source: https://github.com/Nkawu/TFT22_ILI9225 - +#if 0 #ifndef TFT22_ILI9225_h #define TFT22_ILI9225_h @@ -469,3 +469,4 @@ class TFT22_ILI9225 { }; #endif +#endif // 0 \ No newline at end of file diff --git a/RX_FSK/src/geteph.cpp b/RX_FSK/src/geteph.cpp index c6f1d86..6e0a7c2 100644 --- a/RX_FSK/src/geteph.cpp +++ b/RX_FSK/src/geteph.cpp @@ -5,7 +5,7 @@ #include #include #include -#include "Display.h" +//#include "Display.h" #include "Sonde.h" extern WiFiClient client; @@ -89,16 +89,16 @@ void geteph() { if(!buf) { Serial.println("Invalid FTP host config"); return; } *buf = 0; buf++; - uint8_t dispw, disph, dispxs, dispys; - disp.rdis->getDispSize(&disph, &dispw, &dispxs, &dispys); - disp.rdis->clear(); - disp.rdis->setFont(FONT_SMALL); - disp.rdis->drawString(0, 0, host); + //uint8_t dispw, disph, dispxs, dispys; + //disp.rdis->getDispSize(&disph, &dispw, &dispxs, &dispys); + //disp.rdis->clear(); + //disp.rdis->setFont(FONT_SMALL); + //disp.rdis->drawString(0, 0, host); // fetch rinex from server char *ptr = buf + strlen(buf); snprintf(ptr, 128, "%04d/%03d/brdc%03d0.%02dn.gz", year, day, day, year-2000); Serial.println("running geteph\n"); - disp.rdis->drawString(0, 1*dispys, ptr+9); + //disp.rdis->drawString(0, 1*dispys, ptr+9); if(!client.connect(host, 21)) { Serial.printf("FTP connection to %s failed\n", host); @@ -156,9 +156,9 @@ void geteph() { fh.close(); snprintf(buf, 16, "Fetched %d B ",len); buf[16]=0; - disp.rdis->drawString(0,2*dispys,buf); + //disp.rdis->drawString(0,2*dispys,buf); - disp.rdis->drawString(0,4*dispys,"Decompressing..."); + //disp.rdis->drawString(0,4*dispys,"Decompressing..."); // decompression tinfl_decompressor *decomp = (tinfl_decompressor *)malloc(sizeof(tinfl_decompressor)); tinfl_init(decomp); @@ -226,7 +226,7 @@ void geteph() { status.close(); snprintf(buf, 16, "Done: %d B ",total); buf[16]=0; - disp.rdis->drawString(0,5*dispys,buf); + //disp.rdis->drawString(0,5*dispys,buf); ephstate = EPH_GOOD; delay(1000); diff --git a/RX_FSK/src/gfxfont.h b/RX_FSK/src/gfxfont.h index f99a757..2397185 100644 --- a/RX_FSK/src/gfxfont.h +++ b/RX_FSK/src/gfxfont.h @@ -6,6 +6,7 @@ // To use a font in your Arduino sketch, #include the corresponding .h // file and pass address of GFXfont struct to setFont(). +#if 0 #ifndef _GFFFONT_H_ #define _GFFFONT_H_ @@ -24,3 +25,4 @@ typedef struct { // Data stored for FONT AS A WHOLE: } GFXfont; #endif // _GFFFONT_H_ +#endif // 0 \ No newline at end of file diff --git a/RX_FSK/src/headless.c b/RX_FSK/src/headless.c new file mode 100644 index 0000000..07b0bb2 --- /dev/null +++ b/RX_FSK/src/headless.c @@ -0,0 +1,20 @@ +#include +#include +#include "headless.h" + +//#define EARTH_RADIUS (6371000.0F) +#ifndef PI +#define PI (3.1415926535897932384626433832795) +#endif +// defined by Arduino.h #define radians(x) ( (x)*180.0F/PI ) + +struct GpsPos gpsPos; + +/* +float calcLatLonDist(float lat1, float lon1, float lat2, float lon2) { + float x = radians(lon1-lon2) * cos( radians((lat1+lat2)/2) ); + float y = radians(lat2-lat1); + float d = sqrt(x*x+y*y)*EARTH_RADIUS; + return d; +} +*/ \ No newline at end of file diff --git a/RX_FSK/src/headless.h b/RX_FSK/src/headless.h new file mode 100644 index 0000000..77498b5 --- /dev/null +++ b/RX_FSK/src/headless.h @@ -0,0 +1,19 @@ +#ifndef HEADLESS_H +#define HEADLESS_H + +struct GpsPos { + double lat; + double lon; + int alt; + int course; + float speed; + int sat; + int accuracy; + int hdop; + int valid; +}; +extern struct GpsPos gpsPos; + +//float calcLatLonDist(float lat1, float lon1, float lat2, float lon2); + +#endif // HEADLESS_H \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index 19aa9d9..40f92ff 100644 --- a/platformio.ini +++ b/platformio.ini @@ -45,3 +45,25 @@ lib_ignore = Time ; extra_scripts = post:scripts/makefontpartition.py ;board_build.partitions = partition-fonts.csv + +[env:ttgo-lora32-headless] +platform = https://github.com/platformio/platform-espressif32.git +board = ttgo-lora32-v1 +framework = arduino +monitor_speed = 115200 +lib_deps = + ${extra.lib_deps_builtin} + ${extra.lib_deps_external} + paulstoffregen/Time@^1.6.0 +lib_ignore = Time + +; Add / remove the following two lines for separate fonts partition in flash +; after changes: +; - pio run --target=upload (uploads partition table) +; - pio run --target=uploadfs (uploads file system matching the new partition table) +; if enable also do: +; - pio run --target=uploadfonts (uploads fonts.bin created during the first pio run) +; Then everything should be "back to normal" +; +extra_scripts = post:scripts/makefontpartition.py +;board_build.partitions = partition-fonts.csv \ No newline at end of file