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.
This commit is contained in:
parent
e738e18d16
commit
2f0b7f8df7
|
|
@ -271,6 +271,20 @@ static inline int minmea_toint(struct minmea_float *f)
|
|||
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
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ typedef struct
|
|||
uint16_t speed; // Ground speed in km/h
|
||||
int16_t tmg_mag; // Course over ground, degrees, magnetic
|
||||
int16_t tmg_true; // Course over ground, degrees, true
|
||||
uint16_t hdop; // Horizontal dilution of precision, in cm
|
||||
}
|
||||
gps_t;
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@ void gps_task(const struct gpsDevice *dev)
|
|||
gps_data.timestamp.year = frame.date.year;
|
||||
}
|
||||
|
||||
gps_data.tmg_true = minmea_tofloat(&frame.course);
|
||||
gps_data.speed = KNOTS2KMH(minmea_toint(&frame.speed));
|
||||
}
|
||||
break;
|
||||
|
|
@ -110,6 +109,7 @@ void gps_task(const struct gpsDevice *dev)
|
|||
struct minmea_sentence_gsa frame;
|
||||
if (minmea_parse_gsa(&frame, sentence))
|
||||
{
|
||||
gps_data.hdop = minmea_toscaledint(&frame.hdop, 100);
|
||||
gps_data.fix_type = frame.fix_type;
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue