From 86982f6a913bfdcd1d0c6b8a3c698c3fd3a64c05 Mon Sep 17 00:00:00 2001 From: DL2MF Date: Mon, 22 Apr 2019 20:12:12 +0200 Subject: [PATCH] Fixing missing libs and minor changes, improving spectrum display info. --- RX_FSK/RX_FSK.ino | 36 +++++++++++++++++---------- RX_FSK/data/config.txt | 45 ++++++++++++++++++++++------------ RX_FSK/data/index.html | 2 +- RX_FSK/data/networks.txt | 10 +++----- RX_FSK/data/qrg.txt | 18 +++++++++----- libraries/SondeLib/DFM.cpp | 8 +++--- libraries/SondeLib/RS41.cpp | 18 ++++++++------ libraries/SondeLib/RS41.h | 2 +- libraries/SondeLib/Scanner.cpp | 9 ++++++- libraries/SondeLib/Sonde.cpp | 15 +++++++++--- libraries/SondeLib/Sonde.h | 3 +++ libraries/SondeLib/aprs.cpp | 45 +++++++++++++++++++++++++++++++--- libraries/SondeLib/aprs.h | 3 ++- 13 files changed, 152 insertions(+), 62 deletions(-) diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index 44a7bbd..557b8f6 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -106,7 +106,7 @@ void setupChannelList() { const char *createQRGForm() { char *ptr = message; strcpy(ptr,"
"); - for(int i=0; i<10; i++) { + for(int i=0; i=sonde.nSonde?2:sonde.sondeList[i].type); sprintf(ptr+strlen(ptr), "" "" @@ -286,8 +286,12 @@ struct st_configitems { int type; // 0: numeric; i>0 string of length i; -1: separator; -2: type selector void *data; }; -#define N_CONFIG 16 +#define N_CONFIG 20 struct st_configitems config_list[N_CONFIG] = { + {"ShowSpectrum (s)", 0, &sonde.config.spectrum}, + {"Startfreq (MHz)", 0, &sonde.config.startfreq}, + {"Bandwidth (kHz)", 0, &sonde.config.channelbw}, + {"---", -1, NULL}, {"Call", 8, sonde.config.call}, {"Passcode", 8, sonde.config.passcode}, {"---", -1, NULL}, @@ -491,7 +495,7 @@ void setup() u8x8->drawString(1, 1, "RDZ_TTGO_SONDE"); u8x8->drawString(2, 3, " V0.1e"); u8x8->drawString(1, 5, "Mods by DL2MF"); - delay(4000); + delay(3000); sonde.clearDisplay(); @@ -720,7 +724,6 @@ void WiFiEvent(WiFiEvent_t event){ } } - static char* _scan[2]={"/","\\"}; void loopWifiScan() { u8x8->setFont(u8x8_font_chroma48medium8_r); @@ -733,6 +736,7 @@ void loopWifiScan() { int line=0; int cnt=0; + int marker=0; char buf[5]; WiFi.disconnect(true); @@ -806,19 +810,26 @@ void loopWifiScan() { enterMode(ST_SPECTRUM); - for (int i = 0; i < sonde.config.spectrum; i++) { - //pinMode(i, OUTPUT); - //delay(500); - //digitalWrite(i, HIGH); + for (int i = 0; i < sonde.config.spectrum; i++) { scanner.scan(); scanner.plotResult(); + if (sonde.config.marker != 0) { + itoa((sonde.config.startfreq), buf, 10); + u8x8->drawString(0, 1, buf); + u8x8->drawString(7, 1, "MHz"); + itoa((sonde.config.startfreq + 6), buf, 10); + u8x8->drawString(13, 1, buf); + } + if (sonde.config.timer != 0) { itoa((sonde.config.spectrum - i), buf, 10); - u8x8->drawString(0, 1, buf); - u8x8->drawString(2, 1, "Sec."); - } - //digitalWrite(i, LOW); + if (sonde.config.marker != 0) { + marker = 1; + } + u8x8->drawString(0, 1+marker, buf); + u8x8->drawString(2, 1+marker, "Sec."); + } } delay(1000); @@ -843,7 +854,6 @@ void loopWifiScan() { enterMode(ST_SCANNER); } - void loop() { Serial.println("Running main loop"); switch(mainState) { diff --git a/RX_FSK/data/config.txt b/RX_FSK/data/config.txt index f7e0242..78ff4dd 100644 --- a/RX_FSK/data/config.txt +++ b/RX_FSK/data/config.txt @@ -1,4 +1,6 @@ -# Input button +#-------------------------------# +# Hardware depending settings +#-------------------------------# button_pin=0 # LED port led_pin=25 @@ -8,35 +10,48 @@ led_pin=25 oled_sda=21 oled_scl=22 oled_rst=16 - -noisefloor=-110 -call=DL2623 -passcode=14251 - -maxsonde=15 -debug=1 +#-------------------------------# +# General config settings +#-------------------------------# +maxsonde=20 +debug=0 wifi=0 wifiap=1 +#-------------------------------# +# Spectrum display settings +#-------------------------------# +startfreq=400 +channelbw=10 spectrum=10 timer=1 - +noisefloor=-110 +marker=1 +#-------------------------------# +# APRS settings +#-------------------------------# +call=N0CALL +passcode=12345 +#-------------------------------# # axudp for sending to aprsmap +#-------------------------------# # local use only, do not feed to public services # data not sanities / quality checked, outliers not filtered out axudp.active=1 -# axudp.host=82.211.8.199 -# axudp.port=40100 -axudp.host=euro.aprs2.net -axudp.port=14589 +axudp.host=192.168.42.20 +axudp.port=9002 axudp.symbol=/O axudp.highrate=1 axudp.idformat=0 - +#-------------------------------# # maybe some time in the future +#-------------------------------# # currently simply not implemented, no need to put anything here anyway tcp.active=0 tcp.host=radiosondy.info tcp.port=14590 tcp.symbol=/O tcp.highrate=20 -tcp.idformat=0 \ No newline at end of file +tcp.idformat=0 +#-------------------------------# +# EOF +#-------------------------------# \ No newline at end of file diff --git a/RX_FSK/data/index.html b/RX_FSK/data/index.html index 37a32f5..30dc0be 100644 --- a/RX_FSK/data/index.html +++ b/RX_FSK/data/index.html @@ -1,7 +1,7 @@ - ESP32 Web Server + AutoRX Sonde Server diff --git a/RX_FSK/data/networks.txt b/RX_FSK/data/networks.txt index 15d1e9b..352a350 100644 --- a/RX_FSK/data/networks.txt +++ b/RX_FSK/data/networks.txt @@ -1,6 +1,4 @@ -RDZsonde -RDZsonde -DinoGast -Schokolade -AndroidDD -dl9rdzhr +AUTORX +12345678 +SONDERX +radiosonde \ No newline at end of file diff --git a/RX_FSK/data/qrg.txt b/RX_FSK/data/qrg.txt index 5abaaa3..ed77a95 100644 --- a/RX_FSK/data/qrg.txt +++ b/RX_FSK/data/qrg.txt @@ -1,17 +1,23 @@ # Frequency in Mhz (format nnn.nnn) # Type (4=RS41, 6=DFM normal, DFM-06, 9=DFM inverted, DFM-09) # -404.500 4 - Meppen -405.700 4 + Bergen -405.900 4 + Bergen -405.100 4 - Meppen -405.300 4 - Essen +402.300 4 - Greifswald +402.500 4 - Schleswig 402.700 4 + HH-Sasel +403.000 4 - DeBilt +404.100 4 + Norderney +404.300 4 - Schleswig_2 +404.500 4 - Meppen +404.700 4 - Greifswald_2 +405.100 4 - Lindenberg +405.700 4 + Bergen +405.900 4 + Bergen_2 +405.100 4 + Meppen_2 +405.300 4 - Essen 403.330 9 - TrUebPl 403.450 9 - TrUebPl 403.470 9 - TrUebPl 403.850 9 - TrUebPl 403.870 9 - TrUebPl 403.890 9 - TrUebPl -439.275 4 - DB0CEL # end diff --git a/libraries/SondeLib/DFM.cpp b/libraries/SondeLib/DFM.cpp index 1d8828f..36cafb8 100644 --- a/libraries/SondeLib/DFM.cpp +++ b/libraries/SondeLib/DFM.cpp @@ -228,12 +228,12 @@ int DFM::decodeDAT(uint8_t *dat) break; case 4: { - float hei, vv; - hei = ((uint32_t)dat[0]<<24) + ((uint32_t)dat[1]<<16) + ((uint32_t)dat[2]<<8) + dat[3]; + float lat, vv; + lat = ((uint32_t)dat[0]<<24) + ((uint32_t)dat[1]<<16) + ((uint32_t)dat[2]<<8) + dat[3]; vv = (int16_t)( (dat[4]<<8) | dat[5] ); - Serial.print("GPS-height: "); Serial.print(hei*0.01); + Serial.print("GPS-height: "); Serial.print(lat*0.01); Serial.print(", vv: "); Serial.print(vv*0.01); - sonde.si()->hei = hei*0.01; + sonde.si()->lat = lat*0.01; sonde.si()->vs = vv*0.01; sonde.si()->validPos |= 0x0C; } diff --git a/libraries/SondeLib/RS41.cpp b/libraries/SondeLib/RS41.cpp index a3d1d72..29909ff 100644 --- a/libraries/SondeLib/RS41.cpp +++ b/libraries/SondeLib/RS41.cpp @@ -339,6 +339,7 @@ static void posrs41(const byte b[], uint32_t b_len, uint32_t p) long0)+vz*(double)sin((float)lat); dir = X2C_DIVL(atang2(vn, ve),1.7453292519943E-2); if (dir<0.0) dir = 360.0+dir; + sonde.si()->dir = dir; Serial.print(" "); sonde.si()->hs = sqrt((float)(vn*vn+ve*ve))*3.6f; Serial.print(sonde.si()->hs); @@ -350,16 +351,17 @@ static void posrs41(const byte b[], uint32_t b_len, uint32_t p) Serial.print("m/s "); Serial.print(getcard16(b, b_len, p+18UL)&255UL); Serial.print("Sats"); - sonde.si()->hei = heig; + sonde.si()->alt = heig; sonde.si()->validPos = true; } /* end posrs41() */ - -void RS41::decode41(byte *data, int maxlen) +// returns: 0: ok, -1: rs or crc error +int RS41::decode41(byte *data, int maxlen) { - char buf[128]; + char buf[128]; + int crcok = 0; int32_t corr = reedsolomon41(data, 560, 131); // try short frame first if(corr<0) { @@ -392,7 +394,8 @@ void RS41::decode41(byte *data, int maxlen) // check CRC if(!crcrs(data, 560, p, p+len)) { Serial.println("###CRC ERROR###"); - } else { + } else { + crcok = 1; switch(typ) { case 'y': // name { @@ -420,6 +423,7 @@ void RS41::decode41(byte *data, int maxlen) p += len; Serial.println(); } + return crcok ? 0 : -1; } void RS41::printRaw(uint8_t *data, int len) { @@ -472,8 +476,8 @@ int RS41::receiveFrame() { //printRaw(data, MAXLEN); for(int i=0; i #include +#include "Sonde.h" + extern U8X8_SSD1306_128X64_NONAME_SW_I2C *u8x8; #define CHANBW 10 #define PIXSAMPL (50/CHANBW) #define SMOOTH 3 -#define STARTF 401000000 +//#define STARTF 401000000 #define NCHAN ((int)(6000/CHANBW)) +double STARTF = (sonde.config.startfreq * 1000000); +//int CHANBW = (sonde.config.channelbw); +//int NCHAN = ((int)(6000/CHANBW)); +//int PIXSAMPL = (50/CHANBW); + int scanresult[NCHAN]; int scandisp[NCHAN/PIXSAMPL]; diff --git a/libraries/SondeLib/Sonde.cpp b/libraries/SondeLib/Sonde.cpp index 3cea2f1..75a0bd8 100644 --- a/libraries/SondeLib/Sonde.cpp +++ b/libraries/SondeLib/Sonde.cpp @@ -59,8 +59,11 @@ Sonde::Sonde() { config.debug=0; config.wifi=1; config.wifiap=1; + config.startfreq=400; + config.channelbw=10; config.spectrum=10; - config.timer=0; + config.timer=0; + config.marker=0; config.udpfeed.active = 1; config.udpfeed.type = 0; strcpy(config.udpfeed.host, "192.168.42.20"); @@ -110,11 +113,17 @@ void Sonde::setConfig(const char *cfg) { } else if(strcmp(cfg,"wifi")==0) { config.wifi = atoi(val); } else if(strcmp(cfg,"wifiap")==0) { - config.wifiap = atoi(val); + config.wifiap = atoi(val); + } else if(strcmp(cfg,"startfreq")==0) { + config.startfreq = atoi(val); + } else if(strcmp(cfg,"channelbw")==0) { + config.channelbw = atoi(val); } else if(strcmp(cfg,"spectrum")==0) { config.spectrum = atoi(val); } else if(strcmp(cfg,"timer")==0) { - config.timer = atoi(val); + config.timer = atoi(val); + } else if(strcmp(cfg,"marker")==0) { + config.marker = atoi(val); } else if(strcmp(cfg,"axudp.active")==0) { config.udpfeed.active = atoi(val)>0; } else if(strcmp(cfg,"axudp.host")==0) { diff --git a/libraries/SondeLib/Sonde.h b/libraries/SondeLib/Sonde.h index 4948919..806ea95 100644 --- a/libraries/SondeLib/Sonde.h +++ b/libraries/SondeLib/Sonde.h @@ -21,8 +21,11 @@ typedef struct st_rdzconfig { int debug; // show port and config options after reboot int wifi; // connect to known WLAN 0=skip int wifiap; // enable/disable WiFi AccessPoint mode 0=disable + int startfreq; // spectrum display start freq (400, 401, ...) + int channelbw; // spectrum channel bandwidth (valid: 5, 10, 20, 25, 50, 100 kHz) int spectrum; // show freq spectrum for n seconds 0=disable int timer; // show remaining time in spectrum 0=disable + int marker; // show freq marker in spectrum 0=disable int maxsonde; // number of max sonde in scan (range=1-99) int noisefloor; // for spectrum display char call[9]; // APRS callsign diff --git a/libraries/SondeLib/aprs.cpp b/libraries/SondeLib/aprs.cpp index 10fc23a..d53e3e6 100644 --- a/libraries/SondeLib/aprs.cpp +++ b/libraries/SondeLib/aprs.cpp @@ -211,10 +211,47 @@ extern int aprsstr_mon2raw(const char *mon, char raw[], int raw_len) #define FEET (1.0/0.3048) #define KNOTS (1.851984) +#define X2C_max_longcard 0xFFFFFFFFUL +static uint32_t X2C_TRUNCC(double x, uint32_t min0, uint32_t max0) +{ + uint32_t i; + + if (x < (double)min0) + i = (uint32_t)min0; + if (x > (double)max0) + i = (uint32_t)max0; + + i = (uint32_t)x; + if ((double)i > x) + --i; + return i; +} + + +static uint32_t truncc(double r) +{ + if (r<=0.0) return 0UL; + else if (r>=2.E+9) return 2000000000UL; + else return (uint32_t)X2C_TRUNCC(r,0UL,X2C_max_longcard); + return 0; +} /* end truncc() */ + + + +static uint32_t dao91(double x) +/* radix91(xx/1.1) of dddmm.mmxx */ +{ + double a; + a = fabs(x); + return ((truncc((a-(double)(float)truncc(a))*6.E+5)%100UL) + *20UL+11UL)/22UL; +} /* end dao91() */ + + char b[201]; char raw[201]; -char * aprs_senddata(float lat, float lon, float hei, float speed, float dir, float climb, const char *type, const char *objname, const char *usercall, const char *sym) +char * aprs_senddata(float lat, float lon, float alt, float speed, float dir, float climb, const char *type, const char *objname, const char *usercall, const char *sym) { *b=0; aprsstr_append(b, usercall); @@ -244,11 +281,11 @@ char * aprs_senddata(float lat, float lon, float hei, float speed, float dir, fl snprintf(b+i, APRS_MAXLEN-i, "%03d/%03d", realcard(dir+1.5), realcard(speed*1.0/KNOTS+0.5)); } #endif - if(hei>0.5) { + if(alt>0.5) { i=strlen(b); - snprintf(b+i, APRS_MAXLEN-i, "/A=%06d", realcard(hei*FEET+0.5)); + snprintf(b+i, APRS_MAXLEN-i, "/A=%06d", realcard(alt*FEET+0.5)); } -#if 0 +#if 1 int dao=1; if(dao) { i=strlen(b); diff --git a/libraries/SondeLib/aprs.h b/libraries/SondeLib/aprs.h index 90e7b97..fe3517e 100644 --- a/libraries/SondeLib/aprs.h +++ b/libraries/SondeLib/aprs.h @@ -9,6 +9,7 @@ typedef struct st_feedinfo { int type; // 0:UDP(axudp), 1:TCP(aprs.fi) char host[64]; int port; + char symbol[3]; int lowrate; int highrate; int lowlimit; @@ -19,7 +20,7 @@ typedef struct st_feedinfo { #define APRS_MAXLEN 201 void aprs_gencrctab(void); int aprsstr_mon2raw(const char *mon, char raw[], int raw_len); -char * aprs_senddata(float lat, float lon, float hei, float speed, float dir, float climb, const char *type, const char *objname, const char *usercall, const char *sym); +char * aprs_senddata(float lat, float lon, float alt, float speed, float dir, float climb, const char *type, const char *objname, const char *usercall, const char *sym); #endif
IDActiveFreqMode
%d