From 3158945266ec5f94efeb8311592be8ff54e8dd56 Mon Sep 17 00:00:00 2001 From: Pawel Jalocha Date: Wed, 12 Jul 2023 11:48:47 +0100 Subject: [PATCH] Various updates, most important is to save the Power-ON state for the devices with AXP192 so they don't turn on on the external power (by will remember if they had been turned on by the button) --- main/adsl.h | 47 ++++++++++++++++++++++++++++++++++++ main/axp192.h | 4 +++- main/config.h | 2 +- main/ctrl.cpp | 3 ++- main/disp_oled.cpp | 2 +- main/hal.cpp | 7 +++++- main/main.cpp | 22 +++++++++++++++++ main/ogn.h | 59 ++++++++++++++++++++++++++++++++++++---------- main/ogn1.h | 3 ++- main/ognconv.cpp | 53 +++++++++++++++++++++++++++++++++++++++++ main/ognconv.h | 4 ++++ main/parameters.h | 15 ++++++++---- main/proc.cpp | 25 ++++++++++---------- main/rf.cpp | 6 ++--- main/sens.cpp | 3 ++- 15 files changed, 215 insertions(+), 40 deletions(-) diff --git a/main/adsl.h b/main/adsl.h index 05db3fb..249689e 100644 --- a/main/adsl.h +++ b/main/adsl.h @@ -236,6 +236,53 @@ class ADSL_Packet LonDist = (LonDist<<12)/LatCos; // LonDist/=cosine(Latitude) setLonOGN(RefLon+(LonDist*27)/5); } +// -------------------------------------------------------------------------------------------------------- + + int WriteStxJSON(char *JSON) const // Stratux JSON message + { int Len=0; + uint32_t Address=getAddress(); + Len+=Format_String(JSON+Len, "\"addr\":\""); + Len+=Format_Hex(JSON+Len, (uint8_t) (Address>>16)); + Len+=Format_Hex(JSON+Len, (uint16_t)(Address)); + JSON[Len++]='\"'; + JSON[Len++]=','; + Len+=Format_String(JSON+Len, "\"addr_type\":"); + JSON[Len++] = HexDigit(getAddrTypeOGN()); + Len+=Format_String(JSON+Len, ",\"acft_type\":\""); + JSON[Len++] = HexDigit(getAcftTypeOGN()); + // Len+=Format_String(JSON+Len, ",\"acft_cat\":\""); + // Len+=Format_Hex(JSON+Len, AcftCat); + JSON[Len++]='\"'; + + Len+=Format_String(JSON+Len, ",\"lat_deg\":"); + Len+=Format_SignDec(JSON+Len, getLatUBX(), 8, 7, 1); + Len+=Format_String(JSON+Len, ",\"lon_deg\":"); + Len+=Format_SignDec(JSON+Len, getLonUBX(), 8, 7, 1); + + Len+=Format_String(JSON+Len, ",\"track_deg\":"); + Len+=Format_UnsDec(JSON+Len, ((uint32_t)225*getTrack()+16)>>5, 2, 1); + Len+=Format_String(JSON+Len, ",\"speed_mps\":"); + Len+=Format_UnsDec(JSON+Len, ((uint32_t)getSpeed()*10+2)>>2, 2, 1); + Len+=Format_String(JSON+Len, ",\"climb_mps\":"); + Len+=Format_SignDec(JSON+Len, ((int32_t)getClimb()*10+4)>>3, 2, 1, 1); + + Len+=Format_String(JSON+Len, ",\"alt_hae_m\":"); + Len+=Format_SignDec(JSON+Len, getAlt(), 1, 0, 1); + + if(getRelay()) Len+=Format_String(JSON+Len, ",\"relay\":1"); + + Len+=Format_String(JSON+Len, ",\"NACp\":"); + JSON[Len++]='0'+HorizAccuracy; + Len+=Format_String(JSON+Len, ",\"NACv\":"); + JSON[Len++]='0'+VelAccuracy; + // Len+=Format_String(JSON+Len, ",\"Emergency\":"); + // JSON[Len++]='0'+Emergency; + // if(FlightState>0 && FlightState<3) + // { Len+=Format_String(JSON+Len, ",\"airborne\":"); + // Len+=Format_String(JSON+Len, FlightState==2?"true":"false"; } + + return Len; } + // -------------------------------------------------------------------------------------------------------- void Scramble(void) diff --git a/main/axp192.h b/main/axp192.h index 00140e5..f7169e7 100644 --- a/main/axp192.h +++ b/main/axp192.h @@ -24,7 +24,9 @@ class AXP192 static const uint8_t REG_CHARGE_1 = 0x33; // target voltage, current static const uint8_t REG_CHARGE_2 = 0x34; static const uint8_t REG_BACKUP_CHG = 0x35; // backup battery charge - static const uint8_t REG_POK_SET = 0x36; // press-key parameters + static const uint8_t REG_POK_SET = 0x36; // Power-ON-Key parameters + static const uint8_t REG_DCDC_FREQ = 0x37; // [0..15] DC-DC frequency adjust, 5%/bit + static const uint8_t REG_DCDC_MODE = 0x80; // DC-DC1/2/3 mode PFM/PWM auto or PWM fixed static const uint8_t REG_INTEN1 = 0x40; // IRQ enable static const uint8_t REG_INTEN2 = 0x41; diff --git a/main/config.h b/main/config.h index 1aa5124..12512b9 100644 --- a/main/config.h +++ b/main/config.h @@ -77,7 +77,7 @@ // #define WITH_ADSL // #define WITH_PAW // #define WITH_FANET -// #define WITH_LORAWAN +#define WITH_LORAWAN #define WITH_AP // WiFi Access Point: can work together with BT_SPP #define WITH_AP_BUTTON // only starts when button pressed at sartup diff --git a/main/ctrl.cpp b/main/ctrl.cpp index ff1c759..aef95f7 100644 --- a/main/ctrl.cpp +++ b/main/ctrl.cpp @@ -476,7 +476,8 @@ void vTaskCTRL(void* pvParameters) xSemaphoreTake(CONS_Mutex, portMAX_DELAY); Format_String(CONS_UART_Write, "Power-Off Request\n"); xSemaphoreGive(CONS_Mutex); - // vTaskDelay(1000); + Parameters.PowerON=0; + Parameters.WriteToNVS(); AXP.setLED(4); #ifdef WITH_OLED OLED_DisplayON(0); diff --git a/main/disp_oled.cpp b/main/disp_oled.cpp index abace3a..fda1a1c 100644 --- a/main/disp_oled.cpp +++ b/main/disp_oled.cpp @@ -42,7 +42,7 @@ #define STR(macro) QUOTE(macro) #ifndef VERSION -#define VERSION 0.1.3 +#define VERSION 0.1.5 #endif static char Line[128]; diff --git a/main/hal.cpp b/main/hal.cpp index 7409f6f..378a879 100644 --- a/main/hal.cpp +++ b/main/hal.cpp @@ -1678,7 +1678,12 @@ void IO_Configuration(void) #endif AXP.checkID(); AXP.setPOK(0xDC); // power-on = 11 = 1sec, long-press = 01 = 1.5sec, power-off = enable, PWROK delay = 64ms, power-off = 00 = 4sec - uint8_t PwrStatus = AXP.readStatus(); + // uint8_t PwrStatus = AXP.readStatus(); // bit #0 = 1:by ext. power, 0:by power-on-button + // bool ExtPwrON = PwrStatus&1; + // if(!ExtPwrON) Parameters.PowerON=1; + // xSemaphoreTake(CONS_Mutex, portMAX_DELAY); + // Format_String(CONS_UART_Write, ExtPwrON ? "Power-ON by ext. power\n":"Power-ON by Power-ON button\n"); + // xSemaphoreGive(CONS_Mutex); AXP.setLED_ON(); AXP.setPowerOutput(AXP.OUT_DCDC1, 1); // 3.3V on the pin header for LCD and BME280 AXP.setDCDC1(3300); diff --git a/main/main.cpp b/main/main.cpp index 170ab6d..815d463 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -63,6 +63,28 @@ void app_main(void) #endif IO_Configuration(); // initialize the GPIO/UART/I2C/SPI for Radio, GPS, OLED, Baro +#ifdef WITH_AXP + uint8_t PwrStatus = AXP.readStatus(); // bit #0 = 1:by ext. power, 0:by power-on-button + bool ExtPwrON = PwrStatus&1; + xSemaphoreTake(CONS_Mutex, portMAX_DELAY); + Format_String(CONS_UART_Write, ExtPwrON ? "Power-ON by ext. power\n":"Power-ON by Power-ON button\n"); + if(ExtPwrON) + { Format_String(CONS_UART_Write, "Power-ON by ext. power\n"); + if(!Parameters.PowerON) + { AXP.setLED(4); + vTaskDelay(500); + AXP.setPowerOutput(AXP.OUT_LDO2, 0); // turn off RFM power + AXP.setPowerOutput(AXP.OUT_LDO3, 0); // turn off GPS power + AXP.setPowerOutput(AXP.OUT_DCDC1, 0); + AXP.ShutDown(); + vTaskDelay(1000); } + } + else + { Format_String(CONS_UART_Write, "Power-ON button\n"); + if(!Parameters.PowerON) { Parameters.PowerON=1; Parameters.WriteToNVS(); } + } + xSemaphoreGive(CONS_Mutex); +#endif #ifdef WITH_SD if(SD_isMounted()) // if SD card succesfully mounted at startup { Parameters.SaveToFlash=0; diff --git a/main/ogn.h b/main/ogn.h index c7873d7..0689b81 100644 --- a/main/ogn.h +++ b/main/ogn.h @@ -683,7 +683,7 @@ class GPS_Time void setDefaultDate() { Year=00; Month=1; Day=1; } // default Date is 01-JAN-2000 void setDefaultTime() { Hour=0; Min=0; Sec=0; mSec=0; } // default Time is 00:00:00.00 - uint8_t FormatDate(char *Out, char Sep='.') const + uint8_t FormatDate_DDMMYY(char *Out, char Sep='.') const { uint8_t Len=0; Len+=Format_UnsDec(Out+Len, (uint32_t)Day, 2); Out[Len++]=Sep; @@ -692,6 +692,17 @@ class GPS_Time Len+=Format_UnsDec(Out+Len, (uint32_t)Year, 2); Out[Len]=0; return Len; } + uint8_t FormatDate_YYYYMMDD(char *Out, char Sep='.') const + { uint8_t Len=0; + Out[Len++]='2'; + Out[Len++]='0'; + Len+=Format_UnsDec(Out+Len, Year, 2); + Out[Len++]=Sep; + Len+=Format_UnsDec(Out+Len, Month, 2); + Out[Len++]=Sep; + Len+=Format_UnsDec(Out+Len, Day, 2); + Out[Len]=0; return Len; } + uint8_t FormatTime(char *Out, char Sep=':') const { uint8_t Len=0; Len+=Format_UnsDec(Out+Len, (uint32_t)Hour, 2); @@ -815,6 +826,9 @@ class GPS_Time setUnixTime(Time); mSec = Time_ms-(uint64_t)Time*1000; } + void setUnixTime(double Time) + { setUnixTime_ms((uint64_t)floor(Time*1e3)); } + uint64_t getUnixTime_ms(void) const { return (uint64_t)getUnixTime()*1000 + mSec; } @@ -920,8 +934,11 @@ class GPS_Position: public GPS_Time } ; } ; - // uint16_t SatSNRsum; // sum of cSNR from GPGSV - // uint8_t SatSNRcount; // count of satellites from GPGSV + uint16_t SatSNRsum; // [dB] temporary sum of cSNR from GPGSV + uint8_t SatSNRcount; // temporary count of satellites from GPGSV + uint8_t SatSNRgsv; // temporary number of GSV + uint8_t SatSNR; // [0.25dB] average satellites SNR + uint8_t SatSNRnum; // [sats] number of satellites int8_t FixQuality; // 0 = none, 1 = GPS, 2 = Differential GPS (can be WAAS) int8_t FixMode; // 0 = not set (from GSA) 1 = none, 2 = 2-D, 3 = 3-D @@ -966,7 +983,7 @@ class GPS_Position: public GPS_Time void Clear(void) { Flags=0; FixQuality=0; FixMode=0; PDOP=0; HDOP=0; VDOP=0; - // SatSNRsum=0; SatSNRcount=0; + SatSNRsum=0; SatSNRcount=0; SatSNR=0; SatSNRnum=0; SatSNRgsv=0; setDefaultDate(); setDefaultTime(); Latitude=0; Longitude=0; LatitudeCosine=3000; Altitude=0; GeoidSeparation=0; @@ -1122,10 +1139,10 @@ class GPS_Position: public GPS_Time int8_t ReadNMEA(const char *NMEA) { int Err=0; - Err=ReadGGA(NMEA); if(Err!=(-1)) return Err; + Err=ReadGSV(NMEA); if(Err!=(-1)) return Err; + Err=ReadGGA(NMEA); if(Err!=(-1)) { calcSatSNR(); return Err; } Err=ReadGSA(NMEA); if(Err!=(-1)) return Err; - Err=ReadRMC(NMEA); if(Err!=(-1)) return Err; - // Err=ReadGSV(NMEA); if(Err!=(-1)) return Err; + Err=ReadRMC(NMEA); if(Err!=(-1)) { calcSatSNR(); return Err; } return 0; } int8_t ReadPGRMZ(NMEA_RxMsg &RxMsg) @@ -1285,17 +1302,33 @@ class GPS_Position: public GPS_Time ReadHDOP(GSA+Index[15]); ReadVDOP(GSA+Index[16]); NMEAframes++; return 1; } -/* + int8_t ReadGSV(NMEA_RxMsg &RxMsg) { // return 1; } int8_t ReadGSV(const char *GSV) - { if( (memcmp(GSV, "$GPGSV", 6)!=0) && (memcmp(GSV, "$GNGSV", 6)!=0) ) return -1; // check if the right sequence - uint8_t Index[24]; if(IndexNMEA(Index, GSV)<20) return -2; // index parameters and check the sum - // - return 1; } -*/ + { if(GSV[0]!='$') return -1; + if(memcmp(GSV+3, "GSV", 3)!=0) return -1; + if(GSV[1]!='G' && GSV[1]!='B') return -1; + uint8_t Index[24]; int8_t Parms=IndexNMEA(Index, GSV); + if(Parms<3) return -2; // index parameters and check the sum + for( int Parm=3; Parm0; // read time and check if same as the GGA says diff --git a/main/ogn1.h b/main/ogn1.h index 34418a3..35ce32d 100644 --- a/main/ogn1.h +++ b/main/ogn1.h @@ -811,7 +811,8 @@ class OGN1_Packet // Packet structure for the OGN tracker void clrBaro(void) { Position.BaroMSB=0; Position.BaroAltDiff=0; } int16_t getBaroAltDiff(void) const { int16_t AltDiff=Position.BaroAltDiff; if(Position.BaroMSB==0) AltDiff|=0xFF00; return AltDiff; } void setBaroAltDiff(int32_t AltDiff) - { if(AltDiff<(-255)) AltDiff=(-255); else if(AltDiff>255) AltDiff=255; + { // if(AltDiff<(-255)) AltDiff=(-255); else if(AltDiff>255) AltDiff=255; + if(AltDiff<(-255) || AltDiff>255) { clrBaro(); return; } Position.BaroMSB = (AltDiff&0xFF00)==0; Position.BaroAltDiff=AltDiff&0xFF; } void EncodeStdAltitude(int32_t StdAlt) { setBaroAltDiff((StdAlt-DecodeAltitude())); } int32_t DecodeStdAltitude(void) const { return (DecodeAltitude()+getBaroAltDiff()); } diff --git a/main/ognconv.cpp b/main/ognconv.cpp index 2b2c6b2..371393b 100644 --- a/main/ognconv.cpp +++ b/main/ognconv.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "format.h" #include "ognconv.h" @@ -411,3 +412,55 @@ int APRS2IGC(char *Out, const char *Inp, int GeoidSepar) // convert Out[Len++]='\n'; Out[Len]=0; return Len; } // add NL, terminator and return length og the string // ============================================================================================== + +// https://en.wikipedia.org/wiki/Barometric_formula +// https://www.engineeringtoolbox.com/standard-atmosphere-d_604.html + +const float g0 = 9.80665; +const float M = 0.0289644; +const float R = 8.3144598; + +static float BaroAlt(float P, float hb, float Pb, float Tb, float Lb, float gb=g0) +{ if(Lb==0) return hb - logf(P/Pb)*(R*Tb)/(gb*M); + return hb + Tb/Lb*(1-powf(P/Pb, (R*Lb)/(gb*M))); } + +static float BaroPress(float h, float hb, float Pb, float Tb, float Lb, float gb=g0) +{ if(Lb==0) return Pb*expf(-(gb*M/R)*(h-hb)/Tb); + return Pb*powf( (Tb-(h-hb)*Lb)/Tb, (gb*M)/(R*Lb)); } + +static class BaroRef +{ public: + float hb, Pb, Tb, Lb, gb; +} BaroRefTable[7] = +{ // [m] [Pa] [K] [K/m] [m/s^2] + { 0, 101325.00, 288.15, 0.0065, 9.807 }, + { 11000, 22632.10, 216.65, 0 , 9.776 }, + { 20000, 5474.89, 216.65, -0.0010, 9.745 }, + { 32000, 868.02, 228.65, -0.0028, 9.715 }, + { 47000, 110.91, 270.65, 0 , 9.654 }, + { 51000, 66.94, 270.65, 0.0028, 9.654 }, + { 71000, 3.96, 214.65, 0.0020, 9.594 } +} ; + +float BaroTemp(float h) // temperature [K] at given altitude [m] +{ int Idx=0; + for( ; Idx<6; Idx++) + { if(hBaroRefTable[Idx+1].Pb) break; } + BaroRef &Ref = BaroRefTable[Idx]; + return BaroAlt(P, Ref.hb, Ref.Pb, Ref.Tb, Ref.Lb /* , Ref.gb */ ); } + +// ============================================================================================== diff --git a/main/ognconv.h b/main/ognconv.h index 3de1106..7d63111 100644 --- a/main/ognconv.h +++ b/main/ognconv.h @@ -107,4 +107,8 @@ uint8_t DecodeAscii85(uint32_t &Word, const char *Ascii); // Decode 5-char Asc int APRS2IGC(char *Out, const char *Inp, int GeoidSepar); // convert APRS message to IGC B-record +float BaroTemp(float h); // temperature [K] at given altitude [m] +float BaroPress(float h); // pressure [Pa] at given altitude [m] +float BaroAlt(float P); // altitude [m] for given pressure [Pa] + #endif // __OGNCONV_H__ diff --git a/main/parameters.h b/main/parameters.h index 63be6d4..65ff585 100644 --- a/main/parameters.h +++ b/main/parameters.h @@ -48,6 +48,7 @@ class FlashParameters int8_t TxPower: 6; // [dBm] highest bit set => HW module (up to +20dBm Tx power) bool RFchipTypeHW: 1; // is this RFM69HW (Tx power up to +20dBm) ? uint8_t FreqPlan: 3; // 0=default or force given frequency hopping plan + bool RelayMode: 1; // Static relay-mode: rarely transmit own position, priority to relays or other aircrafts } ; } ; @@ -69,14 +70,16 @@ class FlashParameters { uint16_t Flags; struct { bool SaveToFlash:1; // Save parameters from the config file to Flash - bool hasBT:1; // has BT interface on the console - bool BT_ON:1; // BT on after power up + bool PowerON :1; + bool SpareBit :1; + // bool hasBT:1; // has BT interface on the console + // bool BT_ON:1; // BT on after power up bool manGeoidSepar:1; // GeoidSepar is manually configured as the GPS or MAVlink are not able to deliver it bool Encrypt:1; // encrypt the position packets uint8_t NavMode:3; // GPS navigation mode/model uint8_t Verbose:2; // uint8_t NavRate:3; // [Hz] GPS position report rate - int8_t TimeCorr:3; // [sec] it appears for ArduPilot you need to correct time by 3 seconds which is likley the leap-second issue + int8_t TimeCorr:3; // [sec] it appears for ArduPilot you need to correct time by 3 seconds which is likely the leap-second issue } ; } ; // @@ -268,6 +271,8 @@ uint16_t StratuxPort; PressCorr = 0; // [0.25Pa] TimeCorr = 0; // [sec] + PowerON = 1; + FreqPlan = DEFAULT_FreqPlan; // [0..5] PPSdelay = DEFAULT_PPSdelay; // [ms] PageMask = 0xFFFF; @@ -495,7 +500,7 @@ uint16_t StratuxPort; Len+=Format_String(Line+Len, " SX1262"); #endif Line[Len++]='/'; - Len+=Format_SignDec(Line+Len, (int16_t)TxPower); + Len+=Format_SignDec(Line+Len, (int32_t)TxPower); Len+=Format_String(Line+Len, "dBm"); Line[Len++]=' '; Len+=Format_SignDec(Line+Len, (int32_t)RFchipFreqCorr, 2, 1); Len+=Format_String(Line+Len, "ppm"); Len+=Format_String(Line+Len, " CON:"); @@ -521,7 +526,7 @@ uint16_t StratuxPort; Len+=Format_String(Line+Len, ",FreqPlan="); Line[Len++]='0'+FreqPlan; Len+=Format_String(Line+Len, ",TxPower="); - Len+=Format_SignDec(Line+Len, (int16_t)TxPower); + Len+=Format_SignDec(Line+Len, (int32_t)TxPower); Len+=NMEA_AppendCheckCRNL(Line, Len); Line[Len]=0; return Len; } diff --git a/main/proc.cpp b/main/proc.cpp index ddd1830..aef50a9 100644 --- a/main/proc.cpp +++ b/main/proc.cpp @@ -410,7 +410,7 @@ static void ProcessRxPacket(OGN_RxPacket *RxPacket, uint8_t RxPacket if(Signif || Warn) IGClog_FIFO.Write(*RxPacket); #endif #ifdef WITH_PFLAA - if( Parameters.Verbose // print PFLAA on the console for received packets + if( Parameters.Verbose // print PFLAA on the console for received packets #ifdef WITH_LOOKOUT && (!Tgt) #endif @@ -646,16 +646,17 @@ void vTaskPROC(void* pvParameters) else { RF_TxFIFO.Write(); // complete the write into the TxFIFO #ifdef WITH_ADSL - ADSL_Packet *Packet = ADSL_TxFIFO.getWrite(); - Packet->Init(); - Packet->setAddress (Parameters.Address); - Packet->setAddrTypeOGN(Parameters.AddrType); - Packet->setRelay(0); - Packet->setAcftTypeOGN(Parameters.AcftType); - Position->Encode(*Packet); - Packet->Scramble(); // this call hangs when -Os is used to compile - Packet->setCRC(); - ADSL_TxFIFO.Write(); + if(RF_FreqPlan.Plan<=1) // ADS-L only in Europe/Africa + { ADSL_Packet *Packet = ADSL_TxFIFO.getWrite(); + Packet->Init(); + Packet->setAddress (Parameters.Address); + Packet->setAddrTypeOGN(Parameters.AddrType); + Packet->setRelay(0); + Packet->setAcftTypeOGN(Parameters.AcftType); + Position->Encode(*Packet); + Packet->Scramble(); + Packet->setCRC(); + ADSL_TxFIFO.Write(); } #endif TxBackOff = 0; bool FloatAcft = Parameters.AcftType==3 || ( Parameters.AcftType>=0xB && Parameters.AcftType<=0xD); @@ -666,7 +667,7 @@ void vTaskPROC(void* pvParameters) static uint8_t FNTbackOff=0; if(FNTbackOff) FNTbackOff--; // if( (SlotTime&0x07)==(RX_Random&0x07) ) // every 8sec - else + else if(RF_FreqPlan.Plan<=1) { FANET_Packet *Packet = FNT_TxFIFO.getWrite(); Packet->setAddress(Parameters.Address); Position->EncodeAirPos(*Packet, Parameters.AcftType, !Parameters.Stealth); diff --git a/main/rf.cpp b/main/rf.cpp index 93b2335..234167c 100644 --- a/main/rf.cpp +++ b/main/rf.cpp @@ -733,13 +733,13 @@ extern "C" #ifdef WITH_LORAWAN bool WANtx = 0; if(WAN_BackOff) WAN_BackOff--; - else if(Parameters.TxPower!=(-32)) // decide to transmit in this slot + else if(RF_FreqPlan.Plan<=1 && Parameters.TxPower!=(-32)) // decide to transmit in this slot { if(WANdev.State==0 || WANdev.State==2) // { WANtx=1; SlotEnd=1220; } } #endif #ifdef WITH_ADSL - if(ADSL_Slot==1 && ADSL_TxPkt) + if(RF_FreqPlan.Plan<=1 && ADSL_Slot==1 && ADSL_TxPkt) TimeSlot(TxChan, SlotEnd-TimeSync_msTime(), ADSL_TxPkt, TRX.averRSSI, 0, TxTime); else #endif @@ -750,7 +750,7 @@ extern "C" #ifdef WITH_LORAWAN if(!WANtx && TxPkt0 && TxPkt0->Packet.Header.AddrType && WANdev.State!=1 && WANdev.State!=3) // if no WAN transmission/reception scheduled #else - if(TxPkt0 && TxPkt0->Packet.Header.AddrType) + if(RF_FreqPlan.Plan<=1 && TxPkt0 && TxPkt0->Packet.Header.AddrType) #endif { PAW_Packet Packet; Packet.Clear(); OGN1_Packet TxPkt = TxPkt0->Packet; diff --git a/main/sens.cpp b/main/sens.cpp index a162036..c60ce0b 100644 --- a/main/sens.cpp +++ b/main/sens.cpp @@ -181,7 +181,8 @@ static void ProcBaro(void) Noise=(IntSqrt(25*Noise)+64)>>7; // [0.1 Pa] noise (RMS) measured on the pressure int32_t Pressure=BaroPipe.Aver; // [1/16Pa] - int32_t StdAltitude = Atmosphere::StdAltitude((Pressure+8)>>4); // [0.1 m] + // int32_t StdAltitude = Atmosphere::StdAltitude((Pressure+8)>>4); // [0.1 m] + int32_t StdAltitude = floorf(BaroAlt((1.0f/16)*Pressure)*10+0.5); int32_t ClimbRate4sec = ((Pressure-PressDelay.Input(Pressure))*PLR)/3200; // [0.01m/sec] climb rate over 4 sec. #ifdef WITH_VARIO VarioSound(ClimbRate);