diff --git a/docs/Cli.md b/docs/Cli.md index 4d60d426a3..2dc36c5a9b 100644 --- a/docs/Cli.md +++ b/docs/Cli.md @@ -369,6 +369,9 @@ Re-apply any new defaults as desired. | fw_autotune_threshold | 50 | Threshold [%] of max rate to consider overshoot/undershoot detection | | fw_autotune_ff_to_p_gain | 10 | FF to P gain (strength relationship) [%] | | fw_autotune_ff_to_i_tc | 600 | FF to I time (defines time for I to reach the same level of response as FF) [ms] | +| stats | OFF | General switch of the statistics recording feature (a.k.a. odometer) | +| stats_total_time | 0 | Total flight time [in seconds]. The value is updated on every disarm when "stats" are enabled. | +| stats_total_dist | 0 | Total flight distance [in meters]. The value is updated on every disarm when "stats" are enabled. | This Markdown table is made by MarkdwonTableMaker addon for google spreadsheet. Original Spreadsheet used to make this table can be found here https://docs.google.com/spreadsheets/d/1ubjYdMGmZ2aAMUNYkdfe3hhIF7wRfIjcuPOi_ysmp00/edit?usp=sharing diff --git a/src/main/fc/stats.c b/src/main/fc/stats.c index 046cd5af5c..a66f47f3b8 100644 --- a/src/main/fc/stats.c +++ b/src/main/fc/stats.c @@ -12,6 +12,9 @@ #include "config/parameter_group.h" #include "config/parameter_group_ids.h" +#define MIN_FLIGHT_TIME_TO_RECORD_STATS_S 10 //prevent recording stats for that short "flights" [s] + + PG_REGISTER_WITH_RESET_FN(statsConfig_t, statsConfig, PG_STATS_CONFIG, 0); void pgResetFn_statsConfig(statsConfig_t *instance) @@ -33,9 +36,12 @@ void statsOnArm(void) void statsOnDisarm(void) { if (statsConfig()->stats_enabled) { - statsConfigMutable()->stats_total_time += (millis() - arm_millis) / 1000; //[s] - statsConfigMutable()->stats_total_dist += (getTotalTravelDistance() - arm_distance_cm) / 100; //[m] - writeEEPROM(); + uint32_t dt = (millis() - arm_millis) / 1000; + if (dt >= MIN_FLIGHT_TIME_TO_RECORD_STATS_S) { + statsConfigMutable()->stats_total_time += dt; //[s] + statsConfigMutable()->stats_total_dist += (getTotalTravelDistance() - arm_distance_cm) / 100; //[m] + writeEEPROM(); + } } }