From 1ed0b5cc35ebbbb058c6095ecdc91c2391f9e350 Mon Sep 17 00:00:00 2001 From: Pawel Jalocha Date: Mon, 20 Sep 2021 11:04:38 +0100 Subject: [PATCH] Alternate altitude display in meters and feet --- main/disp_oled.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main/disp_oled.cpp b/main/disp_oled.cpp index a11e6cf..97f0cd3 100644 --- a/main/disp_oled.cpp +++ b/main/disp_oled.cpp @@ -265,8 +265,13 @@ void OLED_DrawGPS(u8g2_t *OLED, GPS_Position *GPS) // GPS time, position, altit Len=0; Len+=Format_String(Line+Len, "Alt: "); if(GPS && GPS->isValid()) - { Len+=Format_SignDec(Line+Len, GPS->Altitude, 4, 1); - Line[Len++]='m'; } + { if(GPS->Sec&2) // display altitude in meters + { Len+=Format_SignDec(Line+Len, GPS->Altitude, 4, 1); + Line[Len++]='m'; } + else // and alternate in feet + { Len+=Format_SignDec(Line+Len, (GPS->Altitude*336+512)>>10, 5); + Line[Len++]='f'; Line[Len++]='t'; } + } else Len+=Format_String(Line+Len, "-----.-"); Line[Len]=0; u8g2_DrawStr(OLED, 0, 60, Line);