diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 29c424d932..e2ba089784 100755 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -1015,8 +1015,25 @@ static void osdDisplayStatisticLabel(uint8_t y, const char * text, const char * displayWrite(osdDisplayPort, 22, y, value); } +/* + * Test if there's some stat enabled + */ +static bool isSomeStatEnabled(void) { + for (int i = 0; i < OSD_STAT_COUNT; i++) { + if (osdConfig()->enabled_stats[i]) { + return true; + } + } + return false; +} + static void osdShowStats(void) { + + if (!isSomeStatEnabled()) { + return; + } + uint8_t top = 2; char buff[10]; diff --git a/src/test/unit/osd_unittest.cc b/src/test/unit/osd_unittest.cc index 534db8b60f..7c126383d6 100644 --- a/src/test/unit/osd_unittest.cc +++ b/src/test/unit/osd_unittest.cc @@ -131,6 +131,18 @@ void doTestArm(bool testEmpty = true) } } +/* + * Auxiliary function. Test is there're stats that must be shown + */ +bool isSomeStatEnabled(void) { + for (int i = 0; i < OSD_STAT_COUNT; i++) { + if (osdConfigMutable()->enabled_stats[i]) { + return true; + } + } + return false; +} + /* * Performs a test of the OSD actions on disarming. * (reused throughout the test suite) @@ -147,10 +159,11 @@ void doTestDisarm() // then // post flight statistics displayed - displayPortTestBufferSubstring(2, 2, " --- STATS ---"); + if (isSomeStatEnabled()) { + displayPortTestBufferSubstring(2, 2, " --- STATS ---"); + } } - /* * Tests initialisation of the OSD and the power on splash screen. */