1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-12 19:10:32 +03:00

Add Launch Timer (#14332)

* feat: add launch timer to osd timer type

* fix: fix code style

* Update src/main/osd/osd.c

fix: code style

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>

* Update src/main/osd/osd.c

fix: adding a comma after "LAUNCH TIME"

Co-authored-by: Jan Post <Rm2k-Freak@web.de>

* Update src/main/osd/osd.c

fix: added free space

Co-authored-by: Jan Post <Rm2k-Freak@web.de>

* Update src/main/osd/osd.h

fix: added free space after declaration

Co-authored-by: Jan Post <Rm2k-Freak@web.de>

* Update src/main/osd/osd.c

fix: added timer reset when switching to LAUNCH mode again

Co-authored-by: Jan Post <Rm2k-Freak@web.de>

---------

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>
Co-authored-by: Jan Post <Rm2k-Freak@web.de>
This commit is contained in:
hhhh hgfh 2025-04-11 00:31:06 +03:00 committed by GitHub
parent 4ae22e9f8e
commit b2c939e899
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 2 deletions

View file

@ -114,7 +114,8 @@ const char * const osdTimerSourceNames[] = {
"ON TIME ",
"TOTAL ARM",
"LAST ARM ",
"ON/ARM "
"ON/ARM ",
"LAUNCH TIME",
};
#define OSD_LOGO_ROWS 4
@ -127,6 +128,8 @@ const char * const osdTimerSourceNames[] = {
#define IS_MID(X) (rcData[X] > 1250 && rcData[X] < 1750)
timeUs_t osdFlyTime = 0;
timeUs_t osdLaunchTime = 0;
#if defined(USE_ACC)
float osdGForce = 0;
#endif
@ -1243,6 +1246,13 @@ STATIC_UNIT_TESTED bool osdProcessStats1(timeUs_t currentTimeUs)
timeUs_t deltaT = currentTimeUs - lastTimeUs;
osdFlyTime += deltaT;
stats.armed_time += deltaT;
#ifdef USE_LAUNCH_CONTROL
if (!isLaunchControlActive()) {
osdLaunchTime += deltaT;
} else {
osdLaunchTime = 0;
}
#endif
} else if (osdStatsEnabled) { // handle showing/hiding stats based on OSD disable switch position
if (displayIsGrabbed(osdDisplayPort)) {
osdStatsEnabled = false;

View file

@ -29,7 +29,7 @@
#include "sensors/esc_sensor.h"
#define OSD_NUM_TIMER_TYPES 4
#define OSD_NUM_TIMER_TYPES 5
extern const char * const osdTimerSourceNames[OSD_NUM_TIMER_TYPES];
#define OSD_ELEMENT_BUFFER_LENGTH 32
@ -257,6 +257,7 @@ typedef enum {
OSD_TIMER_SRC_TOTAL_ARMED,
OSD_TIMER_SRC_LAST_ARMED,
OSD_TIMER_SRC_ON_OR_ARMED,
OSD_TIMER_SRC_LAUNCH_TIME,
OSD_TIMER_SRC_COUNT
} osd_timer_source_e;
@ -392,6 +393,8 @@ typedef struct statistic_s {
extern timeUs_t resumeRefreshAt;
extern timeUs_t osdFlyTime;
extern timeUs_t osdLaunchTime;
#if defined(USE_ACC)
extern float osdGForce;
#endif

View file

@ -515,6 +515,8 @@ static char osdGetTimerSymbol(osd_timer_source_e src)
return SYM_FLY_M;
case OSD_TIMER_SRC_ON_OR_ARMED:
return ARMING_FLAG(ARMED) ? SYM_FLY_M : SYM_ON_M;
case OSD_TIMER_SRC_LAUNCH_TIME:
return 'L';
default:
return ' ';
}
@ -533,6 +535,8 @@ static timeUs_t osdGetTimerValue(osd_timer_source_e src)
}
case OSD_TIMER_SRC_ON_OR_ARMED:
return ARMING_FLAG(ARMED) ? osdFlyTime : micros();
case OSD_TIMER_SRC_LAUNCH_TIME:
return osdLaunchTime;
default:
return 0;
}