1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

Fix GPS speed and max speed to respect the units selection

Previously GPS speed and max speed would always display in KPH even if the user chose imperial units.  Now they will display in MPH for imperial units.
This commit is contained in:
Bruce Luckcuck 2018-04-24 16:41:45 -04:00
parent c0b27e6d0c
commit 8c24176d96
2 changed files with 18 additions and 3 deletions

View file

@ -38,6 +38,7 @@
#define DEGREES_TO_RADIANS(angle) ((angle) * 0.0174532925f)
#define CM_S_TO_KM_H(centimetersPerSecond) (centimetersPerSecond * 36 / 1000)
#define CM_S_TO_MPH(centimetersPerSecond) (((centimetersPerSecond * 10000) / 5080) / 88)
#define MIN(a,b) \
__extension__ ({ __typeof__ (a) _a = (a); \

View file

@ -427,9 +427,16 @@ static bool osdDrawSingleElement(uint8_t item)
break;
case OSD_GPS_SPEED:
// FIXME ideally we want to use SYM_KMH symbol but it's not in the font any more, so we use K.
// FIXME ideally we want to use SYM_KMH symbol but it's not in the font any more, so we use K (M for MPH)
switch (osdConfig()->units) {
case OSD_UNIT_IMPERIAL:
tfp_sprintf(buff, "%3dM", CM_S_TO_MPH(gpsSol.groundSpeed));
break;
default:
tfp_sprintf(buff, "%3dK", CM_S_TO_KM_H(gpsSol.groundSpeed));
break;
}
break;
case OSD_GPS_LAT:
osdFormatCoordinate(buff, SYM_LAT, gpsSol.llh.lat);
@ -1119,7 +1126,14 @@ static void osdUpdateStats(void)
{
int16_t value = 0;
#ifdef USE_GPS
switch (osdConfig()->units) {
case OSD_UNIT_IMPERIAL:
value = CM_S_TO_MPH(gpsSol.groundSpeed);
break;
default:
value = CM_S_TO_KM_H(gpsSol.groundSpeed);
break;
}
#endif
if (stats.max_speed < value) {
stats.max_speed = value;