mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 01:05:27 +03:00
Merge pull request #6391 from leocb/osd-max-g-force-stat
Added Max G-force OSD stat
This commit is contained in:
commit
41ce2c6327
4 changed files with 16 additions and 1 deletions
|
@ -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;
|
||||
|
@ -703,7 +705,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;
|
||||
|
@ -1236,6 +1238,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)
|
||||
|
@ -1275,6 +1278,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;
|
||||
|
@ -1442,6 +1449,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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue