8484#endif
8585
8686#define VIDEO_BUFFER_CHARS_PAL 480
87+ #define IS_DISPLAY_PAL (displayScreenSize(osdDisplayPort) == VIDEO_BUFFER_CHARS_PAL)
8788
8889// Character coordinate and attributes
8990#define OSD_POS (x ,y ) (x | (y << 5))
9697#define FEET_PER_MILE 5280
9798#define FEET_PER_KILOFEET 1000 // Used for altitude
9899#define METERS_PER_KILOMETER 1000
100+ #define METERS_PER_MILE 1609
99101
100102#define EFFICIENCY_UPDATE_INTERVAL (5 * 1000)
101103
@@ -687,7 +689,7 @@ static void osdCrosshairsBounds(uint8_t *x, uint8_t *y, uint8_t *length)
687689{
688690 * x = 14 - 1 ; // Offset for 1 char to the left
689691 * y = 6 ;
690- if (displayScreenSize ( osdDisplayPort ) == VIDEO_BUFFER_CHARS_PAL ) {
692+ if (IS_DISPLAY_PAL ) {
691693 ++ (* y );
692694 }
693695 int size = 3 ;
@@ -1086,7 +1088,7 @@ static bool osdDrawSingleElement(uint8_t item)
10861088 rollAngle = - rollAngle ;
10871089 }
10881090
1089- if (displayScreenSize ( osdDisplayPort ) == VIDEO_BUFFER_CHARS_PAL ) {
1091+ if (IS_DISPLAY_PAL ) {
10901092 ++ elemPosY ;
10911093 }
10921094
@@ -1150,7 +1152,7 @@ static bool osdDrawSingleElement(uint8_t item)
11501152 elemPosX = 14 ;
11511153 elemPosY = 6 ;
11521154
1153- if (displayScreenSize ( osdDisplayPort ) == VIDEO_BUFFER_CHARS_PAL ) {
1155+ if (IS_DISPLAY_PAL ) {
11541156 ++ elemPosY ;
11551157 }
11561158
@@ -1658,13 +1660,25 @@ void osdInit(displayPort_t *osdDisplayPortToUse)
16581660
16591661 displayClearScreen (osdDisplayPort );
16601662
1663+ uint8_t y = 4 ;
16611664 char string_buffer [30 ];
16621665 tfp_sprintf (string_buffer , "INAV VERSION: %s" , FC_VERSION_STRING );
1663- displayWrite (osdDisplayPort , 5 , 6 , string_buffer );
1666+ displayWrite (osdDisplayPort , 5 , y ++ , string_buffer );
16641667#ifdef USE_CMS
1665- displayWrite (osdDisplayPort , 7 , 7 , CMS_STARTUP_HELP_TEXT1 );
1666- displayWrite (osdDisplayPort , 11 , 8 , CMS_STARTUP_HELP_TEXT2 );
1667- displayWrite (osdDisplayPort , 11 , 9 , CMS_STARTUP_HELP_TEXT3 );
1668+ displayWrite (osdDisplayPort , 7 , y ++ , CMS_STARTUP_HELP_TEXT1 );
1669+ displayWrite (osdDisplayPort , 11 , y ++ , CMS_STARTUP_HELP_TEXT2 );
1670+ displayWrite (osdDisplayPort , 11 , y ++ , CMS_STARTUP_HELP_TEXT3 );
1671+ #endif
1672+
1673+ #ifdef USE_STATS
1674+ displayWrite (osdDisplayPort , 3 , ++ y , "ODOMETER:" );
1675+ if (osdConfig ()-> units == OSD_UNIT_IMPERIAL )
1676+ tfp_sprintf (string_buffer , "%dMI" , statsConfig ()-> stats_total_dist / METERS_PER_MILE );
1677+ else
1678+ tfp_sprintf (string_buffer , "%dKM" , statsConfig ()-> stats_total_dist / METERS_PER_KILOMETER );
1679+ displayWrite (osdDisplayPort , 13 , y ++ , string_buffer );
1680+ tfp_sprintf (string_buffer , "%dH" , statsConfig ()-> stats_total_time / 3600 );
1681+ displayWrite (osdDisplayPort , 13 , y ++ , string_buffer );
16681682#endif
16691683
16701684 displayResync (osdDisplayPort );
@@ -1713,16 +1727,18 @@ static void osdUpdateStats(void)
17131727 stats .max_altitude = MAX (stats .max_altitude , osdGetAltitude ());
17141728}
17151729
1730+ /* Attention: NTSC screen only has 12 fully visible lines - it is FULL now! */
17161731static void osdShowStats (void )
17171732{
17181733 const char * disarmReasonStr [DISARM_REASON_COUNT ] = { "UNKNOWN" , "TIMEOUT" , "STICKS" , "SWITCH" , "SWITCH" , "KILLSW" , "FAILSAFE" , "NAV SYS" };
1719- uint8_t top = 2 ;
1734+ uint8_t top = 1 ; /* first fully visible line */
17201735 const uint8_t statNameX = 1 ;
17211736 const uint8_t statValuesX = 20 ;
17221737 char buff [10 ];
17231738
17241739 displayClearScreen (osdDisplayPort );
1725- displayWrite (osdDisplayPort , statNameX , top ++ , " --- STATS ---" );
1740+ if (IS_DISPLAY_PAL )
1741+ displayWrite (osdDisplayPort , statNameX , top ++ , " --- STATS ---" );
17261742
17271743 if (STATE (GPS_FIX )) {
17281744 displayWrite (osdDisplayPort , statNameX , top , "MAX SPEED :" );
@@ -1738,6 +1754,10 @@ static void osdShowStats(void)
17381754 displayWrite (osdDisplayPort , statValuesX , top ++ , buff );
17391755 }
17401756
1757+ displayWrite (osdDisplayPort , statNameX , top , "MAX ALTITUDE :" );
1758+ osdFormatAltitudeStr (buff , stats .max_altitude );
1759+ displayWrite (osdDisplayPort , statValuesX , top ++ , buff );
1760+
17411761 displayWrite (osdDisplayPort , statNameX , top , "MIN BATTERY VOLT :" );
17421762 osdFormatCentiNumber (buff , stats .min_voltage , 0 , osdConfig ()-> main_voltage_decimals , 0 , osdConfig ()-> main_voltage_decimals + 2 );
17431763 strcat (buff , "V" );
@@ -1785,10 +1805,6 @@ static void osdShowStats(void)
17851805 }
17861806 }
17871807
1788- displayWrite (osdDisplayPort , statNameX , top , "MAX ALTITUDE :" );
1789- osdFormatAltitudeStr (buff , stats .max_altitude );
1790- displayWrite (osdDisplayPort , statValuesX , top ++ , buff );
1791-
17921808 displayWrite (osdDisplayPort , statNameX , top , "FLY TIME :" );
17931809 uint32_t flySeconds = flyTime / 1000000 ;
17941810 uint16_t flyMinutes = flySeconds / 60 ;
0 commit comments