1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 14:25:20 +03:00

Added Max G-force OSD stat

This commit is contained in:
leocb 2018-07-17 11:44:01 -03:00
parent 92ddf3185f
commit 05e42db90b
4 changed files with 16 additions and 1 deletions

View file

@ -982,6 +982,7 @@ const clivalue_t valueTable[] = {
{ "osd_stat_max_alt", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_MAX_ALTITUDE, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)},
{ "osd_stat_bbox", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_BLACKBOX, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)},
{ "osd_stat_bb_no", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_BLACKBOX_NUMBER, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)},
{ "osd_stat_max_g_force", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_MAX_G_FORCE, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)},
#endif

View file

@ -126,6 +126,7 @@ static uint32_t blinkBits[(OSD_ITEM_COUNT + 31)/32];
#define IS_MID(X) (rcData[X] > 1250 && rcData[X] < 1750)
static timeUs_t flyTime = 0;
static float osdGForce = 0;
typedef struct statistic_s {
timeUs_t armed_time;
@ -135,6 +136,7 @@ typedef struct statistic_s {
int16_t min_rssi;
int32_t max_altitude;
int16_t max_distance;
float max_g_force;
} statistic_t;
static statistic_t stats;
@ -694,7 +696,7 @@ static bool osdDrawSingleElement(uint8_t item)
case OSD_G_FORCE:
{
float osdGForce = 0;
osdGForce = 0.0f;
for (int axis = 0; axis < XYZ_AXIS_COUNT; axis++) {
const float a = accAverage[axis];
osdGForce += a * a;
@ -1233,6 +1235,7 @@ static void osdResetStats(void)
stats.max_altitude = 0;
stats.max_distance = 0;
stats.armed_time = 0;
stats.max_g_force = 0;
}
static void osdUpdateStats(void)
@ -1272,6 +1275,10 @@ static void osdUpdateStats(void)
stats.max_altitude = altitude;
}
if (stats.max_g_force < osdGForce){
stats.max_g_force = osdGForce;
}
#ifdef USE_GPS
if (STATE(GPS_FIX) && STATE(GPS_FIX_HOME)) {
value = GPS_distanceToHome;
@ -1439,6 +1446,11 @@ static void osdShowStats(uint16_t endBatteryVoltage)
}
#endif
if (osdStatGetState(OSD_STAT_MAX_G_FORCE)) {
tfp_sprintf(buff, "%01d.%01dG", (int)stats.max_g_force, (int)(stats.max_g_force * 10) % 10);
osdDisplayStatisticLabel(top++, "MAX G-FORCE", buff);
}
}
static void osdShowArmed(void)

View file

@ -123,6 +123,7 @@ typedef enum {
OSD_STAT_MAX_ALTITUDE,
OSD_STAT_BLACKBOX,
OSD_STAT_BLACKBOX_NUMBER,
OSD_STAT_MAX_G_FORCE,
OSD_STAT_COUNT // MUST BE LAST
} osd_stats_e;

View file

@ -303,6 +303,7 @@ TEST(OsdTest, TestStatsImperial)
osdStatSetState(OSD_STAT_RTC_DATE_TIME, true);
osdStatSetState(OSD_STAT_MAX_DISTANCE, true);
osdStatSetState(OSD_STAT_BLACKBOX_NUMBER, false);
osdStatSetState(OSD_STAT_MAX_G_FORCE, false);
// and
// using imperial unit system