Skip to content

Commit

Permalink
Merge pull request #1 from pjalocha/master
Browse files Browse the repository at this point in the history
update to last change
  • Loading branch information
Fab501 authored Feb 1, 2021
2 parents 5b2e39f + 0ea2e24 commit 37ca198
Show file tree
Hide file tree
Showing 10 changed files with 331 additions and 124 deletions.
13 changes: 11 additions & 2 deletions main/hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ GPIO HELTEC TTGO JACEK M5_JACEK T-Beam T-Beamv10 Foll
#ifdef WITH_TBEAM_V10
#define PIN_RFM_RST GPIO_NUM_23 // Reset 23
#define PIN_RFM_IRQ GPIO_NUM_26 // packet done on receive or transmit
#ifdef WITH_SX1262
#define PIN_RFM_BUSY GPIO_NUM_32 // for the T-Beam with SX1262
#endif
#define PIN_RFM_SS GPIO_NUM_18 // SPI chip-select
#define PIN_RFM_SCK GPIO_NUM_5 // SPI clock
#define PIN_RFM_MISO GPIO_NUM_19 // SPI MISO
Expand Down Expand Up @@ -910,7 +913,7 @@ void RFM_RESET_SetInput (void) { gpio_set_direction(PIN_RFM_RST, GPIO_M
void RFM_RESET_SetOutput (void) { gpio_set_direction(PIN_RFM_RST, GPIO_MODE_OUTPUT); }
void RFM_RESET_SetLevel (uint8_t High) { gpio_set_level(PIN_RFM_RST, High&1); }

#ifdef WITH_RFM95 // for RFM95 reset is low-active
#if defined(WITH_RFM95) || defined(WITH_SX1272) || defined(WITH_SX1262) // for RFM95 reset is low-active
void RFM_RESET(uint8_t On) { if(On&1) { RFM_RESET_SetOutput(); RFM_RESET_SetLevel(0); } else RFM_RESET_SetInput(); }
#endif

Expand All @@ -925,7 +928,10 @@ void RFM_RESET(uint8_t On) { }

void RFM_IRQ_SetInput(void) { gpio_set_direction(PIN_RFM_IRQ, GPIO_MODE_INPUT); }
bool RFM_IRQ_isOn(void) { return gpio_get_level(PIN_RFM_IRQ); }

#ifdef WITH_SX1262
void RFM_Busy_SetInput(void) { gpio_set_direction(PIN_RFM_BUSY, GPIO_MODE_INPUT); }
bool RFM_Busy_isOn(void) { return gpio_get_level(PIN_RFM_BUSY); }
#endif
void RFM_Delay(int ms) { vTaskDelay(ms); }

static spi_device_handle_t RFM_SPI;
Expand Down Expand Up @@ -1864,6 +1870,9 @@ void IO_Configuration(void)
#endif

RFM_IRQ_SetInput();
#ifdef WITH_SX1262
RFM_Busy_SetInput();
#endif
RFM_RESET_SetOutput();
RFM_RESET(0);

Expand Down
4 changes: 4 additions & 0 deletions main/hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ void RFM_TransferBlock(uint8_t *Data, uint8_t Len);
void RFM_RESET(uint8_t On); // RF module reset
bool RFM_IRQ_isOn(void); // query the IRQ state
void RFM_Delay(int ms); // [ms] idle delay
#ifdef WITH_SX1262
void RFM_Busy_SetInput(void);
bool RFM_Busy_isOn(void);
#endif

#ifdef WITH_OLED
int OLED_DisplayON(uint8_t ON, uint8_t DispIdx=0); // when OFF then low-power mode
Expand Down
9 changes: 8 additions & 1 deletion main/nmea.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ inline uint8_t NMEA_AppendCheckCRNL(char *NMEA, uint8_t Len) { return NMEA_Appen
if(Data[4]!='X') return 0;
return Data[5]=='T'; }

uint8_t isP(void) const
uint8_t isP(void) const // Private thus specific to the euqipment
{ return Data[1]=='P'; }

uint8_t isPOGN(void) const // OGN dedicated NMEA sentence
Expand All @@ -220,6 +220,13 @@ inline uint8_t NMEA_AppendCheckCRNL(char *NMEA, uint8_t Len) { return NMEA_Appen
{ if(!isPOGN()) return 0;
return Data[5]=='S'; }

uint8_t isPGRMZ(void) // barometric pressure report
{ if(!isP()) return 0;
if(Data[2]!='G') return 0;
if(Data[3]!='R') return 0;
if(Data[4]!='M') return 0;
return Data[5]=='Z'; }

uint8_t isPOGNL(void) // log file list request
{ if(!isPOGN()) return 0;
return Data[5]=='L'; }
Expand Down
31 changes: 24 additions & 7 deletions main/ogn.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ template <class OGNx_Packet=OGN1_Packet>
Len+=Format_SignDec(Out+Len, -(int16_t)RxRSSI/2); Out[Len++]='d'; Out[Len++]='B'; Out[Len++]='m';
Out[Len++]=' ';
Len+=Format_UnsDec(Out+Len, (uint16_t)Packet.Position.Time, 2);
Out[Len++]=' ';
Out[Len++]='s'; Out[Len++]=' ';
Len+=Format_Latitude(Out+Len, Packet.DecodeLatitude());
Out[Len++]=' ';
Len+=Format_Longitude(Out+Len, Packet.DecodeLongitude());
Expand All @@ -482,6 +482,9 @@ template <class OGNx_Packet=OGN1_Packet>
Len+=Format_UnsDec(Out+Len, Packet.DecodeSpeed(), 2, 1); Out[Len++]='m'; Out[Len++]='/'; Out[Len++]='s';
Out[Len++]=' ';
Len+=Format_SignDec(Out+Len, Packet.DecodeClimbRate(), 2, 1); Out[Len++]='m'; Out[Len++]='/'; Out[Len++]='s';
Out[Len++]=' ';
Out[Len++]='r';
Len+=Format_Hex(Out+Len, Rank);
Out[Len++]='\n'; Out[Len]=0;
return Len; }

Expand Down Expand Up @@ -984,6 +987,8 @@ class GPS_Position: public GPS_Time
Out[Len++]='/'; Len+=Format_SignDec(Out+Len, GeoidSeparation, 4, 1); Out[Len++]='m';
Out[Len++]=' '; Len+=Format_UnsDec(Out+Len, Speed, 2, 1); Out[Len++]='m'; Out[Len++]='/'; Out[Len++]='s';
Out[Len++]=' '; Len+=Format_UnsDec(Out+Len, Heading, 4, 1); Out[Len++]='d'; Out[Len++]='e'; Out[Len++]='g';
Out[Len++]=' '; Len+=Format_SignDec(Out+Len, ClimbRate, 2, 1); Out[Len++]='m'; Out[Len++]='/'; Out[Len++]='s';
Out[Len++]=' '; Len+=Format_SignDec(Out+Len, TurnRate, 2, 1); Out[Len++]='d'; Out[Len++]='e'; Out[Len++]='g'; Out[Len++]='/'; Out[Len++]='s';
if(hasBaro)
{ Out[Len++]=' '; Len+=Format_SignDec(Out+Len, Temperature, 2, 1); Out[Len++]='C';
Out[Len++]=' '; Len+=Format_UnsDec(Out+Len, Pressure/4 ); Out[Len++]='P'; Out[Len++]='a';
Expand Down Expand Up @@ -1030,12 +1035,13 @@ class GPS_Position: public GPS_Time
return 1; }

int8_t ReadNMEA(NMEA_RxMsg &RxMsg)
{ if(RxMsg.isGPGGA()) return ReadGGA(RxMsg);
if(RxMsg.isGNGGA()) return ReadGGA(RxMsg);
if(RxMsg.isGPRMC()) return ReadRMC(RxMsg);
if(RxMsg.isGNRMC()) return ReadRMC(RxMsg);
if(RxMsg.isGPGSA()) return ReadGSA(RxMsg);
if(RxMsg.isGNGSA()) return ReadGSA(RxMsg);
{ // if(RxMsg.isGPGGA()) return ReadGGA(RxMsg);
if(RxMsg.isGxGGA()) return ReadGGA(RxMsg);
// if(RxMsg.isGPRMC()) return ReadRMC(RxMsg);
if(RxMsg.isGxRMC()) return ReadRMC(RxMsg);
// if(RxMsg.isGPGSA()) return ReadGSA(RxMsg);
if(RxMsg.isGxGSA()) return ReadGSA(RxMsg);
if(RxMsg.isPGRMZ()) return ReadPGRMZ(RxMsg); // (pressure) altitude
// if(RxMsg.isGxGSV()) return ReadGSV(RxMsg);
return 0; }

Expand All @@ -1047,6 +1053,17 @@ class GPS_Position: public GPS_Time
// Err=ReadGSV(NMEA); if(Err!=(-1)) return Err;
return 0; }

int8_t ReadPGRMZ(NMEA_RxMsg &RxMsg)
{ if(RxMsg.Parms<3) return -2;
int8_t Ret=Read_Float1(StdAltitude, (const char *)(RxMsg.ParmPtr(0)));
if(Ret<=0) return -1;
char Unit=RxMsg.ParmPtr(1)[0];
hasBaro=1; Pressure=0; Temperature=0;
if(Unit=='m' || Unit=='M') return 1;
if(Unit!='f' && Unit!='F') return -1;
StdAltitude = (StdAltitude*312+512)>>10;
return 1; }

int8_t ReadGGA(NMEA_RxMsg &RxMsg)
{ if(RxMsg.Parms<14) return -2; // no less than 14 paramaters
hasGPS = ReadTime((const char *)RxMsg.ParmPtr(0))>0; // read time and check if same as the RMC says
Expand Down
14 changes: 8 additions & 6 deletions main/ogn1.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,12 @@ class OGN1_Packet // Packet structure for the OGN tracker
Len+=Format_UnsDec(JSON+Len, DecodeHeading(), 2, 1);
Len+=Format_String(JSON+Len, ",\"speed_mps\":");
Len+=Format_UnsDec(JSON+Len, DecodeSpeed(), 2, 1);
Len+=Format_String(JSON+Len, ",\"climb_mps\":");
Len+=Format_SignDec(JSON+Len, DecodeClimbRate(), 2, 1, 1);
Len+=Format_String(JSON+Len, ",\"turn_dps\":");
Len+=Format_SignDec(JSON+Len, DecodeTurnRate(), 2, 1, 1);
if(hasClimbRate())
{ Len+=Format_String(JSON+Len, ",\"climb_mps\":");
Len+=Format_SignDec(JSON+Len, DecodeClimbRate(), 2, 1, 1); }
if(hasTurnRate())
{ Len+=Format_String(JSON+Len, ",\"turn_dps\":");
Len+=Format_SignDec(JSON+Len, DecodeTurnRate(), 2, 1, 1); }
Len+=Format_String(JSON+Len, ",\"DOP\":");
Len+=Format_UnsDec(JSON+Len, 10+DecodeDOP(), 2, 1); }
if(!Header.Encrypted && Header.NonPos) // non-encrypted status and info
Expand Down Expand Up @@ -746,7 +748,7 @@ class OGN1_Packet // Packet structure for the OGN tracker
{ return (uint16_t)Position.Heading<<6; }

void clrTurnRate(void) { Position.TurnRate=0x80; } // mark turn-rate as absent
bool hasTurnRate(void) const { return Position.TurnRate==0x80; }
bool hasTurnRate(void) const { return Position.TurnRate!=0x80; }

void EncodeTurnRate(int16_t Turn) // [0.1 deg/sec]
{ Position.TurnRate = EncodeSR2V5(Turn); }
Expand All @@ -755,7 +757,7 @@ class OGN1_Packet // Packet structure for the OGN tracker
{ return DecodeSR2V5(Position.TurnRate); }

void clrClimbRate(void) { Position.ClimbRate=0x100; } // mark climb rate as absent
bool hasClimbRate(void) const { return Position.ClimbRate==0x100; }
bool hasClimbRate(void) const { return Position.ClimbRate!=0x100; }

void EncodeClimbRate(int16_t Climb)
{ Position.ClimbRate = EncodeSR2V6(Climb); }
Expand Down
5 changes: 2 additions & 3 deletions main/paw.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,12 @@ class PAW_Packet
{ OGN=1; // extended data flag
AddrType = Packet.Header.AddrType; // [2-bit]
Relay = Packet.Header.Relay; // relay flag
// Time = Packet.Position.Time; // [sec]
Time = Packet.Position.Time; // [sec]
int32_t ClimbRate = Packet.DecodeClimbRate(); // [0.1m/s]
ClimbRate = (ClimbRate*315+512)>>10; // [64fpm]
if(ClimbRate>127) ClimbRate=127;
else if(ClimbRate<(-127)) ClimbRate=(-127);
Climb = ClimbRate;
}
Climb = ClimbRate; }
SeqMsg = 0;
setCRC(); return 1; }

Expand Down
Loading

0 comments on commit 37ca198

Please sign in to comment.