diff --git a/main/gps.cpp b/main/gps.cpp index 1232bc1..e1ae3a4 100644 --- a/main/gps.cpp +++ b/main/gps.cpp @@ -461,7 +461,7 @@ static void GPS_BurstComplete(void) // wh } uint8_t NextPosIdx = (PosIdx+1)&PosPipeIdxMask; // next position to be recorded if( Position[PosIdx].isTimeValid() && Position[NextPosIdx].isTimeValid() ) - { int16_t Period = Position[PosIdx].calcTimeDiff(Position[NextPosIdx]); + { int32_t Period = Position[PosIdx].calcTimeDiff(Position[NextPosIdx]); if(Period>0) GPS_PosPeriod = (Period+GPS_PosPipeSize/2)/(GPS_PosPipeSize-1); #ifdef DEBUG_PRINT xSemaphoreTake(CONS_Mutex, portMAX_DELAY); @@ -475,7 +475,6 @@ static void GPS_BurstComplete(void) // wh Format_String(CONS_UART_Write, "s\n"); xSemaphoreGive(CONS_Mutex); #endif - } Position[NextPosIdx].Clear(); // clear the next position // int8_t Sec = Position[PosIdx].Sec; // diff --git a/main/gps.h b/main/gps.h index d95ca7d..c535c47 100644 --- a/main/gps.h +++ b/main/gps.h @@ -7,7 +7,11 @@ #include "lowpass2.h" -const uint8_t GPS_PosPipeSize = 4; // number of GPS positions held in a pipe +#ifdef WITH_ESP32 +const uint8_t GPS_PosPipeSize = 32; // number of GPS positions held in a pipe +#else +const uint8_t GPS_PosPipeSize = 4; // number of GPS positions held in a pipe +#endif // extern uint8_t GPS_PowerMode; // 0=shutdown, 1=reduced, 2=normal diff --git a/main/ogn.h b/main/ogn.h index cad770c..3f54b60 100644 --- a/main/ogn.h +++ b/main/ogn.h @@ -1018,10 +1018,10 @@ class GPS_Position calcLatitudeCosine(); return 1; } - int16_t calcTimeDiff(GPS_Position &RefPos) const - { int16_t TimeDiff = (FracSec+(int16_t)Sec*100) - (RefPos.FracSec+(int16_t)RefPos.Sec*100); - if(TimeDiff<(-3000)) TimeDiff+=6000; - else if(TimeDiff>=3000) TimeDiff-=6000; + int32_t calcTimeDiff(GPS_Position &RefPos) const + { int32_t TimeDiff = ((int32_t)Min*6000+(int16_t)Sec*100+FracSec) - ((int32_t)RefPos.Min*6000+(int16_t)RefPos.Sec*100+RefPos.FracSec); + if(TimeDiff<(-180000)) TimeDiff+=360000; // wrap-around 60min + else if(TimeDiff>=180000) TimeDiff-=360000; return TimeDiff; } // [0.01s] int16_t calcDifferentials(GPS_Position &RefPos) // calculate climb rate and turn rate with an earlier reference position diff --git a/main/parameters.h b/main/parameters.h index 712efba..2ef250b 100644 --- a/main/parameters.h +++ b/main/parameters.h @@ -48,7 +48,7 @@ class FlashParameters { uint32_t Console; struct { uint32_t CONbaud:24; // [bps] Console baud rate - uint8_t CONprot: 8; // [bit-mask] Console protocol mask: 0=minGPS, 1=allGPS, 2=Baro, 3=UBX, 4=OGN, 5=FLARM, 6=GDL90, 7= + uint8_t CONprot: 8; // [bit-mask] Console protocol mask: 0=minGPS, 1=allGPS, 2=Baro, 3=UBX, 4=OGN, 5=FLARM, 6=GDL90, 7=$PGAV5 } ; } ;