mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 13:25:30 +03:00
Merge pull request #5765 from etracer65/gps_speed_units
Fix GPS speed and max speed to respect the units selection
This commit is contained in:
commit
f0ea0e81d4
3 changed files with 19 additions and 4 deletions
|
@ -39,6 +39,7 @@
|
||||||
#define DEGREES_TO_RADIANS(angle) ((angle) * 0.0174532925f)
|
#define DEGREES_TO_RADIANS(angle) ((angle) * 0.0174532925f)
|
||||||
|
|
||||||
#define CM_S_TO_KM_H(centimetersPerSecond) (centimetersPerSecond * 36 / 1000)
|
#define CM_S_TO_KM_H(centimetersPerSecond) (centimetersPerSecond * 36 / 1000)
|
||||||
|
#define CM_S_TO_MPH(centimetersPerSecond) (((centimetersPerSecond * 10000) / 5080) / 88)
|
||||||
|
|
||||||
#define MIN(a,b) \
|
#define MIN(a,b) \
|
||||||
__extension__ ({ __typeof__ (a) _a = (a); \
|
__extension__ ({ __typeof__ (a) _a = (a); \
|
||||||
|
|
|
@ -428,8 +428,15 @@ static bool osdDrawSingleElement(uint8_t item)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OSD_GPS_SPEED:
|
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)
|
||||||
tfp_sprintf(buff, "%3dK", CM_S_TO_KM_H(gpsSol.groundSpeed));
|
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;
|
break;
|
||||||
|
|
||||||
case OSD_GPS_LAT:
|
case OSD_GPS_LAT:
|
||||||
|
@ -1121,7 +1128,14 @@ static void osdUpdateStats(void)
|
||||||
{
|
{
|
||||||
int16_t value = 0;
|
int16_t value = 0;
|
||||||
#ifdef USE_GPS
|
#ifdef USE_GPS
|
||||||
value = CM_S_TO_KM_H(gpsSol.groundSpeed);
|
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
|
#endif
|
||||||
if (stats.max_speed < value) {
|
if (stats.max_speed < value) {
|
||||||
stats.max_speed = value;
|
stats.max_speed = value;
|
||||||
|
|
|
@ -370,7 +370,7 @@ TEST(OsdTest, TestStatsImperial)
|
||||||
displayPortTestBufferSubstring(2, row++, "2017-11-19 10:12:");
|
displayPortTestBufferSubstring(2, row++, "2017-11-19 10:12:");
|
||||||
displayPortTestBufferSubstring(2, row++, "TOTAL ARM : 00:05.00");
|
displayPortTestBufferSubstring(2, row++, "TOTAL ARM : 00:05.00");
|
||||||
displayPortTestBufferSubstring(2, row++, "LAST ARM : 00:03");
|
displayPortTestBufferSubstring(2, row++, "LAST ARM : 00:03");
|
||||||
displayPortTestBufferSubstring(2, row++, "MAX SPEED : 28");
|
displayPortTestBufferSubstring(2, row++, "MAX SPEED : 17");
|
||||||
displayPortTestBufferSubstring(2, row++, "MAX DISTANCE : 328%c", SYM_FT);
|
displayPortTestBufferSubstring(2, row++, "MAX DISTANCE : 328%c", SYM_FT);
|
||||||
displayPortTestBufferSubstring(2, row++, "MIN BATTERY : 14.7%c", SYM_VOLT);
|
displayPortTestBufferSubstring(2, row++, "MIN BATTERY : 14.7%c", SYM_VOLT);
|
||||||
displayPortTestBufferSubstring(2, row++, "END BATTERY : 15.2%c", SYM_VOLT);
|
displayPortTestBufferSubstring(2, row++, "END BATTERY : 15.2%c", SYM_VOLT);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue