From b2c939e899a6acc20995c1fa020e34177a1f8278 Mon Sep 17 00:00:00 2001 From: hhhh hgfh <118007458+Claucdan@users.noreply.github.com> Date: Fri, 11 Apr 2025 00:31:06 +0300 Subject: [PATCH] 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 * Update src/main/osd/osd.c fix: adding a comma after "LAUNCH TIME" Co-authored-by: Jan Post * Update src/main/osd/osd.c fix: added free space Co-authored-by: Jan Post * Update src/main/osd/osd.h fix: added free space after declaration Co-authored-by: Jan Post * Update src/main/osd/osd.c fix: added timer reset when switching to LAUNCH mode again Co-authored-by: Jan Post --------- Co-authored-by: Mark Haslinghuis Co-authored-by: Jan Post --- src/main/osd/osd.c | 12 +++++++++++- src/main/osd/osd.h | 5 ++++- src/main/osd/osd_elements.c | 4 ++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/osd/osd.c b/src/main/osd/osd.c index 7e4ab9057b..0b2cbaef24 100644 --- a/src/main/osd/osd.c +++ b/src/main/osd/osd.c @@ -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; diff --git a/src/main/osd/osd.h b/src/main/osd/osd.h index c311bb1f45..eabb04d543 100644 --- a/src/main/osd/osd.h +++ b/src/main/osd/osd.h @@ -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 diff --git a/src/main/osd/osd_elements.c b/src/main/osd/osd_elements.c index 07844d0ea2..64bae571c1 100644 --- a/src/main/osd/osd_elements.c +++ b/src/main/osd/osd_elements.c @@ -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; }