mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 01:35:41 +03:00
Add GPS Lap Timer (#11856)
* Add gps lap timer * change timing to GPS time instead of local time * rebase and minor changes * implement KarateBrot's suggestions * follow ledvinap's suggestions, some OSD symbol changes * move platform.h include to the top Co-authored-by: Jan Post <Rm2k-Freak@web.de> * fix osd elements not showing, remove useless block * cleanup, move pg stuff to pg folder * cleanup from review * minor mods to gps lap timer update, add number of laps tracked * rename time variable * add const to timeMs Co-authored-by: Jan Post <Rm2k-Freak@web.de> * Update licenses, add is_sys_element macro * update licenses * round to nearest centisecond Co-authored-by: Jan Post <Rm2k-Freak@web.de> --------- Co-authored-by: Jan Post <Rm2k-Freak@web.de>
This commit is contained in:
parent
23a416b431
commit
aad197f791
26 changed files with 660 additions and 10 deletions
|
@ -61,6 +61,7 @@
|
|||
#include "drivers/time.h"
|
||||
|
||||
#include "fc/core.h"
|
||||
#include "fc/gps_lap_timer.h"
|
||||
#include "fc/rc_controls.h"
|
||||
#include "fc/rc_modes.h"
|
||||
#include "fc/runtime_config.h"
|
||||
|
@ -193,6 +194,8 @@ const osd_stats_e osdStatsDisplayOrder[OSD_STAT_COUNT] = {
|
|||
OSD_STAT_TOTAL_TIME,
|
||||
OSD_STAT_TOTAL_DIST,
|
||||
OSD_STAT_WATT_HOURS_DRAWN,
|
||||
OSD_STAT_BEST_3_CONSEC_LAPS,
|
||||
OSD_STAT_BEST_LAP,
|
||||
};
|
||||
|
||||
// Group elements in a number of groups to reduce task scheduling overhead
|
||||
|
@ -545,6 +548,19 @@ void osdInit(displayPort_t *osdDisplayPortToUse, osdDisplayPortDevice_e displayP
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef USE_GPS_LAP_TIMER
|
||||
void printLapTime(char *buffer, const uint32_t timeMs) {
|
||||
if (timeMs != 0) {
|
||||
const uint32_t timeRoundMs = timeMs + 5; // round value in division by 10
|
||||
const int timeSeconds = timeRoundMs / 1000;
|
||||
const int timeDecimals = (timeRoundMs % 1000) / 10;
|
||||
tfp_sprintf(buffer, "%3u.%02u", timeSeconds, timeDecimals);
|
||||
} else {
|
||||
tfp_sprintf(buffer, " -.--");
|
||||
}
|
||||
}
|
||||
#endif // USE_GPS_LAP_TIMER
|
||||
|
||||
static void osdResetStats(void)
|
||||
{
|
||||
stats.max_current = 0;
|
||||
|
@ -951,6 +967,20 @@ static bool osdDisplayStat(int statistic, uint8_t displayRow)
|
|||
return true;
|
||||
#endif
|
||||
|
||||
#ifdef USE_GPS_LAP_TIMER
|
||||
case OSD_STAT_BEST_3_CONSEC_LAPS: {
|
||||
printLapTime(buff, gpsLapTimerData.best3Consec);
|
||||
osdDisplayStatisticLabel(midCol, displayRow, "BEST 3 CON", buff);
|
||||
return true;
|
||||
}
|
||||
|
||||
case OSD_STAT_BEST_LAP: {
|
||||
printLapTime(buff, gpsLapTimerData.bestLapTime);
|
||||
osdDisplayStatisticLabel(midCol, displayRow, "BEST LAP", buff);
|
||||
return true;
|
||||
}
|
||||
#endif // USE_GPS_LAP_TIMER
|
||||
|
||||
#ifdef USE_PERSISTENT_STATS
|
||||
case OSD_STAT_TOTAL_FLIGHTS:
|
||||
itoa(statsConfig()->stats_total_flights, buff, 10);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue