From 0304e4ea32c3d45c159f22641c9c15da3f894216 Mon Sep 17 00:00:00 2001 From: michael carter Date: Mon, 8 Feb 2021 17:45:17 +0000 Subject: [PATCH 01/12] subframe and temp, hum calcs --- libraries/SondeLib/RS41.cpp | 309 ++++++++++++++++++++++++++++++++++++ libraries/SondeLib/Sonde.h | 3 + 2 files changed, 312 insertions(+) diff --git a/libraries/SondeLib/RS41.cpp b/libraries/SondeLib/RS41.cpp index a71c9ac..dfc506e 100644 --- a/libraries/SondeLib/RS41.cpp +++ b/libraries/SondeLib/RS41.cpp @@ -17,6 +17,128 @@ static byte data[800]; static int dpos = 0; +static byte subframe[51*16]; // 816 subframe bytes +static bool subframeReceived[51] = { false }; // do we have data for row +static bool subframeComplete = false; // is the subframe complete +static bool validExternalTemperature = false; // have received all the calibration frames for the external temperature +static bool validHumidity = false; // have received all the calibration frames for the humidity +static bool validRAExternalTemperature = false; // have received all the calibration frames for the external temperature +static bool validRAHumidity = false; // have received all the calibration frames for the humidity + +// whole 51 row frame as C structure +// taken from https://github.com/einergehtnochrein/ra-firmware +union subframeBuffer { + byte rawData[51*16]; + struct __attribute__((__packed__)) { + uint16_t crc16; /* CRC16 CCITT Checksum over range 0x002...0x31F */ + uint16_t frequency; /* 0x002: TX is on 400 MHz + (frequency / 64) * 10 kHz */ + uint8_t startupTxPower; /* 0x004: TX power level at startup (1...7) */ + uint8_t reserved005; + uint8_t reserved006; + uint16_t reserved007; /* 0x007: ?? (some bitfield) [0],[1],[2],[3]. Init value = 0xE */ + uint16_t reserved009; /* 0x009: ? */ + uint8_t reserved00B; + uint8_t reserved00C; + uint8_t serial[8]; /* 0x00D: Sonde ID, 8 char, not terminated */ + uint16_t firmwareVersion; /* 0x015: 10000*major + 100*minor + patch*/ + uint16_t reserved017; + uint16_t minHeight4Flight; /* 0x019: Height (meter above ground) where flight mode begins */ + uint8_t lowBatteryThreshold100mV; /* 0x01B: (Default=18) Shutdown if battery voltage below this + threshold for some time (10s ?) + */ + uint8_t nfcDetectorThreshold; /* 0x01C: NFC detector threshold [25mV] (Default: 0x05 = 125mV) */ + uint8_t reserved01D; /* 0x01D: ?? (Init value = 0xB4) */ + uint8_t reserved01E; /* 0x01E: ?? (Init value = 0x3C) */ + uint16_t reserved01F; + int8_t refTemperatureThreshold; /* 0x021: Reference temperature threshold [°C] */ + uint8_t reserved022; + uint16_t reserved023; + uint16_t reserved025; + int16_t flightKillFrames; /* 0x027: Number of frames in flight until kill (-1 = disabled) */ + uint16_t reserved029; /* 0x029: ? (Init value = 0) */ + uint8_t burstKill; /* 0x02B: Burst kill (0=disabled, 1=enabled) */ + uint8_t reserved02C; + uint8_t reserved02D; + uint16_t reserved02E; + uint16_t reserved030; + uint8_t reserved032; + uint16_t reserved033; + uint16_t reserved035; + uint16_t reserved037; + uint16_t reserved039; /* 0x039: */ + uint8_t reserved03B; /* 0x03B: */ + uint8_t reserved03C; /* 0x03C: */ + float refResistorLow; /* 0x03D: Reference resistor low (750 Ohms) */ + float refResistorHigh; /* 0x041: Reference resistor high (1100 Ohms) */ + float refCapLow; /* 0x045: Reference capacitance low (0) */ + float refCapHigh; /* 0x049: Reference capacitance high (47 pF) */ + float taylorT[3]; /* 0x04D: Tayor coefficients for main temperature calculation */ + float calT; /* 0x059: Calibration factor for main sensor */ + float polyT[6]; /* 0x05D: */ + float calibU[2]; /* 0x075: Calibration coefficients for humidity sensor */ + + float matrixU[7][6]; /* 0x07D: Matrix for humidity sensor RH calculation */ + float taylorTU[3]; /* 0x125: Coefficients for U sensor temperature calculation */ + float calTU; /* 0x131: Calibration factor for U temperature sensor */ + float polyTrh[6]; /* 0x135: */ + + uint8_t reserved14D; /* 0x14D: */ + uint32_t reserved14E; /* 0x14E: */ + + float f152; + uint8_t u156; + float f157; /* 0x157: ?? (Initialized by same value as calibU) */ + uint8_t reserved15B[0x160-0x15B]; + float f160[35]; + uint8_t startIWDG; /* 0x1EC: If ==0 or ==2: Watchdog IWDG will not be started */ + uint8_t parameterSetupDone; /* 0x1ED: Set (!=0) if parameter setup was done */ + uint8_t reserved1EE; + uint8_t reserved1EF; + float f1F0[8]; + float pressureLaunchSite[2]; /* 0x210: Pressure [hPa] at launch site */ + struct { + char variant[10]; /* 0x218: Sonde variant (e.g. "RS41-SG") */ + uint8_t mainboard[10]; /* 0x222: Name of mainboard (e.g. "RSM412") */ + } names; + struct { + uint8_t mainboard[9]; /* 0x22C: Serial number of mainboard (e.g. "L1123553") */ + uint8_t text235[12]; /* 0x235: "0000000000" */ + uint16_t reserved241; /* 0x241: */ + uint8_t pressureSensor[8]; /* 0x243: Serial number of pressure sensor (e.g. "N1310487") */ + uint16_t reserved24B; /* 0x24B: */ + } serials; + uint16_t reserved24D; /* 0x24D: */ + uint8_t reserved24F; + uint8_t reserved250; + uint16_t reserved251; /* 0x251: (Init value = 0x21A = 538) */ + uint8_t xdataUartBaud; /* 0x253: 1=9k6, 2=19k2, 3=38k4, 4=57k6, 5=115k2 */ + uint8_t reserved254; + float cpuTempSensorVoltageAt25deg; /* 0x255: CPU temperature sensor voltage at 25°C */ + uint8_t reserved259; + uint8_t reserved25A[0x25E -0x25A]; + float matrixP[18]; /* 0x25E: Coefficients for pressure sensor polynomial */ + float f2A6[17]; + uint8_t reserved2EA[0x2FA-0x2EA]; + uint16_t halfword2FA[9]; + float reserved30C; + float reserved310; /* 0x310: */ + uint8_t reserved314; /* 0x314: */ + uint8_t reserved315; /* 0x315: */ + int16_t burstKillFrames; /* 0x316: Number of active frames after burst kill */ + uint8_t reserved318[0x320-0x318]; + + /* This is fragment 50. It only uses 14 valid bytes! */ + int16_t killCountdown; /* 0x320: Counts frames remaining until kill (-1 = inactive) */ + uint8_t reserved322[6]; + int8_t intTemperatureCpu; /* 0x328: Temperature [°C] of CPU */ + int8_t intTemperatureRadio; /* 0x329: Temperature [°C] of radio chip */ + int8_t reserved32A; /* 0x32A: */ + uint8_t reserved32B; /* 0x32B: */ + uint8_t reserved32C; /* 0x32C: ? (the sum of two slow 8-bit counters) */ + uint8_t reserved32D; /* 0x32D: ? (the sum of two slow 8-bit counters) */ + } value; + } calibration; + static uint16_t CRCTAB[256]; #define X2C_DIVR(a, b) ((b) != 0.0f ? (a)/(b) : (a)) @@ -251,6 +373,11 @@ static int32_t getint32(const byte frame[], uint32_t frame_len, return (int32_t)n; } /* end getint32() */ +static uint32_t getint24(const byte frame[], uint32_t frame_len, uint32_t p) { // 24bit unsigned int + uint32_t val24 = 0; + val24 = frame[p] | (frame[p+1]<<8) | (frame[p+2]<<16); + return val24; +} static uint32_t getcard16(const byte frame[], uint32_t frame_len, uint32_t p) @@ -379,7 +506,124 @@ static void posrs41(const byte b[], uint32_t b_len, uint32_t p) sonde.si()->validPos = 0x7f; } /* end posrs41() */ +void ProcessSubframe( byte subframeBytes[16], int subframeNumber ) { + // the total subframe consists of 51 rows, each row 16 bytes + // based on https://github.com/bazjo/RS41_Decoding/tree/master/RS41-SGP#Subframe + memcpy( calibration.rawData+16*subframeNumber, subframeBytes, 16); + subframeReceived[subframeNumber] = true; // mark this row of the total subframe as complete + + #if 0 + Serial.printf("subframe number: 0x%02X\n", subframeNumber ); + Serial.print("subframe values: "); + for ( int i = 0; i < 16; i++ ) { + Serial.printf( "%02X ", subframeBytes[i] ); + } + Serial.println(); + + Serial.println("Full subframe"); + for ( int j = 0; j<51; j++ ) { + Serial.printf("%03X ", j*16); + for ( int i = 0; i < 16; i++ ) { + Serial.printf( "%02X ", subframe[j*16+i] ); + } + Serial.println(); + } + Serial.println(); + #endif +} + +/* Find the water vapor saturation pressure for a given temperature. + * Uses the Hyland and Wexler equation with coefficients for T < 0°C. + */ +// taken from https://github.com/einergehtnochrein/ra-firmware +static float _RS41_waterVaporSaturationPressure (float Tcelsius) +{ + /* Convert to Kelvin */ + float T = Tcelsius + 273.15f; + + /* Apply some correction magic */ + T = 0 + - 0.4931358f + + (1.0f + 4.61e-3f) * T + - 1.3746454e-5f * T * T + + 1.2743214e-8f * T * T * T + ; + + /* Plug into H+W equation */ + float p = expf(-5800.2206f / T + + 1.3914993f + + 6.5459673f * logf(T) + - 4.8640239e-2f * T + + 4.1764768e-5f * T * T + - 1.4452093e-8f * T * T * T + ); + + /* Scale result to hPa */ + return p / 100.0f; +} + +// taken from https://github.com/einergehtnochrein/ra-firmware +float GetRATemp( uint32_t measuredCurrent, uint32_t refMin, uint32_t refMax, float calT, float taylorT[3], float polyT[6] ) { + /* Reference values for temperature are two known resistors. + * From that we can derive the resistance of the sensor. + */ + float current = float(measuredCurrent - refMin) / float(refMax - refMin); + float res = calibration.value.refResistorLow + + (calibration.value.refResistorHigh - calibration.value.refResistorLow) * current; + float x = res * calT; + + float Tuncal = 0 + + taylorT[0] + + taylorT[1] * x + + taylorT[2] * x * x; + + /* Apply calibration polynomial */ + float temperature = + Tuncal + polyT[0] + + polyT[1] * Tuncal + + polyT[2] * Tuncal * Tuncal + + polyT[3] * Tuncal * Tuncal * Tuncal + + polyT[4] * Tuncal * Tuncal * Tuncal * Tuncal + + polyT[5] * Tuncal * Tuncal * Tuncal * Tuncal * Tuncal; + + return temperature; +} + +// taken from https://github.com/einergehtnochrein/ra-firmware +float GetRAHumidity( uint32_t humCurrent, uint32_t humMin, uint32_t humMax, float sensorTemp, float externalTemp ) { + + float current = float( humCurrent - humMin) / float( humMax - humMin ); + /* Compute absolute capacitance from the known references */ + float C = calibration.value.refCapLow + + (calibration.value.refCapHigh - calibration.value.refCapLow) * current; + /* Apply calibration */ + float Cp = ( C / calibration.value.calibU[0] - 1.0f) * calibration.value.calibU[1]; + Serial.printf("Cp = %f\n", Cp ); + + int j, k; + float sum = 0; + float xj = 1.0f; + for (j = 0; j < 7; j++) { + float yk = 1.0f; + for (k = 0; k < 6; k++) { + sum += xj * yk * calibration.value.matrixU[j][k]; + yk *= ( sensorTemp - 20.0f) / 180.0f; + } + xj *= Cp; + } + + /* Since there is always a small difference between the temperature readings for + * the atmospheric (main) tempoerature sensor and the temperature sensor inside + * the humidity sensor device, transform the humidity value to the atmospheric conditions + * with its different water vapor saturation pressure. + */ + float RH = sum + * _RS41_waterVaporSaturationPressure(sensorTemp) + / _RS41_waterVaporSaturationPressure(externalTemp); + + return RH; +} // returns: 0: ok, -1: rs or crc error int RS41::decode41(byte *data, int maxlen) @@ -457,6 +701,13 @@ int RS41::decode41(byte *data, int maxlen) sonde.si()->countKT = cntdown; sonde.si()->crefKT = fnr; } + + // process this subframe + int subframeOffset = 24; // 24 = 0x18, start of subframe data + byte receivedBytes[16]; + memcpy( receivedBytes, data+p+subframeOffset, 16); + ProcessSubframe( receivedBytes, calnr ); + } // TODO: some more data break; @@ -476,6 +727,64 @@ int RS41::decode41(byte *data, int maxlen) case '{': // pos posrs41(data+p, len, 0); break; + case 'z': // 0x7a is character z - 7A-MEAS temperature and humidity frame + { + uint32_t tempMeasMain = getint24(data, 560, p+0); + uint32_t tempMeasRef1 = getint24(data, 560, p+3); + uint32_t tempMeasRef2 = getint24(data, 560, p+6); + uint32_t humidityMain = getint24(data, 560, p+9); + uint32_t humidityRef1 = getint24(data, 560, p+12); + uint32_t humidityRef2 = getint24(data, 560, p+15); + uint32_t tempHumiMain = getint24(data, 560, p+18); + uint32_t tempHumiRef1 = getint24(data, 560, p+21); + uint32_t tempHumiRef2 = getint24(data, 560, p+24); + uint32_t pressureMain = getint24(data, 560, p+27); + uint32_t pressureRef1 = getint24(data, 560, p+30); + uint32_t pressureRef2 = getint24(data, 560, p+33); + #if 0 + Serial.printf( "External temp: tempMeasMain = %ld, tempMeasRef1 = %ld, tempMeasRef2 = %ld\n", tempMeasMain, tempMeasRef1, tempMeasRef2 ); + Serial.printf( "Rel Humidity: humidityMain = %ld, humidityRef1 = %ld, humidityRef2 = %ld\n", humidityMain, humidityRef1, humidityRef2 ); + Serial.printf( "Humid sensor: tempHumiMain = %ld, tempHumiRef1 = %ld, tempHumiRef2 = %ld\n", tempHumiMain, tempHumiRef1, tempHumiRef2 ); + Serial.printf( "Pressure sens: pressureMain = %ld, pressureRef1 = %ld, pressureRef2 = %ld\n", pressureMain, pressureRef1, pressureRef2 ); + #endif + + // for a valid temperature, require rLow rHigh (frames 3 4) TaylorT (frames 4 5), polyT (frames 5 6 7), + validExternalTemperature = subframeReceived[3] && subframeReceived[4] && subframeReceived[5] + && subframeReceived[6] && subframeReceived[7]; + + // for a valid RA humidity, valid temperature, calibU (frame 7) matrixU (frame 7-12), taylorTU (frame 12 13), + // calTU (frame 13) polyTrh (frame 13 14) + validHumidity = validExternalTemperature && subframeReceived[0x08] && subframeReceived[0x09] && subframeReceived[0x0A] + && subframeReceived[0x0B] && subframeReceived[0x0C] && subframeReceived[0x0D] && subframeReceived[0x0E] + && subframeReceived[0x0F] && subframeReceived[0x10] && subframeReceived[0x11] && subframeReceived[0x12]; + + if ( validExternalTemperature ) { + if ( tempMeasMain > tempMeasRef1 && tempMeasMain < tempMeasRef2 ) { + sonde.si()->temperature = GetRATemp( tempMeasMain, tempMeasRef1, tempMeasRef2, + calibration.value.calT, calibration.value.taylorT, calibration.value.polyT ); + Serial.printf("tempRA = %f\n", sonde.si()->temperature ); + } + else { + Serial.println( "External temperature data measurement mismatch"); + } + } + + if ( validHumidity ) { + if ( tempHumiMain > tempHumiRef1 && tempHumiMain < tempHumiRef2 ) { + sonde.si()->tempRHSensor = GetRATemp( tempHumiMain, tempHumiRef1, tempHumiRef2, + calibration.value.calTU, calibration.value.taylorTU, calibration.value.polyTrh ); + sonde.si()->relativeHumidity = GetRAHumidity( humidityMain, humidityRef1, humidityRef2, sonde.si()->tempRHSensor, sonde.si()->temperature ); + Serial.printf("Relative humidity = %f\n", sonde.si()->relativeHumidity ); + } + else { + Serial.println( "Sensor temperature data measurement mismatch" ); + } + } + } + break; + + + default: break; }} diff --git a/libraries/SondeLib/Sonde.h b/libraries/SondeLib/Sonde.h index 189df28..eb555f4 100644 --- a/libraries/SondeLib/Sonde.h +++ b/libraries/SondeLib/Sonde.h @@ -99,6 +99,9 @@ typedef struct st_sondeinfo { // shut down timers, currently only for RS41; -1=disabled int16_t launchKT, burstKT, countKT; uint16_t crefKT; // frame number in which countKT was last sent + float temperature = -300.0; // platinum resistor temperature + float tempRHSensor = -300.0; // temperature of relative humidity sensor + float relativeHumidity = -1.0; // relative humidity } SondeInfo; // rxStat: 3=undef[empty] 1=timeout[.] 2=errro[E] 0=ok[|] 4=no valid position[°] From 6e64cd753c2508677fd62b0ec5cbd96b3c048237 Mon Sep 17 00:00:00 2001 From: mycarda Date: Tue, 9 Feb 2021 11:32:01 +0000 Subject: [PATCH 02/12] minor updates after testing --- RX_FSK/version.h | 2 +- libraries/SondeLib/RS41.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/RX_FSK/version.h b/RX_FSK/version.h index 45cd53b..e5049d5 100644 --- a/RX_FSK/version.h +++ b/RX_FSK/version.h @@ -1,4 +1,4 @@ const char *version_name = "rdzTTGOsonde"; -const char *version_id = "devel20210205"; +const char *version_id = "devel20210209"; const int SPIFFS_MAJOR=2; const int SPIFFS_MINOR=9; diff --git a/libraries/SondeLib/RS41.cpp b/libraries/SondeLib/RS41.cpp index dfc506e..2b8659e 100644 --- a/libraries/SondeLib/RS41.cpp +++ b/libraries/SondeLib/RS41.cpp @@ -599,7 +599,6 @@ float GetRAHumidity( uint32_t humCurrent, uint32_t humMin, uint32_t humMax, floa + (calibration.value.refCapHigh - calibration.value.refCapLow) * current; /* Apply calibration */ float Cp = ( C / calibration.value.calibU[0] - 1.0f) * calibration.value.calibU[1]; - Serial.printf("Cp = %f\n", Cp ); int j, k; float sum = 0; @@ -762,17 +761,18 @@ int RS41::decode41(byte *data, int maxlen) if ( tempMeasMain > tempMeasRef1 && tempMeasMain < tempMeasRef2 ) { sonde.si()->temperature = GetRATemp( tempMeasMain, tempMeasRef1, tempMeasRef2, calibration.value.calT, calibration.value.taylorT, calibration.value.polyT ); - Serial.printf("tempRA = %f\n", sonde.si()->temperature ); + Serial.printf("External temperature = %f\n", sonde.si()->temperature ); } else { Serial.println( "External temperature data measurement mismatch"); } } - if ( validHumidity ) { + if ( validHumidity && validExternalTemperature ) { if ( tempHumiMain > tempHumiRef1 && tempHumiMain < tempHumiRef2 ) { sonde.si()->tempRHSensor = GetRATemp( tempHumiMain, tempHumiRef1, tempHumiRef2, calibration.value.calTU, calibration.value.taylorTU, calibration.value.polyTrh ); + Serial.printf("Humidity Sensor temperature = %f\n", sonde.si()->tempRHSensor ); sonde.si()->relativeHumidity = GetRAHumidity( humidityMain, humidityRef1, humidityRef2, sonde.si()->tempRHSensor, sonde.si()->temperature ); Serial.printf("Relative humidity = %f\n", sonde.si()->relativeHumidity ); } From dd3d428fc88e4812e70aa2f59e5cfea722ce5d06 Mon Sep 17 00:00:00 2001 From: Tadeusz Magura-Witkowski Date: Fri, 28 Feb 2020 15:29:25 +0100 Subject: [PATCH 03/12] KML live output --- RX_FSK/RX_FSK.ino | 50 ++++++++++++++++++++++++++++++++++++++ libraries/SondeLib/Sonde.h | 1 + 2 files changed, 51 insertions(+) diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index 520110a..c9bfa9f 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -869,6 +869,48 @@ const char *handleUpdatePost(AsyncWebServerRequest *request) { return ""; } +const char *createKMLLive(const char *myIP) { + char *ptr = message; + + strcpy(ptr, "loads dynamic.kmlhttp://"); + strcat(ptr, myIP); + strcat(ptr, "/dynamic.kmlonInterval10"); + + return message; +} + +void addSondeStatusKML(char *ptr, int i) +{ + SondeInfo *s = &sonde.sondeList[i]; + + if (!s->validID) + { + return; + } + + sprintf(ptr + strlen(ptr), "%s%.6f,%.6f,%.0f%3.3f MHz, Type: %s, h=%.0fm", + s->id, s->id, + s->lon, s->lat, s->alt, + s->freq, sondeTypeStr[s->type], s->alt); +} + +const char *createKMLDynamic() { + char *ptr = message; + + strcpy(ptr, ""); + + for (int i = 0; i < sonde.nSonde; i++) { + int snum = (i + sonde.currentSonde) % sonde.nSonde; + if (sonde.sondeList[snum].active) { + addSondeStatusKML(ptr, snum); + } + } + + strcat(ptr, ""); + + return message; +} + const char *sendGPX(AsyncWebServerRequest * request) { Serial.println("\n\n\n********GPX request\n\n"); @@ -992,6 +1034,14 @@ void SetupAsyncServer() { request->send(SPIFFS, "/index.html", String(), false, processor); }); + server.on("/live.kml", HTTP_GET, [](AsyncWebServerRequest * request) { + request->send(200, "application/vnd.google-earth.kml+xml", createKMLLive(sonde.myIP)); + }); + + server.on("/dynamic.kml", HTTP_GET, [](AsyncWebServerRequest * request) { + request->send(200, "application/vnd.google-earth.kml+xml", createKMLDynamic()); + }); + server.onNotFound([](AsyncWebServerRequest * request) { if (request->method() == HTTP_OPTIONS) { request->send(200); diff --git a/libraries/SondeLib/Sonde.h b/libraries/SondeLib/Sonde.h index 189df28..be2fd4e 100644 --- a/libraries/SondeLib/Sonde.h +++ b/libraries/SondeLib/Sonde.h @@ -239,6 +239,7 @@ public: // moved to heap, saving space in .bss //SondeInfo sondeList[MAXSONDE+1]; SondeInfo *sondeList; + char myIP[17]; // 17 - to fit full IPv4 IP + null byte Sonde(); void defaultConfig(); From 9b9cd8720bf45dfe73317e75b70e4a501f9d09d1 Mon Sep 17 00:00:00 2001 From: Tadeusz Magura-Witkowski Date: Wed, 10 Feb 2021 18:00:00 +0100 Subject: [PATCH 04/12] Small fixes to make it work with upstream version --- RX_FSK/RX_FSK.ino | 2 +- libraries/SondeLib/Sonde.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index c9bfa9f..e57e4fb 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -1035,7 +1035,7 @@ void SetupAsyncServer() { }); server.on("/live.kml", HTTP_GET, [](AsyncWebServerRequest * request) { - request->send(200, "application/vnd.google-earth.kml+xml", createKMLLive(sonde.myIP)); + request->send(200, "application/vnd.google-earth.kml+xml", createKMLLive(sonde.ipaddr.c_str())); }); server.on("/dynamic.kml", HTTP_GET, [](AsyncWebServerRequest * request) { diff --git a/libraries/SondeLib/Sonde.h b/libraries/SondeLib/Sonde.h index be2fd4e..189df28 100644 --- a/libraries/SondeLib/Sonde.h +++ b/libraries/SondeLib/Sonde.h @@ -239,7 +239,6 @@ public: // moved to heap, saving space in .bss //SondeInfo sondeList[MAXSONDE+1]; SondeInfo *sondeList; - char myIP[17]; // 17 - to fit full IPv4 IP + null byte Sonde(); void defaultConfig(); From 581024f035689f173552638abdd888c7c96c2b1b Mon Sep 17 00:00:00 2001 From: mycarda Date: Thu, 11 Feb 2021 07:33:28 +0000 Subject: [PATCH 05/12] Fix bug for negative uint, convert to float first --- libraries/SondeLib/RS41.cpp | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/libraries/SondeLib/RS41.cpp b/libraries/SondeLib/RS41.cpp index 2b8659e..b722505 100644 --- a/libraries/SondeLib/RS41.cpp +++ b/libraries/SondeLib/RS41.cpp @@ -568,7 +568,7 @@ float GetRATemp( uint32_t measuredCurrent, uint32_t refMin, uint32_t refMax, flo /* Reference values for temperature are two known resistors. * From that we can derive the resistance of the sensor. */ - float current = float(measuredCurrent - refMin) / float(refMax - refMin); + float current = ( float(measuredCurrent) - float(refMin) ) / float(refMax - refMin); float res = calibration.value.refResistorLow + (calibration.value.refResistorHigh - calibration.value.refResistorLow) * current; float x = res * calT; @@ -758,27 +758,17 @@ int RS41::decode41(byte *data, int maxlen) && subframeReceived[0x0F] && subframeReceived[0x10] && subframeReceived[0x11] && subframeReceived[0x12]; if ( validExternalTemperature ) { - if ( tempMeasMain > tempMeasRef1 && tempMeasMain < tempMeasRef2 ) { - sonde.si()->temperature = GetRATemp( tempMeasMain, tempMeasRef1, tempMeasRef2, - calibration.value.calT, calibration.value.taylorT, calibration.value.polyT ); - Serial.printf("External temperature = %f\n", sonde.si()->temperature ); - } - else { - Serial.println( "External temperature data measurement mismatch"); - } + sonde.si()->temperature = GetRATemp( tempMeasMain, tempMeasRef1, tempMeasRef2, + calibration.value.calT, calibration.value.taylorT, calibration.value.polyT ); + Serial.printf("External temperature = %f\n", sonde.si()->temperature ); } if ( validHumidity && validExternalTemperature ) { - if ( tempHumiMain > tempHumiRef1 && tempHumiMain < tempHumiRef2 ) { - sonde.si()->tempRHSensor = GetRATemp( tempHumiMain, tempHumiRef1, tempHumiRef2, + sonde.si()->tempRHSensor = GetRATemp( tempHumiMain, tempHumiRef1, tempHumiRef2, calibration.value.calTU, calibration.value.taylorTU, calibration.value.polyTrh ); - Serial.printf("Humidity Sensor temperature = %f\n", sonde.si()->tempRHSensor ); - sonde.si()->relativeHumidity = GetRAHumidity( humidityMain, humidityRef1, humidityRef2, sonde.si()->tempRHSensor, sonde.si()->temperature ); - Serial.printf("Relative humidity = %f\n", sonde.si()->relativeHumidity ); - } - else { - Serial.println( "Sensor temperature data measurement mismatch" ); - } + Serial.printf("Humidity Sensor temperature = %f\n", sonde.si()->tempRHSensor ); + sonde.si()->relativeHumidity = GetRAHumidity( humidityMain, humidityRef1, humidityRef2, sonde.si()->tempRHSensor, sonde.si()->temperature ); + Serial.printf("Relative humidity = %f\n", sonde.si()->relativeHumidity ); } } break; From 4fcd24cc417866a956edbdc1f99280be6a75349b Mon Sep 17 00:00:00 2001 From: Michael Carter Date: Thu, 11 Feb 2021 07:35:41 +0000 Subject: [PATCH 06/12] Update version.h update version --- RX_FSK/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RX_FSK/version.h b/RX_FSK/version.h index e5049d5..41ff9c6 100644 --- a/RX_FSK/version.h +++ b/RX_FSK/version.h @@ -1,4 +1,4 @@ const char *version_name = "rdzTTGOsonde"; -const char *version_id = "devel20210209"; +const char *version_id = "devel20210211"; const int SPIFFS_MAJOR=2; const int SPIFFS_MINOR=9; From 30b7b353390b45d9dec32787031f47a91e88bdb6 Mon Sep 17 00:00:00 2001 From: "Hansi, dl9rdz" Date: Sat, 20 Feb 2021 10:27:50 +0100 Subject: [PATCH 07/12] fix for wrong DFM position for negative lat/lon (untested) --- RX_FSK/version.h | 2 +- libraries/SondeLib/DFM.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RX_FSK/version.h b/RX_FSK/version.h index e8cc738..e702617 100644 --- a/RX_FSK/version.h +++ b/RX_FSK/version.h @@ -1,4 +1,4 @@ const char *version_name = "rdzTTGOsonde"; -const char *version_id = "devel20210213"; +const char *version_id = "devel20210220"; const int SPIFFS_MAJOR=2; const int SPIFFS_MINOR=10; diff --git a/libraries/SondeLib/DFM.cpp b/libraries/SondeLib/DFM.cpp index 5c34975..bf9d204 100644 --- a/libraries/SondeLib/DFM.cpp +++ b/libraries/SondeLib/DFM.cpp @@ -412,7 +412,7 @@ void DFM::decodeDAT(uint8_t *dat) case 2: { float lat, vh; - lat = ((uint32_t)dat[0]<<24) + ((uint32_t)dat[1]<<16) + ((uint32_t)dat[2]<<8) + ((uint32_t)dat[3]); + lat = (int32_t)(((uint32_t)dat[0]<<24) + ((uint32_t)dat[1]<<16) + ((uint32_t)dat[2]<<8) + ((uint32_t)dat[3])); vh = ((uint16_t)dat[4]<<8) + dat[5]; Serial.print("GPS-lat: "); Serial.print(lat*0.0000001); Serial.print(", hor-V: "); Serial.print(vh*0.01); @@ -424,7 +424,7 @@ void DFM::decodeDAT(uint8_t *dat) case 3: { float lon, dir; - lon = ((uint32_t)dat[0]<<24) + ((uint32_t)dat[1]<<16) + ((uint32_t)dat[2]<<8) + (uint32_t)dat[3]; + lon = (int32_t)(((uint32_t)dat[0]<<24) + ((uint32_t)dat[1]<<16) + ((uint32_t)dat[2]<<8) + (uint32_t)dat[3]); dir = ((uint16_t)dat[4]<<8) + dat[5]; Serial.print("GPS-lon: "); Serial.print(lon*0.0000001); Serial.print(", dir: "); Serial.print(dir*0.01); From cb6f2a7c9121a728bc69061fc35eab6c3a6b30f4 Mon Sep 17 00:00:00 2001 From: "Hansi, dl9rdz" Date: Fri, 26 Feb 2021 23:40:15 +0100 Subject: [PATCH 08/12] auto gps factoryreset for t-beam --- RX_FSK/RX_FSK.ino | 37 ++++++++++++++++++++++------------ RX_FSK/data/GPSRESET | 1 + RX_FSK/data/config.txt | 2 +- RX_FSK/version.h | 2 +- libraries/SondeLib/Display.cpp | 6 ++++-- libraries/SondeLib/Sonde.cpp | 1 + 6 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 RX_FSK/data/GPSRESET diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index 00cb44c..d6f2eb4 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -1217,23 +1217,34 @@ void gpsTask(void *parameter) { #define UBX_SYNCH_2 0x62 uint8_t ubx_set9k6[]={UBX_SYNCH_1, UBX_SYNCH_2, 0x06, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0xC0, 0x08, 0x00, 0x00, 0x80, 0x25, 0x00, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8D, 0x8F}; uint8_t ubx_factorydef[]={UBX_SYNCH_1, UBX_SYNCH_2, 0x06, 0x09, 13, 0, 0xff, 0xff, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0x17, 0x8A }; +uint8_t ubx_hardreset[]={UBX_SYNCH_1, UBX_SYNCH_2, 0x06, 0x04, 4, 0, 0xff, 0xff, 0, 0, 0x0C, 0x5D }; void initGPS() { if (sonde.config.gps_rxd < 0) return; // GPS disabled if (sonde.config.gps_txd >= 0) { // TX enable, thus try setting baud to 9600 and do a factory reset - Serial.println("Trying to reset GPS..."); - Serial2.begin(115200, SERIAL_8N1, sonde.config.gps_rxd, sonde.config.gps_txd); - Serial2.write(ubx_set9k6, sizeof(ubx_set9k6)); - delay(100); - Serial2.begin(38400, SERIAL_8N1, sonde.config.gps_rxd, sonde.config.gps_txd); - Serial2.write(ubx_set9k6, sizeof(ubx_set9k6)); - delay(100); - Serial2.begin(19200, SERIAL_8N1, sonde.config.gps_rxd, sonde.config.gps_txd); - Serial2.write(ubx_set9k6, sizeof(ubx_set9k6)); - delay(100); - Serial2.begin(9600, SERIAL_8N1, sonde.config.gps_rxd, sonde.config.gps_txd); - Serial2.write(ubx_factorydef, sizeof(ubx_factorydef)); - delay(1000); + File testfile = SPIFFS.open("/GPSRESET", FILE_READ); + if(testfile && !testfile.isDirectory()) { + testfile.close(); + Serial.println("GPS factory reset..."); + Serial2.begin(115200, SERIAL_8N1, sonde.config.gps_rxd, sonde.config.gps_txd); + Serial2.write(ubx_set9k6, sizeof(ubx_set9k6)); + delay(100); + Serial2.begin(38400, SERIAL_8N1, sonde.config.gps_rxd, sonde.config.gps_txd); + Serial2.write(ubx_set9k6, sizeof(ubx_set9k6)); + delay(100); + Serial2.begin(19200, SERIAL_8N1, sonde.config.gps_rxd, sonde.config.gps_txd); + Serial2.write(ubx_set9k6, sizeof(ubx_set9k6)); + delay(100); + Serial2.begin(9600, SERIAL_8N1, sonde.config.gps_rxd, sonde.config.gps_txd); + Serial2.write(ubx_factorydef, sizeof(ubx_factorydef)); + delay(100); + Serial2.write(ubx_hardreset, sizeof(ubx_hardreset)); + //delay(5000); + SPIFFS.remove("/GPSRESET"); + } else if (testfile) { + Serial.println("GPS reset file: not found/isdir"); + testfile.close(); + } } else { Serial2.begin(9600, SERIAL_8N1, sonde.config.gps_rxd, sonde.config.gps_txd); } diff --git a/RX_FSK/data/GPSRESET b/RX_FSK/data/GPSRESET new file mode 100644 index 0000000..fd38861 --- /dev/null +++ b/RX_FSK/data/GPSRESET @@ -0,0 +1 @@ ++ diff --git a/RX_FSK/data/config.txt b/RX_FSK/data/config.txt index 4e8b2e8..bda55a1 100644 --- a/RX_FSK/data/config.txt +++ b/RX_FSK/data/config.txt @@ -26,7 +26,7 @@ #tft_cs=0 tft_orient=1 #gps_rxd=-1 -gps_txd=-1 +#gps_txd=-1 # Show AFC value (for RS41 and M10/M20, maybe also DFM, but not useful for RS92) showafc=1 # Frequency correction, in Hz diff --git a/RX_FSK/version.h b/RX_FSK/version.h index e702617..31a1153 100644 --- a/RX_FSK/version.h +++ b/RX_FSK/version.h @@ -1,4 +1,4 @@ const char *version_name = "rdzTTGOsonde"; -const char *version_id = "devel20210220"; +const char *version_id = "devel20210226"; const int SPIFFS_MAJOR=2; const int SPIFFS_MINOR=10; diff --git a/libraries/SondeLib/Display.cpp b/libraries/SondeLib/Display.cpp index 00a261b..8557c83 100644 --- a/libraries/SondeLib/Display.cpp +++ b/libraries/SondeLib/Display.cpp @@ -780,8 +780,8 @@ void Display::parseDispElement(char *text, DispEntry *de) de->extra = (char *)circinfo; } else { de->extra = strdup(text+1); + Serial.printf("parsing 'g' entry: extra is '%s'\n", de->extra); } - Serial.printf("parsing 'g' entry: extra is '%s'\n", de->extra); break; case 'r': de->func = disp.drawRSSI; break; @@ -839,7 +839,7 @@ int Display::countEntries(File f) { break; } f.seek(pos, SeekSet); - Serial.printf("Counted %d entries\n", n); + //Serial.printf("Counted %d entries\n", n); return n; } @@ -970,9 +970,11 @@ void Display::initFromFile(int index) { what++; newlayouts[idx].de[what].func = NULL; } else { +#if 0 for(int i=0; i<12; i++) { Serial.printf("action %d: %d\n", i, (int)newlayouts[idx].actions[i]); } +#endif what=-1; } break; diff --git a/libraries/SondeLib/Sonde.cpp b/libraries/SondeLib/Sonde.cpp index 6f16a14..0c9c590 100644 --- a/libraries/SondeLib/Sonde.cpp +++ b/libraries/SondeLib/Sonde.cpp @@ -114,6 +114,7 @@ void Sonde::defaultConfig() { //config.button2_pin = 255; config.button2_axp = 1; config.gps_rxd = 34; + config.gps_txd = 12; // Check for I2C-Display@21,22 #define SSD1306_ADDRESS 0x3c Wire.begin(21, 22); From a051b069bb4adb74c50ac0f6146bc4b26b640785 Mon Sep 17 00:00:00 2001 From: "Hansi, dl9rdz" Date: Sat, 27 Feb 2021 00:32:03 +0100 Subject: [PATCH 09/12] fix travis? --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a4f08be..a6f9e6c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: c env: global: - - ESP32TOOLS=/home/travis/.arduino15/packages/esp32/hardware/esp32/1.0.4/tools + - ESP32TOOLS=/home/travis/.arduino15/packages/esp32/hardware/esp32/1.0.5/tools - MKSPIFFS=/home/travis/.arduino15/packages/esp32/tools/mkspiffs/0.2.3/mkspiffs before_install: - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16" From a7a642332fc118a241c077583ac549a145d63764 Mon Sep 17 00:00:00 2001 From: "Hansi, dl9rdz" Date: Tue, 2 Mar 2021 12:47:46 +0100 Subject: [PATCH 10/12] test (Joerg) --- RX_FSK/RX_FSK.ino | 70 ++++++++++++++++++++++++++-- RX_FSK/data/config.txt | 1 + RX_FSK/version.h | 2 +- libraries/SondeLib/Sonde.cpp | 3 ++ libraries/SondeLib/Sonde.h | 1 + libraries/SondeLib/TFT22_ILI9225.cpp | 11 +++-- libraries/SondeLib/TFT22_ILI9225.h | 4 +- 7 files changed, 84 insertions(+), 8 deletions(-) diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index d6f2eb4..d940a13 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -108,6 +108,7 @@ int readLine(Stream &stream, char *buffer, int maxlen) { return n; } + // Replaces placeholder with LED state value String processor(const String& var) { Serial.println(var); @@ -564,6 +565,7 @@ struct st_configitems config_list[] = { {"tft_rs", "TFT RS", 0, &sonde.config.tft_rs}, {"tft_cs", "TFT CS", 0, &sonde.config.tft_cs}, {"tft_orient", "TFT orientation (0/1/2/3), OLED flip: 3", 0, &sonde.config.tft_orient}, + {"tft_modeflip", "TFT modeflip (usually 0)", 0, &sonde.config.tft_modeflip}, {"button_pin", "Button input port", -4, &sonde.config.button_pin}, {"button2_pin", "Button 2 input port", -4, &sonde.config.button2_pin}, {"button2_axp", "Use AXP192 PWR as Button 2", 0, &sonde.config.button2_axp}, @@ -790,6 +792,55 @@ const char *handleControlPost(AsyncWebServerRequest *request) { return ""; } +int streamEditForm(int &state, File &file, String filename, char *buffer, size_t maxlen, size_t index) { + Serial.printf("streamEdit: state=%d max:%d idx:%d\n", state, maxlen, index); + int i=0; + switch(state) { + case 0: // header + { + // we optimistically assume that on first invocation, maxlen is large enough to handle the header..... + strncpy(buffer, "Editor

Edit: ", maxlen); + i = strlen(buffer); + strncpy(buffer+i, filename.c_str(), maxlen-i); + i += strlen(buffer+i); + strncpy(buffer+i, "

", maxlen); + state++; + return strlen(buffer); + case 3: // end + return 0; + } + return 0; +} + // bad idea. prone to buffer overflow. use at your own risk... const char *createEditForm(String filename) { Serial.println("Creating edit form"); @@ -999,14 +1050,27 @@ void SetupAsyncServer() { }); server.on("/edit.html", HTTP_GET, [](AsyncWebServerRequest * request) { - request->send(200, "text/html", createEditForm(request->getParam(0)->value())); + // new version: + // Open file + // store file object in request->_tempObject + //request->send(200, "text/html", createEditForm(request->getParam(0)->value())); + const String filename = request->getParam(0)->value(); + File file = SPIFFS.open("/" + filename, "r"); + int state = 0; + request->send("text/html", 0, [state,file,filename](uint8_t *buffer, size_t maxLen, size_t index) mutable -> size_t { + Serial.printf("******* send callback: %d %d %d\n", state, maxLen, index); + return streamEditForm(state, file, filename, (char *)buffer, maxLen, index); + }); }); server.on("/edit.html", HTTP_POST, [](AsyncWebServerRequest * request) { const char *ret = handleEditPost(request); if (ret == NULL) request->send(200, "text/html", "ERROR

Something went wrong. Uploaded file is empty.

"); - else - request->send(200, "text/html", createEditForm(request->getParam(0)->value())); + else { + String f = request->getParam(0)->value(); + request->redirect("/edit.html?file="+f); + //request->send(200, "text/html", createEditForm(request->getParam(0)->value())); + } }, NULL, [](AsyncWebServerRequest * request, uint8_t *data, size_t len, size_t index, size_t total) { diff --git a/RX_FSK/data/config.txt b/RX_FSK/data/config.txt index bda55a1..e3bcc5e 100644 --- a/RX_FSK/data/config.txt +++ b/RX_FSK/data/config.txt @@ -25,6 +25,7 @@ #tft_rs=2 #tft_cs=0 tft_orient=1 +#tft_modeflip=0 #gps_rxd=-1 #gps_txd=-1 # Show AFC value (for RS41 and M10/M20, maybe also DFM, but not useful for RS92) diff --git a/RX_FSK/version.h b/RX_FSK/version.h index 31a1153..479d805 100644 --- a/RX_FSK/version.h +++ b/RX_FSK/version.h @@ -1,4 +1,4 @@ const char *version_name = "rdzTTGOsonde"; -const char *version_id = "devel20210226"; +const char *version_id = "devel20210302"; const int SPIFFS_MAJOR=2; const int SPIFFS_MINOR=10; diff --git a/libraries/SondeLib/Sonde.cpp b/libraries/SondeLib/Sonde.cpp index 0c9c590..57648d8 100644 --- a/libraries/SondeLib/Sonde.cpp +++ b/libraries/SondeLib/Sonde.cpp @@ -87,6 +87,7 @@ void Sonde::defaultConfig() { config.button2_axp = 0; config.norx_timeout = 20; config.screenfile = 1; + config.tft_modeflip = 0; if(initlevels[16]==0) { config.oled_sda = 4; config.oled_scl = 15; @@ -258,6 +259,8 @@ void Sonde::setConfig(const char *cfg) { config.tft_cs = atoi(val); } else if(strcmp(cfg,"tft_orient")==0) { config.tft_orient = atoi(val); + } else if(strcmp(cfg,"tft_modeflip")==0) { + config.tft_modeflip = atoi(val); } else if(strcmp(cfg,"gps_rxd")==0) { config.gps_rxd = atoi(val); } else if(strcmp(cfg,"gps_txd")==0) { diff --git a/libraries/SondeLib/Sonde.h b/libraries/SondeLib/Sonde.h index 189df28..4ba8640 100644 --- a/libraries/SondeLib/Sonde.h +++ b/libraries/SondeLib/Sonde.h @@ -186,6 +186,7 @@ typedef struct st_rdzconfig { int tft_rs; // TFT RS pin int tft_cs; // TFT CS pin int tft_orient; // TFT orientation (default: 1) + int tft_modeflip; // Hack for Joerg's strange display int gps_rxd; // GPS module RXD pin. We expect 9600 baud NMEA data. int gps_txd; // GPS module TXD pin // software configuration diff --git a/libraries/SondeLib/TFT22_ILI9225.cpp b/libraries/SondeLib/TFT22_ILI9225.cpp index 1bd3762..145d7d6 100644 --- a/libraries/SondeLib/TFT22_ILI9225.cpp +++ b/libraries/SondeLib/TFT22_ILI9225.cpp @@ -342,10 +342,12 @@ void TFT22_ILI9225::begin() endWrite(); delay(50); +#define OCTLFLIP(m) ((m&0xff)<<8) +#define EMODEFLIP(m) ((m>>8)<<3) startWrite(); - _writeRegister(ILI9225_DRIVER_OUTPUT_CTRL, 0x011C); // set the display line number and display direction + _writeRegister(ILI9225_DRIVER_OUTPUT_CTRL, OCTLFLIP(_modeFlip) ^ 0x011C); // set the display line number and display direction _writeRegister(ILI9225_LCD_AC_DRIVING_CTRL, 0x0100); // set 1 line inversion - _writeRegister(ILI9225_ENTRY_MODE, 0x1038); // set GRAM write direction and BGR=1. + _writeRegister(ILI9225_ENTRY_MODE, EMODEFLIP(_modeFlip) ^ 0x1038); // set GRAM write direction and BGR=1. _writeRegister(ILI9225_DISP_CTRL1, 0x0000); // Display off _writeRegister(ILI9225_BLANK_PERIOD_CTRL1, 0x0808); // set the back porch and front porch _writeRegister(ILI9225_FRAME_CYCLE_CTRL, 0x1100); // set the clocks number per line @@ -482,7 +484,7 @@ void TFT22_ILI9225::_setWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y startWrite(); // autoincrement mode if ( _orientation > 0 ) mode = modeTab[_orientation-1][mode]; - _writeRegister(ILI9225_ENTRY_MODE, 0x1000 | ( mode<<3) ); + _writeRegister(ILI9225_ENTRY_MODE, EMODEFLIP(_modeFlip) ^ (0x1000 | ( mode<<3)) ); _writeRegister(ILI9225_HORIZONTAL_WINDOW_ADDR1,x1); _writeRegister(ILI9225_HORIZONTAL_WINDOW_ADDR2,x0); @@ -582,6 +584,9 @@ void TFT22_ILI9225::setDisplay(boolean flag) { } } +void TFT22_ILI9225::setModeFlip(uint8_t m) { + _modeFlip = m; +} void TFT22_ILI9225::setOrientation(uint8_t orientation) { diff --git a/libraries/SondeLib/TFT22_ILI9225.h b/libraries/SondeLib/TFT22_ILI9225.h index 2cdab23..7286173 100644 --- a/libraries/SondeLib/TFT22_ILI9225.h +++ b/libraries/SondeLib/TFT22_ILI9225.h @@ -393,6 +393,8 @@ class TFT22_ILI9225 { void getGFXCharExtent(uint8_t c, int16_t *gw, int16_t *gh, int16_t *xa); + void setModeFlip(uint8_t m); + private: void _spiWrite(uint8_t v); @@ -436,7 +438,7 @@ class TFT22_ILI9225 { int8_t _rst, _rs, _cs, _sdi, _clk, _led; #endif - uint8_t _orientation, _brightness; + uint8_t _orientation, _brightness, _modeflip; // correspondig modes if orientation changed: const autoIncMode_t modeTab [3][8] = { From 8df0859f1c8669b04e830a80b8a47a6732c8e1d1 Mon Sep 17 00:00:00 2001 From: "Hansi, dl9rdz" Date: Sun, 14 Mar 2021 18:12:07 +0100 Subject: [PATCH 11/12] gps init bugfix, less debug messages, gps for android w/o gps (+GPGST parser), merge kml live view --- RX_FSK/RX_FSK.ino | 530 ++++++++++++++------------- RX_FSK/data/config.txt | 2 +- RX_FSK/version.h | 2 +- libraries/SondeLib/Display.cpp | 15 +- libraries/SondeLib/Display.h | 1 + libraries/SondeLib/RS41.cpp | 4 +- libraries/SondeLib/Sonde.cpp | 39 +- libraries/SondeLib/TFT22_ILI9225.cpp | 6 +- libraries/SondeLib/TFT22_ILI9225.h | 5 +- 9 files changed, 324 insertions(+), 280 deletions(-) diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index 07bacfd..1738764 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -27,9 +27,9 @@ int e; enum MainState { ST_DECODER, ST_SPECTRUM, ST_WIFISCAN, ST_UPDATE, ST_TOUCHCALIB }; static MainState mainState = ST_WIFISCAN; // ST_WIFISCAN; +const char *mainStateStr[5] = {"DECODER", "SPECTRUM", "WIFISCAN", "UPDATE", "TOUCHCALIB" }; AsyncWebServer server(80); -AsyncWebSocket ws("/ws"); AXP20X_Class axp; #define PMU_IRQ 35 @@ -215,7 +215,7 @@ void setupChannelList() { file.close(); } -const char *HTMLHEAD=" "; +const char *HTMLHEAD = " "; void HTMLBODY(char *ptr, const char *which) { strcat(ptr, "
"); -/* - strcat(ptr, ""); -*/ - HTMLBODY(ptr, "qrg.html"); + /* + strcat(ptr, ""); + */ + HTMLBODY(ptr, "qrg.html"); //strcat(ptr, "
"); strcat(ptr, "
IDActiveFreqLaunchsiteMode
"); for (int i = 0; i < sonde.config.maxsonde; i++) { @@ -274,7 +274,7 @@ const char *createQRGForm() { i + 1, i >= sonde.nSonde ? 400.000 : sonde.sondeList[i].freq, i + 1, i >= sonde.nSonde ? " " : sonde.sondeList[i].launchsite, i + 1, i >= sonde.nSonde ? 2 : sondeTypeChar[sonde.sondeList[i].type] ); - //i + 1, s.c_str()); + //i + 1, s.c_str()); } strcat(ptr, "
IDActiveFreqLaunchsiteMode
"); //
"); @@ -456,7 +456,7 @@ void addSondeStatus(char *ptr, int i) sprintf(ptr + strlen(ptr), "radiosondy.info - ", s->id); sprintf(ptr + strlen(ptr), "OSM - ", s->lat, s->lon); sprintf(ptr + strlen(ptr), "Google", s->lat, s->lon); - + strcat(ptr, "

\n"); } @@ -545,7 +545,7 @@ struct st_configitems config_list[] = { {"tcp.port", "APRS TCP Port", 0, &sonde.config.tcpfeed.port}, {"tcp.idformat", "DFM ID Format", -2, &sonde.config.tcpfeed.idformat}, {"tcp.highrate", "Rate limit", 0, &sonde.config.tcpfeed.highrate}, - + /* MQTT */ {"mqtt.active", "MQTT Active (needs reboot)", 0, &sonde.config.mqtt.active}, {"mqtt.id", "MQTT client ID", 63, &sonde.config.mqtt.id}, @@ -742,7 +742,9 @@ const char *createControlForm() { strcat(ptr, "\" value=\""); strcat(ptr, ctrllabel[i]); strcat(ptr, "\">"); - if(i==3) { strcat(ptr, "

"); } + if (i == 3) { + strcat(ptr, "

"); + } } HTMLBODYEND(ptr); Serial.printf("Control form: size=%d bytes\n", strlen(message)); @@ -794,40 +796,40 @@ const char *handleControlPost(AsyncWebServerRequest *request) { int streamEditForm(int &state, File &file, String filename, char *buffer, size_t maxlen, size_t index) { Serial.printf("streamEdit: state=%d max:%d idx:%d\n", state, maxlen, index); - int i=0; - switch(state) { + int i = 0; + switch (state) { case 0: // header - { - // we optimistically assume that on first invocation, maxlen is large enough to handle the header..... - strncpy(buffer, "Editor

Edit: ", maxlen); - i = strlen(buffer); - strncpy(buffer+i, filename.c_str(), maxlen-i); - i += strlen(buffer+i); - strncpy(buffer+i, "