Add tenths of a second OSD timer precision option (#8290)

Add tenths of a second OSD timer precision option
This commit is contained in:
Michael Keller 2019-05-19 12:47:38 +12:00 committed by GitHub
commit dcfe551621
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -192,6 +192,7 @@ typedef enum {
typedef enum {
OSD_TIMER_PREC_SECOND,
OSD_TIMER_PREC_HUNDREDTHS,
OSD_TIMER_PREC_TENTHS,
OSD_TIMER_PREC_COUNT
} osd_timer_precision_e;

View File

@ -286,6 +286,12 @@ void osdFormatTime(char * buff, osd_timer_precision_e precision, timeUs_t time)
tfp_sprintf(buff, "%02d:%02d.%02d", minutes, seconds, hundredths);
break;
}
case OSD_TIMER_PREC_TENTHS:
{
const int tenths = (time / 100000) % 10;
tfp_sprintf(buff, "%02d:%02d.%01d", minutes, seconds, tenths);
break;
}
}
}

View File

@ -414,6 +414,9 @@ TEST(OsdTest, TestStatsMetric)
// using metric unit system
osdConfigMutable()->units = OSD_UNIT_METRIC;
// set timer 1 configuration to tenths precision
osdConfigMutable()->timers[OSD_TIMER_1] = OSD_TIMER(OSD_TIMER_SRC_TOTAL_ARMED, OSD_TIMER_PREC_TENTHS, 0);
// and
// default state values are set
setDefaultSimulationState();
@ -446,7 +449,7 @@ TEST(OsdTest, TestStatsMetric)
// statistics screen should display the following
int row = 3;
displayPortTestBufferSubstring(2, row++, "2017-11-19 10:12:");
displayPortTestBufferSubstring(2, row++, "TOTAL ARM : 00:07.50");
displayPortTestBufferSubstring(2, row++, "TOTAL ARM : 00:07.5");
displayPortTestBufferSubstring(2, row++, "LAST ARM : 00:02");
displayPortTestBufferSubstring(2, row++, "MAX ALTITUDE : 2.0%c", SYM_M);
displayPortTestBufferSubstring(2, row++, "MAX SPEED : 28");