From 636c194aea5aa10778c29689d3ca828c8d883661 Mon Sep 17 00:00:00 2001 From: Hydra Date: Wed, 8 Mar 2017 21:31:58 +0000 Subject: [PATCH] CF/BF - OSD - Show symbol for GPS speed to better align with altitude display on OSD. Name and extract the duplicated GPS_speed equation - in CM/S to KM/H. --- src/main/common/maths.h | 2 ++ src/main/io/osd.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/common/maths.h b/src/main/common/maths.h index e21dfb0426..807be800b8 100644 --- a/src/main/common/maths.h +++ b/src/main/common/maths.h @@ -35,6 +35,8 @@ #define DECIDEGREES_TO_RADIANS(angle) ((angle / 10.0f) * 0.0174532925f) #define DEGREES_TO_RADIANS(angle) ((angle) * 0.0174532925f) +#define CM_S_TO_KM_H(centimetersPerSecond) (centimetersPerSecond * 36 / 1000) + #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define ABS(x) ((x) > 0 ? (x) : -(x)) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 4825bab577..79e4b415b6 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -220,7 +220,8 @@ static void osdDrawSingleElement(uint8_t item) case OSD_GPS_SPEED: { - sprintf(buff, "%d%c", GPS_speed * 36 / 1000, SYM_MS); + // FIXME ideally we want to use SYM_KMH symbol but it's not in the font any more, so we use K. + sprintf(buff, "%dK", CM_S_TO_KM_H(GPS_speed) * 10); break; } #endif // GPS @@ -637,7 +638,7 @@ static void osdUpdateStats(void) { int16_t value = 0; #ifdef GPS - value = GPS_speed * 36 / 1000; + value = CM_S_TO_KM_H(GPS_speed); #endif if (stats.max_speed < value) stats.max_speed = value;