core: gps: added field for HDOP to GPS data

HDOP is expressed in cm, meaning that an HDOP of 1.37m is stored as 137 in
the GPS data structure.
codec2-noise-fix
Silvano Seva 2025-08-21 16:56:18 +02:00
rodzic e738e18d16
commit 2f0b7f8df7
3 zmienionych plików z 16 dodań i 1 usunięć

Wyświetl plik

@ -271,6 +271,20 @@ static inline int minmea_toint(struct minmea_float *f)
return f->value / f->scale; return f->value / f->scale;
} }
/**
* Convert a fixed-point value to an integer value, applying an additional
* scaling factor.
* Returns zero for "unknown" values.
*/
static inline int minmea_toscaledint(struct minmea_float *f, const int scale)
{
if(f->scale == 0)
return 0;
int_least32_t tmp = f->value * scale;
return tmp / f->scale;
}
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

Wyświetl plik

@ -54,6 +54,7 @@ typedef struct
uint16_t speed; // Ground speed in km/h uint16_t speed; // Ground speed in km/h
int16_t tmg_mag; // Course over ground, degrees, magnetic int16_t tmg_mag; // Course over ground, degrees, magnetic
int16_t tmg_true; // Course over ground, degrees, true int16_t tmg_true; // Course over ground, degrees, true
uint16_t hdop; // Horizontal dilution of precision, in cm
} }
gps_t; gps_t;

Wyświetl plik

@ -87,7 +87,6 @@ void gps_task(const struct gpsDevice *dev)
gps_data.timestamp.year = frame.date.year; gps_data.timestamp.year = frame.date.year;
} }
gps_data.tmg_true = minmea_tofloat(&frame.course);
gps_data.speed = KNOTS2KMH(minmea_toint(&frame.speed)); gps_data.speed = KNOTS2KMH(minmea_toint(&frame.speed));
} }
break; break;
@ -110,6 +109,7 @@ void gps_task(const struct gpsDevice *dev)
struct minmea_sentence_gsa frame; struct minmea_sentence_gsa frame;
if (minmea_parse_gsa(&frame, sentence)) if (minmea_parse_gsa(&frame, sentence))
{ {
gps_data.hdop = minmea_toscaledint(&frame.hdop, 100);
gps_data.fix_type = frame.fix_type; gps_data.fix_type = frame.fix_type;
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
{ {