Improved GPS management routine

pull/87/head
Silvano Seva 2022-06-29 17:08:07 +02:00
rodzic 23a1a38a3a
commit 42569af38a
2 zmienionych plików z 25 dodań i 13 usunięć

Wyświetl plik

@ -27,7 +27,7 @@
#define KNOTS2KMH 1.852f
static char sentence[MINMEA_MAX_LENGTH + 1];
static char sentence[2*MINMEA_MAX_LENGTH];
static bool isRtcSyncronised = false;
static bool gpsEnabled = false;
static bool readNewSentence = true;
@ -52,14 +52,22 @@ void gps_taskFunc()
// Acquire a new NMEA sentence from GPS
if(readNewSentence)
{
int status = gps_getNmeaSentence(sentence, MINMEA_MAX_LENGTH + 1);
int status = gps_getNmeaSentence(sentence, 2*MINMEA_MAX_LENGTH);
if(status != 0) return;
readNewSentence = false;
}
// Waiting for a sentence...
if(gps_nmeaSentenceReady() == false)
return;
// Discard all non-GPS sentences
if((sentence[0] != '$') || (sentence[1] != 'G'))
{
readNewSentence = true;
return;
}
// Parse the sentence. Work on a local state copy to minimize the time
// spent with the state mutex locked
gps_t gps_data;

Wyświetl plik

@ -139,26 +139,30 @@ void *dev_task(void *arg)
if(state.gpsDetected) gps_init(9600);
#endif
uint8_t tick_5ms = 0;
while(state.shutdown == false)
{
// Update radio state
state_update();
tick_5ms++;
#if defined(GPS_PRESENT) && !defined(MD3x0_ENABLE_DBG)
if(state.gpsDetected)
{
gps_taskFunc();
}
#endif
// Signal state update to UI thread
event_t dev_msg;
dev_msg.type = EVENT_STATUS;
dev_msg.payload = 0;
ui_pushEvent(dev_msg);
// Update radio state and push an event to the UI every 100ms
if((tick_5ms % 20) == 0)
{
state_update();
// 10Hz update rate
sleepFor(0u, 100u);
event_t dev_msg;
dev_msg.type = EVENT_STATUS;
dev_msg.payload = 0;
ui_pushEvent(dev_msg);
}
// Run this loop once every 5ms
sleepFor(0u, 5u);
}
#if defined(GPS_PRESENT)