kopia lustrzana https://github.com/pjalocha/esp32-ogn-tracker
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)
rodzic
27ca3b6283
commit
3158945266
47
main/adsl.h
47
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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
59
main/ogn.h
59
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; Parm<Parms; ) // up to 4 sats per packet
|
||||
{ int8_t PRN =Read_Dec2(GSV+Index[Parm++]); if(PRN<=0) break; // PRN number
|
||||
int8_t Elev=Read_Dec2(GSV+Index[Parm++]); if(Elev<0) break; // [deg] elevation
|
||||
int16_t Azim=Read_Dec3(GSV+Index[Parm++]); if(Azim<0) break; // [deg] azimuth
|
||||
int8_t SNR =Read_Dec2(GSV+Index[Parm++]); if(SNR<=0) continue; // [dB] SNR or absent when not tracked
|
||||
SatSNRsum+=SNR; SatSNRcount++; }
|
||||
SatSNRgsv++; return 1; }
|
||||
|
||||
void calcSatSNR(void)
|
||||
{ if(SatSNRgsv==0) return;
|
||||
if(SatSNRcount) SatSNR=(SatSNRsum*4+SatSNRcount/2)/SatSNRcount;
|
||||
else SatSNR=0;
|
||||
SatSNRnum=SatSNRcount;
|
||||
SatSNRcount=0; SatSNRsum=0;
|
||||
SatSNRgsv=0; }
|
||||
|
||||
int ReadRMC(NMEA_RxMsg &RxMsg)
|
||||
{ if(RxMsg.Parms<11) return -2; // no less than 12 parameters
|
||||
hasGPS = ReadTime((const char *)RxMsg.ParmPtr(0))>0; // read time and check if same as the GGA says
|
||||
|
|
|
@ -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()); }
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#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(h<BaroRefTable[Idx+1].hb) break; }
|
||||
BaroRef &Ref = BaroRefTable[Idx];
|
||||
return Ref.Tb - (h-Ref.hb)*Ref.Lb; } // [K]
|
||||
|
||||
float BaroPress(float h) // pressure [Pa] at given altitude [m]
|
||||
{ int Idx=0;
|
||||
for( ; Idx<6; Idx++)
|
||||
{ if(h<BaroRefTable[Idx+1].hb) break; }
|
||||
BaroRef &Ref = BaroRefTable[Idx];
|
||||
return BaroPress(h, Ref.hb, Ref.Pb, Ref.Tb, Ref.Lb /* , Ref.gb */ ); }
|
||||
|
||||
float BaroAlt(float P) // altitude [m] for given pressure [Pa]
|
||||
{ int Idx=0;
|
||||
for( ; Idx<6; Idx++)
|
||||
{ if(P>BaroRefTable[Idx+1].Pb) break; }
|
||||
BaroRef &Ref = BaroRefTable[Idx];
|
||||
return BaroAlt(P, Ref.hb, Ref.Pb, Ref.Tb, Ref.Lb /* , Ref.gb */ ); }
|
||||
|
||||
// ==============================================================================================
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
|
@ -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();
|
||||
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(); // this call hangs when -Os is used to compile
|
||||
Packet->Scramble();
|
||||
Packet->setCRC();
|
||||
ADSL_TxFIFO.Write();
|
||||
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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Ładowanie…
Reference in New Issue