Skip to content

Commit 290b919

Browse files
author
Ivan Efimov
committed
kaack counter
1 parent 7e24eec commit 290b919

File tree

8 files changed

+42
-7
lines changed

8 files changed

+42
-7
lines changed

src/main/cli/settings.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,6 +1716,7 @@ const clivalue_t valueTable[] = {
17161716
#ifdef USE_PERSISTENT_STATS
17171717
{ "stats_min_armed_time_s", VAR_INT8 | MASTER_VALUE, .config.minmax = { STATS_OFF, INT8_MAX }, PG_STATS_CONFIG, offsetof(statsConfig_t, stats_min_armed_time_s) },
17181718
{ "stats_total_flights", VAR_UINT32 | MASTER_VALUE, .config.u32Max = UINT32_MAX, PG_STATS_CONFIG, offsetof(statsConfig_t, stats_total_flights) },
1719+
{ "stats_extra_total_kaacks", VAR_UINT32 | MASTER_VALUE, .config.u32Max = UINT32_MAX, PG_STATS_CONFIG, offsetof(statsConfig_t, stats_extra_total_kaacks) },
17191720

17201721
{ "stats_total_time_s", VAR_UINT32 | MASTER_VALUE, .config.u32Max = UINT32_MAX, PG_STATS_CONFIG, offsetof(statsConfig_t, stats_total_time_s) },
17211722
{ "stats_total_dist_m", VAR_UINT32 | MASTER_VALUE, .config.u32Max = UINT32_MAX, PG_STATS_CONFIG, offsetof(statsConfig_t, stats_total_dist_m) },

src/main/cms/cms_menu_persistent_stats.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
uint32_t stats_total_flights;
3939
uint32_t stats_total_time_s;
4040
uint32_t stats_total_dist_m;
41+
uint32_t stats_extra_total_kaacks;
4142
int8_t stats_min_armed_time_s;
4243

4344
static const void *cmsx_PersistentStats_onEnter(displayPort_t *pDisp)
@@ -48,6 +49,7 @@ static const void *cmsx_PersistentStats_onEnter(displayPort_t *pDisp)
4849
stats_total_time_s = statsConfig()->stats_total_time_s;
4950
stats_total_dist_m = statsConfig()->stats_total_dist_m;
5051
stats_min_armed_time_s = statsConfig()->stats_min_armed_time_s;
52+
stats_extra_total_kaacks = statsConfig()->stats_extra_total_kaacks;
5153

5254
return NULL;
5355
}
@@ -61,6 +63,7 @@ static const void *cmsx_PersistentStats_onExit(displayPort_t *pDisp, const OSD_E
6163
statsConfigMutable()->stats_total_time_s = stats_total_time_s;
6264
statsConfigMutable()->stats_total_dist_m = stats_total_dist_m;
6365
statsConfigMutable()->stats_min_armed_time_s = stats_min_armed_time_s;
66+
statsConfigMutable()->stats_extra_total_kaacks = stats_extra_total_kaacks;
6467

6568
return NULL;
6669
}
@@ -72,6 +75,7 @@ static const void *cmsx_ResetStats(displayPort_t *pDisplay, const void *ptr)
7275
stats_total_flights = 0;
7376
stats_total_time_s = 0;
7477
stats_total_dist_m = 0;
78+
stats_extra_total_kaacks = 0;
7579

7680
displayClearScreen(pDisplay, DISPLAY_CLEAR_WAIT);
7781
displayRedraw(pDisplay);
@@ -83,6 +87,7 @@ static const OSD_Entry cmsx_menuPersistentStatsEntries[] =
8387
{
8488
{"-- PERSISTENT STATS --", OME_Label, NULL, NULL},
8589
{"FLIGHTS", OME_UINT32, NULL, &(OSD_UINT32_t){ &stats_total_flights, 0, UINT32_MAX, 1}},
90+
{"KAACKS", OME_UINT32, NULL, &(OSD_UINT32_t){ &stats_extra_total_kaacks, 0, UINT32_MAX, 1}},
8691
{"TIME(sec)", OME_UINT32, NULL, &(OSD_UINT32_t){ &stats_total_time_s, 0, UINT32_MAX, 1}},
8792
{"DIST(m)", OME_UINT32, NULL, &(OSD_UINT32_t){ &stats_total_dist_m, 0, UINT32_MAX, 1}},
8893
{"RESET STATS", OME_Funcall, cmsx_ResetStats, NULL},

src/main/fc/stats.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "io/gps.h"
3434

3535
#include "pg/stats.h"
36+
#include "osd/osd.h"
3637

3738

3839
#define STATS_SAVE_DELAY_US 500000 // Let disarming complete and save stats after this time
@@ -91,15 +92,11 @@ void statsOnDisarm(void)
9192
statsConfigMutable()->stats_total_flights += 1; // arm / flight counter
9293
statsConfigMutable()->stats_total_time_s += dtS;
9394
statsConfigMutable()->stats_total_dist_m += (DISTANCE_FLOWN_CM - arm_distance_cm) / 100;
94-
95-
saveRequired = true;
9695
}
9796

98-
if (saveRequired) {
99-
/* signal that stats need to be saved but don't execute time consuming flash operation
100-
now - let the disarming process complete and then execute the actual save */
101-
dispatchAdd(&writeStatsEntry, STATS_SAVE_DELAY_US);
102-
}
97+
statsConfigMutable()->stats_extra_total_kaacks += osdGetStats()->extra_kaacks;
98+
99+
dispatchAdd(&writeStatsEntry, STATS_SAVE_DELAY_US);
103100
}
104101
}
105102
#endif

src/main/osd/osd.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ const osd_stats_e osdStatsDisplayOrder[OSD_STAT_COUNT] = {
188188
OSD_STAT_TOTAL_FLIGHTS,
189189
OSD_STAT_TOTAL_TIME,
190190
OSD_STAT_TOTAL_DIST,
191+
OSD_STAT_EXTRA_KAACK,
192+
OSD_STAT_EXTRA_KAACK_TOTAL,
191193
};
192194

193195
// Group elements in a number of groups to reduce task scheduling overhead
@@ -497,6 +499,7 @@ static void osdResetStats(void)
497499
stats.max_esc_rpm = 0;
498500
stats.min_link_quality = (linkQualitySource == LQ_SOURCE_NONE) ? 99 : 100; // percent
499501
stats.min_rssi_dbm = CRSF_SNR_MAX;
502+
stats.extra_kaacks = 0;
500503
}
501504

502505
#if defined(USE_ESC_SENSOR) || defined(USE_DSHOT_TELEMETRY)
@@ -873,6 +876,15 @@ static bool osdDisplayStat(int statistic, uint8_t displayRow)
873876
osdDisplayStatisticLabel(displayRow, "TOTAL DISTANCE", buff);
874877
return true;
875878
#endif
879+
case OSD_STAT_EXTRA_KAACK:
880+
itoa(stats.extra_kaacks, buff, 10);
881+
osdDisplayStatisticLabel(displayRow, "KAACKS", buff);
882+
return true;
883+
case OSD_STAT_EXTRA_KAACK_TOTAL:
884+
itoa(statsConfig()->stats_extra_total_kaacks, buff, 10);
885+
osdDisplayStatisticLabel(displayRow, "TOTAL KAACKS", buff);
886+
return true;
887+
876888
}
877889
return false;
878890
}

src/main/osd/osd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ typedef enum {
200200
OSD_STAT_TOTAL_TIME,
201201
OSD_STAT_TOTAL_DIST,
202202
OSD_STAT_MIN_RSSI_DBM,
203+
OSD_STAT_EXTRA_KAACK,
204+
OSD_STAT_EXTRA_KAACK_TOTAL,
203205
OSD_STAT_COUNT // MUST BE LAST
204206
} osd_stats_e;
205207

@@ -329,6 +331,7 @@ typedef struct statistic_s {
329331
int32_t max_esc_rpm;
330332
uint16_t min_link_quality;
331333
int16_t min_rssi_dbm;
334+
uint8_t extra_kaacks;
332335
} statistic_t;
333336

334337
extern timeUs_t resumeRefreshAt;

src/main/osd/osd_elements.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,7 +1425,22 @@ static void osdElementStickOverlay(osdElementParms_t *element)
14251425

14261426
static void osdElementThrottlePosition(osdElementParms_t *element)
14271427
{
1428+
static bool previousKaack = false;
1429+
14281430
const uint8_t throttleValue = calculateThrottlePercent();
1431+
1432+
if (ARMING_FLAG(ARMED)) {
1433+
if (100 == throttleValue) {
1434+
if (!previousKaack) {
1435+
osdGetStats()->extra_kaacks++;
1436+
}
1437+
1438+
previousKaack = true;
1439+
} else {
1440+
previousKaack = false;
1441+
}
1442+
}
1443+
14291444
if (strlen(pilotConfig()->extra100Throttle) == 0 || throttleValue < 100)
14301445
{
14311446
tfp_sprintf(element->buff, "%c%3d", SYM_THR, calculateThrottlePercent());

src/main/pg/stats.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ PG_RESET_TEMPLATE(statsConfig_t, statsConfig,
3434
.stats_total_flights = 0,
3535
.stats_total_time_s = 0,
3636
.stats_total_dist_m = 0,
37+
.stats_extra_total_kaacks = 0,
3738
);
3839
#endif

src/main/pg/stats.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ typedef struct statsConfig_s {
3030
uint32_t stats_total_time_s;
3131
uint32_t stats_total_dist_m;
3232
int8_t stats_min_armed_time_s;
33+
uint32_t stats_extra_total_kaacks;
3334
} statsConfig_t;
3435

3536
PG_DECLARE(statsConfig_t, statsConfig);

0 commit comments

Comments
 (0)