mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 06:15:16 +03:00
stats:
- cosmetic changes from code review - not enabling stats on any F3 (not enough flash)
This commit is contained in:
parent
fea686f2b5
commit
eb99c7e0d1
7 changed files with 23 additions and 26 deletions
|
@ -1417,11 +1417,11 @@ const clivalue_t valueTable[] = {
|
||||||
{ "flysky_spi_rf_channels", VAR_UINT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = 16, PG_FLYSKY_CONFIG, offsetof(flySkyConfig_t, rfChannelMap) },
|
{ "flysky_spi_rf_channels", VAR_UINT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = 16, PG_FLYSKY_CONFIG, offsetof(flySkyConfig_t, rfChannelMap) },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_STATS
|
#ifdef USE_PERSISTENT_STATS
|
||||||
{ "stats", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_STATS_CONFIG, offsetof(statsConfig_t, stats_enabled) },
|
{ "stats", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_STATS_CONFIG, offsetof(statsConfig_t, stats_enabled) },
|
||||||
{ "stats_total_flights", VAR_UINT32 | MASTER_VALUE, .config.u32Max = UINT32_MAX, PG_STATS_CONFIG, offsetof(statsConfig_t, stats_total_flights) },
|
{ "stats_total_flights", VAR_UINT32 | MASTER_VALUE, .config.u32Max = UINT32_MAX, PG_STATS_CONFIG, offsetof(statsConfig_t, stats_total_flights) },
|
||||||
{ "stats_total_time", VAR_UINT32 | MASTER_VALUE, .config.u32Max = UINT32_MAX, PG_STATS_CONFIG, offsetof(statsConfig_t, stats_total_time) },
|
{ "stats_total_time_s", VAR_UINT32 | MASTER_VALUE, .config.u32Max = UINT32_MAX, PG_STATS_CONFIG, offsetof(statsConfig_t, stats_total_time_s) },
|
||||||
{ "stats_total_dist", VAR_UINT32 | MASTER_VALUE, .config.u32Max = UINT32_MAX, PG_STATS_CONFIG, offsetof(statsConfig_t, stats_total_dist) },
|
{ "stats_total_dist_m", VAR_UINT32 | MASTER_VALUE, .config.u32Max = UINT32_MAX, PG_STATS_CONFIG, offsetof(statsConfig_t, stats_total_dist_m) },
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -371,7 +371,9 @@ void disarm(void)
|
||||||
#endif
|
#endif
|
||||||
flipOverAfterCrashActive = false;
|
flipOverAfterCrashActive = false;
|
||||||
|
|
||||||
|
#ifdef USE_PERSISTENT_STATS
|
||||||
statsOnDisarm();
|
statsOnDisarm();
|
||||||
|
#endif
|
||||||
|
|
||||||
// if ARMING_DISABLED_RUNAWAY_TAKEOFF is set then we want to play it's beep pattern instead
|
// if ARMING_DISABLED_RUNAWAY_TAKEOFF is set then we want to play it's beep pattern instead
|
||||||
if (!(getArmingDisableFlags() & ARMING_DISABLED_RUNAWAY_TAKEOFF)) {
|
if (!(getArmingDisableFlags() & ARMING_DISABLED_RUNAWAY_TAKEOFF)) {
|
||||||
|
@ -486,7 +488,10 @@ void tryArm(void)
|
||||||
#else
|
#else
|
||||||
beeper(BEEPER_ARMING);
|
beeper(BEEPER_ARMING);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_PERSISTENT_STATS
|
||||||
statsOnArm();
|
statsOnArm();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_RUNAWAY_TAKEOFF
|
#ifdef USE_RUNAWAY_TAKEOFF
|
||||||
runawayTakeoffDeactivateUs = 0;
|
runawayTakeoffDeactivateUs = 0;
|
||||||
|
@ -978,8 +983,10 @@ bool processRx(timeUs_t currentTimeUs)
|
||||||
|
|
||||||
pidSetAntiGravityState(IS_RC_MODE_ACTIVE(BOXANTIGRAVITY) || featureIsEnabled(FEATURE_ANTI_GRAVITY));
|
pidSetAntiGravityState(IS_RC_MODE_ACTIVE(BOXANTIGRAVITY) || featureIsEnabled(FEATURE_ANTI_GRAVITY));
|
||||||
|
|
||||||
|
#ifdef USE_PERSISTENT_STATS
|
||||||
/* allow the stats collector to do periodic tasks */
|
/* allow the stats collector to do periodic tasks */
|
||||||
statsOnLoop();
|
statsOnLoop();
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,26 @@
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
#ifdef USE_STATS
|
#ifdef USE_PERSISTENT_STATS
|
||||||
|
|
||||||
#include "drivers/time.h"
|
#include "drivers/time.h"
|
||||||
|
|
||||||
#include "fc/config.h"
|
#include "fc/config.h"
|
||||||
#include "fc/runtime_config.h"
|
#include "fc/runtime_config.h"
|
||||||
#include "fc/stats.h"
|
#include "fc/stats.h"
|
||||||
#include "pg/stats.h"
|
|
||||||
|
|
||||||
#include "io/beeper.h"
|
#include "io/beeper.h"
|
||||||
#include "io/gps.h"
|
#include "io/gps.h"
|
||||||
|
|
||||||
|
#include "pg/stats.h"
|
||||||
|
|
||||||
|
|
||||||
#define MIN_FLIGHT_TIME_TO_RECORD_STATS_S 10 //prevent recording stats for that short "flights" [s]
|
#define MIN_FLIGHT_TIME_TO_RECORD_STATS_S 10 //prevent recording stats for that short "flights" [s]
|
||||||
#define STATS_SAVE_DELAY_MS 500 //let disarming complete and save stats after this time
|
#define STATS_SAVE_DELAY_MS 500 //let disarming complete and save stats after this time
|
||||||
|
|
||||||
static uint32_t arm_millis;
|
static timeMs_t arm_millis;
|
||||||
static uint32_t arm_distance_cm;
|
static uint32_t arm_distance_cm;
|
||||||
static uint32_t save_pending_millis; // 0 = none
|
static timeMs_t save_pending_millis; // 0 = none
|
||||||
|
|
||||||
#ifdef USE_GPS
|
#ifdef USE_GPS
|
||||||
#define DISTANCE_FLOWN_CM (GPS_distanceFlownInCm)
|
#define DISTANCE_FLOWN_CM (GPS_distanceFlownInCm)
|
||||||
|
@ -39,8 +40,8 @@ void statsOnDisarm(void)
|
||||||
uint32_t dt = (millis() - arm_millis) / 1000;
|
uint32_t dt = (millis() - arm_millis) / 1000;
|
||||||
if (dt >= MIN_FLIGHT_TIME_TO_RECORD_STATS_S) {
|
if (dt >= MIN_FLIGHT_TIME_TO_RECORD_STATS_S) {
|
||||||
statsConfigMutable()->stats_total_flights += 1; //arm/flight counter
|
statsConfigMutable()->stats_total_flights += 1; //arm/flight counter
|
||||||
statsConfigMutable()->stats_total_time += dt; //[s]
|
statsConfigMutable()->stats_total_time_s += dt; //[s]
|
||||||
statsConfigMutable()->stats_total_dist += (DISTANCE_FLOWN_CM - arm_distance_cm) / 100; //[m]
|
statsConfigMutable()->stats_total_dist_m += (DISTANCE_FLOWN_CM - arm_distance_cm) / 100; //[m]
|
||||||
/* signal that stats need to be saved but don't execute time consuming flash operation
|
/* signal that stats need to be saved but don't execute time consuming flash operation
|
||||||
now - let the disarming process complete and then execute the actual save */
|
now - let the disarming process complete and then execute the actual save */
|
||||||
save_pending_millis = millis();
|
save_pending_millis = millis();
|
||||||
|
|
|
@ -1,15 +1,4 @@
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#ifdef USE_STATS
|
|
||||||
|
|
||||||
void statsOnArm(void);
|
void statsOnArm(void);
|
||||||
void statsOnDisarm(void);
|
void statsOnDisarm(void);
|
||||||
void statsOnLoop(void);
|
void statsOnLoop(void);
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define statsOnArm() do {} while (0)
|
|
||||||
#define statsOnDisarm() do {} while (0)
|
|
||||||
#define statsOnLoop() do {} while (0)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
#ifdef USE_STATS
|
#ifdef USE_PERSISTENT_STATS
|
||||||
|
|
||||||
#include "pg/pg.h"
|
#include "pg/pg.h"
|
||||||
#include "pg/pg_ids.h"
|
#include "pg/pg_ids.h"
|
||||||
|
@ -32,8 +32,8 @@ PG_REGISTER_WITH_RESET_TEMPLATE(statsConfig_t, statsConfig, PG_STATS_CONFIG, 1);
|
||||||
PG_RESET_TEMPLATE(statsConfig_t, statsConfig,
|
PG_RESET_TEMPLATE(statsConfig_t, statsConfig,
|
||||||
.stats_enabled = 0,
|
.stats_enabled = 0,
|
||||||
.stats_total_flights = 0,
|
.stats_total_flights = 0,
|
||||||
.stats_total_time = 0,
|
.stats_total_time_s = 0,
|
||||||
.stats_total_dist = 0,
|
.stats_total_dist_m = 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
typedef struct statsConfig_s {
|
typedef struct statsConfig_s {
|
||||||
uint32_t stats_total_flights;
|
uint32_t stats_total_flights;
|
||||||
uint32_t stats_total_time; // [s]
|
uint32_t stats_total_time_s; // [s]
|
||||||
uint32_t stats_total_dist; // [m]
|
uint32_t stats_total_dist_m; // [m]
|
||||||
uint8_t stats_enabled;
|
uint8_t stats_enabled;
|
||||||
} statsConfig_t;
|
} statsConfig_t;
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,6 @@
|
||||||
#define USE_MSP_DISPLAYPORT
|
#define USE_MSP_DISPLAYPORT
|
||||||
#define USE_MSP_OVER_TELEMETRY
|
#define USE_MSP_OVER_TELEMETRY
|
||||||
#define USE_LED_STRIP
|
#define USE_LED_STRIP
|
||||||
#define USE_STATS
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ((FLASH_SIZE > 256) || (FEATURE_CUT_LEVEL < 11))
|
#if ((FLASH_SIZE > 256) || (FEATURE_CUT_LEVEL < 11))
|
||||||
|
@ -300,5 +299,6 @@
|
||||||
#define USE_TELEMETRY_SENSORS_DISABLED_DETAILS
|
#define USE_TELEMETRY_SENSORS_DISABLED_DETAILS
|
||||||
// Re-enable this after 4.0 has been released, and remove the define from STM32F4DISCOVERY
|
// Re-enable this after 4.0 has been released, and remove the define from STM32F4DISCOVERY
|
||||||
//#define USE_VTX_TABLE
|
//#define USE_VTX_TABLE
|
||||||
|
#define USE_PERSISTENT_STATS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue