kopia lustrzana https://github.com/pjalocha/esp32-ogn-tracker
Group some RF variable for cleaner structure
rodzic
788312c307
commit
6fb70d356e
|
@ -173,7 +173,7 @@ void OLED_DrawGPS(u8g2_t *OLED, GPS_Position *GPS=0) // GPS time, position, alt
|
|||
Len+=Format_String(Line+Len, "sat DOP");
|
||||
Len+=Format_UnsDec(Line+Len, (uint16_t)GPS->HDOP, 2, 1); }
|
||||
else
|
||||
{ Len+=Format_String(Line+Len, " wait for lock"); }
|
||||
{ Len+=Format_String(Line+Len, "(no lock)"); }
|
||||
Line[Len]=0;
|
||||
u8g2_DrawStr(OLED, 0, 12, Line);
|
||||
if(GPS && GPS->isDateValid())
|
||||
|
@ -235,16 +235,18 @@ void OLED_DrawRF(u8g2_t *OLED) // RF
|
|||
u8g2_DrawStr(OLED, 0, 12, Line);
|
||||
Len=0;
|
||||
Len+=Format_String(Line+Len, "Rx:"); //
|
||||
Len+=Format_SignDec(Line+Len, -5*RX_AverRSSI, 2, 1); // noise level seen by the receiver
|
||||
Len+=Format_SignDec(Line+Len, -5*TRX.averRSSI, 2, 1); // noise level seen by the receiver
|
||||
Len+=Format_String(Line+Len, "dBm ");
|
||||
Len+=Format_UnsDec(Line+Len, RX_OGN_Count64); // received packet/min
|
||||
Len+=Format_String(Line+Len, "/min");
|
||||
Line[Len]=0;
|
||||
u8g2_DrawStr(OLED, 0, 24, Line);
|
||||
Len=0;
|
||||
Len+=Format_SignDec(Line+Len, (int16_t)RF_Temp); // RF chip internal temperature (not calibrated)
|
||||
Line[Len++]=0xB0;
|
||||
Line[Len++]='C';
|
||||
Len+=Format_SignDec(Line+Len, (int16_t)TRX.chipTemp); // RF chip internal temperature (not calibrated)
|
||||
// Line[Len++]=0xB0;
|
||||
// Line[Len++]='C';
|
||||
Len+=Format_String(Line+Len, "\260C RxFIFO:");
|
||||
Len+=Format_UnsDec(Line+Len, RF_RxFIFO.Full()); // how many packets wait in the RX queue
|
||||
Line[Len]=0;
|
||||
u8g2_DrawStr(OLED, 0, 36, Line);
|
||||
// u8g2_DrawStr(OLED, 0, 48, RF_FreqPlan.getPlanName());
|
||||
|
|
|
@ -157,8 +157,8 @@ static void ReadStatus(OGN_Packet &Packet)
|
|||
Packet.EncodeVoltage(((Battery*64)+500)/1000); // [1/64V]
|
||||
#endif
|
||||
|
||||
if(Packet.Status.Pressure==0) Packet.EncodeTemperature(RF_Temp*10); // [0.1degC]
|
||||
Packet.Status.RadioNoise = RX_AverRSSI; // [-0.5dBm] write radio noise to the status packet
|
||||
if(Packet.Status.Pressure==0) Packet.EncodeTemperature(TRX.chipTemp*10); // [0.1degC]
|
||||
Packet.Status.RadioNoise = TRX.averRSSI; // [-0.5dBm] write radio noise to the status packet
|
||||
|
||||
Packet.Status.TxPower = Parameters.getTxPower()-4;
|
||||
|
||||
|
@ -173,11 +173,11 @@ static void ReadStatus(OGN_Packet &Packet)
|
|||
Len+=Format_UnsDec(Line+Len, RX_OGN_Count64); // number of OGN packets received
|
||||
Line[Len++]=',';
|
||||
Line[Len++]=',';
|
||||
Len+=Format_SignDec(Line+Len, -5*RX_AverRSSI, 2, 1); // average RF level (over all channels)
|
||||
Len+=Format_SignDec(Line+Len, -5*TRX.averRSSI, 2, 1); // average RF level (over all channels)
|
||||
Line[Len++]=',';
|
||||
Len+=Format_UnsDec(Line+Len, (uint16_t)TX_Credit);
|
||||
Line[Len++]=',';
|
||||
Len+=Format_SignDec(Line+Len, (int16_t)RF_Temp); // the temperature of the RF chip
|
||||
Len+=Format_SignDec(Line+Len, (int16_t)TRX.chipTemp); // the temperature of the RF chip
|
||||
Line[Len++]=',';
|
||||
// Len+=Format_SignDec(Line+Len, MCU_Temp, 2, 1);
|
||||
Line[Len++]=',';
|
||||
|
|
18
main/rf.cpp
18
main/rf.cpp
|
@ -21,8 +21,8 @@ static const uint8_t *OGN_SYNC = OGN2_SYNC;
|
|||
|
||||
RFM_TRX TRX; // radio transceiver
|
||||
|
||||
uint8_t RX_AverRSSI; // [-0.5dBm] average RSSI
|
||||
int8_t RF_Temp; // [degC] temperature of the RF chip: uncalibrated
|
||||
// uint8_t RX_AverRSSI; // [-0.5dBm] average RSSI
|
||||
// int8_t RF_Temp; // [degC] temperature of the RF chip: uncalibrated
|
||||
|
||||
static uint32_t RF_SlotTime; // [sec] UTC time which belongs to the current time slot (0.3sec late by GPS UTC)
|
||||
FreqPlan RF_FreqPlan; // frequency hopping pattern calculator
|
||||
|
@ -228,9 +228,9 @@ extern "C"
|
|||
vTaskDelay(1);
|
||||
SetFreqPlan();
|
||||
|
||||
RX_AverRSSI=RX_RSSI.getOutput();
|
||||
TRX.averRSSI=RX_RSSI.getOutput();
|
||||
|
||||
RX_OGN_Count64 += RX_OGN_Packets - RX_OGN_CountDelay.Input(RX_OGN_Packets); // add OGN packets received, subtract packets received 64 second$
|
||||
RX_OGN_Count64 += RX_OGN_Packets - RX_OGN_CountDelay.Input(RX_OGN_Packets); // add OGN packets received, subtract packets received 64 seconds ago
|
||||
|
||||
RX_OGN_Packets=0; // clear the received packet count
|
||||
|
||||
|
@ -239,12 +239,12 @@ extern "C"
|
|||
#ifdef WITH_RFM69
|
||||
TRX.TriggerTemp(); // trigger RF chip temperature readout
|
||||
vTaskDelay(1); // while(TRX.RunningTemp()) taskYIELD(); // wait for conversion to be ready
|
||||
RF_Temp= TRX.ReadTemp(); // [degC] read RF chip temperature
|
||||
TRX.ReadTemp(); // [degC] read RF chip temperature
|
||||
#endif
|
||||
#ifdef WITH_RFM95
|
||||
RF_Temp= TRX.ReadTemp(); // [degC] read RF chip temperature
|
||||
TRX.ReadTemp(); // [degC] read RF chip temperature
|
||||
#endif
|
||||
RF_Temp+=Parameters.RFchipTempCorr;
|
||||
TRX.chipTemp+=Parameters.RFchipTempCorr;
|
||||
// Note: on RFM95 temperature sens does not work in STANDBY
|
||||
RF_SlotTime = TimeSync_Time();
|
||||
uint8_t TxChan = RF_FreqPlan.getChannel(RF_SlotTime, 0, 1); // tranmsit channel
|
||||
|
@ -284,7 +284,7 @@ extern "C"
|
|||
{ if( (RX_Channel!=TxChan) && (TxPkt0->Packet.Header.Relay==0) )
|
||||
{ const uint8_t *Tmp=TxPktData0; TxPktData0=TxPktData1; TxPktData1=Tmp; } // swap 1st and 2nd packet data
|
||||
}
|
||||
TimeSlot(TxChan, 800-TimeSync_msTime(), TxPktData0, RX_AverRSSI, 0, TxTime); // run a Time-Slot till 0.800sec
|
||||
TimeSlot(TxChan, 800-TimeSync_msTime(), TxPktData0, TRX.averRSSI, 0, TxTime); // run a Time-Slot till 0.800sec
|
||||
|
||||
TRX.WriteMode(RF_OPMODE_STANDBY); // switch to receive mode
|
||||
TxChan = RF_FreqPlan.getChannel(RF_SlotTime, 1, 1); // transmit channel
|
||||
|
@ -296,7 +296,7 @@ extern "C"
|
|||
XorShift32(RX_Random);
|
||||
TxTime = (RX_Random&0x3F)+1; TxTime*=6;
|
||||
|
||||
TimeSlot(TxChan, 1250-TimeSync_msTime(), TxPktData1, RX_AverRSSI, 0, TxTime);
|
||||
TimeSlot(TxChan, 1250-TimeSync_msTime(), TxPktData1, TRX.averRSSI, 0, TxTime);
|
||||
|
||||
if(TxPkt0) RF_TxFIFO.Read();
|
||||
if(TxPkt1) RF_TxFIFO.Read();
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
extern FIFO<OGN_TxPacket<OGN_Packet>, 4> RF_TxFIFO; // buffer for transmitted packets
|
||||
|
||||
extern uint8_t RX_OGN_Packets; // [packets] counts received packets
|
||||
extern uint8_t RX_AverRSSI; // [-0.5dBm] average RSSI
|
||||
extern int8_t RF_Temp; // [degC] temperature of the RF chip: uncalibrated
|
||||
// extern uint8_t RX_AverRSSI; // [-0.5dBm] average RSSI
|
||||
// extern int8_t RF_Temp; // [degC] temperature of the RF chip: uncalibrated
|
||||
extern RFM_TRX TRX; // RF transceiver
|
||||
extern FreqPlan RF_FreqPlan; // frequency hopping pattern calculator
|
||||
extern uint16_t TX_Credit; // counts transmitted packets vs. time to avoid using more than 1% of the time
|
||||
|
|
|
@ -145,9 +145,6 @@ class RFM_RxPktData // packet received by the RF chip
|
|||
class RFM_TRX
|
||||
{ public: // hardware access functions
|
||||
|
||||
uint8_t chipVer; // [] version ID read from the RF chip
|
||||
int8_t chipTemp; // [degC] temperature read from the RF chip
|
||||
|
||||
#ifdef USE_BLOCK_SPI // SPI transfers in blocks, implicit control of the SPI-select
|
||||
void (*TransferBlock)(uint8_t *Data, uint8_t Len);
|
||||
static const size_t MaxBlockLen = 64;
|
||||
|
@ -180,6 +177,10 @@ class RFM_TRX
|
|||
int16_t FreqCorr; // [0.1ppm]
|
||||
int16_t Channel; // [ integer] channel being used
|
||||
|
||||
uint8_t chipVer; // [] version ID read from the RF chip
|
||||
int8_t chipTemp; // [degC] temperature read from the RF chip
|
||||
uint8_t averRSSI; // [-0.5dB]
|
||||
|
||||
// private:
|
||||
static uint32_t calcSynthFrequency(uint32_t Frequency) { return (((uint64_t)Frequency<<16)+7812)/15625; }
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue