1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-21 07:15:18 +03:00

OSD: allow to present odometer on post flight screen

This commit is contained in:
Krzysztof Matula 2019-04-14 23:31:30 +02:00
parent eb7e6c0b39
commit cd0e90fdde
3 changed files with 37 additions and 2 deletions

View file

@ -1230,6 +1230,11 @@ const clivalue_t valueTable[] = {
#ifdef USE_GYRO_DATA_ANALYSE
{ "osd_stat_max_fft", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_MAX_FFT, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)},
#endif
#ifdef USE_PERSISTENT_STATS
{ "osd_stat_total_flights", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_TOTAL_FLIGHTS, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)},
{ "osd_stat_total_time", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_TOTAL_TIME, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)},
{ "osd_stat_total_dist", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_TOTAL_DIST, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)},
#endif
#ifdef USE_OSD_PROFILES
{ "osd_profile", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 1, OSD_PROFILE_COUNT }, PG_OSD_CONFIG, offsetof(osdConfig_t, osdProfileIndex) },

View file

@ -75,6 +75,7 @@
#include "pg/pg.h"
#include "pg/pg_ids.h"
#include "pg/stats.h"
#include "rx/rx.h"
@ -90,6 +91,9 @@
#include "hardware_revision.h"
#endif
#define VIDEO_BUFFER_CHARS_PAL 480
#define IS_DISPLAY_PAL (displayScreenSize(osdDisplayPort) == VIDEO_BUFFER_CHARS_PAL)
const char * const osdTimerSourceNames[] = {
"ON TIME ",
"TOTAL ARM",
@ -464,10 +468,12 @@ static bool isSomeStatEnabled(void)
static void osdShowStats(uint16_t endBatteryVoltage)
{
uint8_t top = 2;
uint8_t top = 1; /* first fully visible line */
char buff[OSD_ELEMENT_BUFFER_LENGTH];
displayClearScreen(osdDisplayPort);
if (IS_DISPLAY_PAL)
displayWrite(osdDisplayPort, 2, top++, " --- STATS ---");
if (osdStatGetState(OSD_STAT_RTC_DATE_TIME)) {
@ -603,6 +609,27 @@ static void osdShowStats(uint16_t endBatteryVoltage)
}
}
#endif
#ifdef USE_PERSISTENT_STATS
if (osdStatGetState(OSD_STAT_TOTAL_FLIGHTS)) {
itoa(statsConfig()->stats_total_flights, buff, 10);
osdDisplayStatisticLabel(top++, "TOTAL FLIGHTS", buff);
}
if (osdStatGetState(OSD_STAT_TOTAL_TIME)) {
int minutes = statsConfig()->stats_total_time_s / 60;
tfp_sprintf(buff, "%d:%02dH", minutes / 60, minutes % 60);
osdDisplayStatisticLabel(top++, "TOTAL FLIGHT TIME", buff);
}
if (osdStatGetState(OSD_STAT_TOTAL_DIST)) {
#define METERS_PER_KILOMETER 1000
#define METERS_PER_MILE 1609
if (osdConfig()->units == OSD_UNIT_IMPERIAL)
tfp_sprintf(buff, "%dMI", statsConfig()->stats_total_dist_m / METERS_PER_MILE);
else
tfp_sprintf(buff, "%dKM", statsConfig()->stats_total_dist_m / METERS_PER_KILOMETER);
osdDisplayStatisticLabel(top++, "TOTAL DISTANCE", buff);
}
#endif
}
static void osdShowArmed(void)

View file

@ -159,6 +159,9 @@ typedef enum {
OSD_STAT_MIN_LINK_QUALITY,
OSD_STAT_FLIGHT_DISTANCE,
OSD_STAT_MAX_FFT,
OSD_STAT_TOTAL_FLIGHTS,
OSD_STAT_TOTAL_TIME,
OSD_STAT_TOTAL_DIST,
OSD_STAT_COUNT // MUST BE LAST
} osd_stats_e;