mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
Merge pull request #6775 from kmitchel/fix_osd_stat_max_g_force
Relocate G-force calculation.
This commit is contained in:
commit
27cbf0515d
1 changed files with 8 additions and 10 deletions
|
@ -738,16 +738,8 @@ static bool osdDrawSingleElement(uint8_t item)
|
||||||
}
|
}
|
||||||
|
|
||||||
case OSD_G_FORCE:
|
case OSD_G_FORCE:
|
||||||
{
|
tfp_sprintf(buff, "%01d.%01dG", (int)osdGForce, (int)(osdGForce * 10) % 10);
|
||||||
osdGForce = 0.0f;
|
break;
|
||||||
for (int axis = 0; axis < XYZ_AXIS_COUNT; axis++) {
|
|
||||||
const float a = accAverage[axis];
|
|
||||||
osdGForce += a * a;
|
|
||||||
}
|
|
||||||
osdGForce = sqrtf(osdGForce) * acc.dev.acc_1G_rec;
|
|
||||||
tfp_sprintf(buff, "%01d.%01dG", (int)osdGForce, (int)(osdGForce * 10) % 10);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case OSD_ROLL_PIDS:
|
case OSD_ROLL_PIDS:
|
||||||
osdFormatPID(buff, "ROL", ¤tPidProfile->pid[PID_ROLL]);
|
osdFormatPID(buff, "ROL", ¤tPidProfile->pid[PID_ROLL]);
|
||||||
|
@ -1050,6 +1042,12 @@ static void osdDrawElements(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sensors(SENSOR_ACC)) {
|
if (sensors(SENSOR_ACC)) {
|
||||||
|
osdGForce = 0.0f;
|
||||||
|
for (int axis = 0; axis < XYZ_AXIS_COUNT; axis++) {
|
||||||
|
const float a = accAverage[axis];
|
||||||
|
osdGForce += a * a;
|
||||||
|
}
|
||||||
|
osdGForce = sqrtf(osdGForce) * acc.dev.acc_1G_rec;
|
||||||
osdDrawSingleElement(OSD_ARTIFICIAL_HORIZON);
|
osdDrawSingleElement(OSD_ARTIFICIAL_HORIZON);
|
||||||
osdDrawSingleElement(OSD_G_FORCE);
|
osdDrawSingleElement(OSD_G_FORCE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue