mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-24 00:35:34 +03:00
Make accelerometer position calculation aligned with Configurator
This commit is contained in:
parent
ca1e0ab05a
commit
1c68e9b720
1 changed files with 5 additions and 2 deletions
|
@ -359,6 +359,9 @@ uint8_t accGetCalibrationAxisFlags(void)
|
||||||
|
|
||||||
int getPrimaryAxisIndex(int32_t sample[3])
|
int getPrimaryAxisIndex(int32_t sample[3])
|
||||||
{
|
{
|
||||||
|
// Apply sensor & board alignment (for axis detection only)
|
||||||
|
alignSensors(sample, acc.dev.accAlign);
|
||||||
|
|
||||||
// Tolerate up to atan(1 / 1.5) = 33 deg tilt (in worst case 66 deg separation between points)
|
// Tolerate up to atan(1 / 1.5) = 33 deg tilt (in worst case 66 deg separation between points)
|
||||||
if ((ABS(sample[Z]) / 1.5f) > ABS(sample[X]) && (ABS(sample[Z]) / 1.5f) > ABS(sample[Y])) {
|
if ((ABS(sample[Z]) / 1.5f) > ABS(sample[X]) && (ABS(sample[Z]) / 1.5f) > ABS(sample[Y])) {
|
||||||
//Z-axis
|
//Z-axis
|
||||||
|
@ -366,11 +369,11 @@ int getPrimaryAxisIndex(int32_t sample[3])
|
||||||
}
|
}
|
||||||
else if ((ABS(sample[X]) / 1.5f) > ABS(sample[Y]) && (ABS(sample[X]) / 1.5f) > ABS(sample[Z])) {
|
else if ((ABS(sample[X]) / 1.5f) > ABS(sample[Y]) && (ABS(sample[X]) / 1.5f) > ABS(sample[Z])) {
|
||||||
//X-axis
|
//X-axis
|
||||||
return (sample[X] > 0) ? 2 : 3;
|
return (sample[X] > 0) ? 3 : 5;
|
||||||
}
|
}
|
||||||
else if ((ABS(sample[Y]) / 1.5f) > ABS(sample[X]) && (ABS(sample[Y]) / 1.5f) > ABS(sample[Z])) {
|
else if ((ABS(sample[Y]) / 1.5f) > ABS(sample[X]) && (ABS(sample[Y]) / 1.5f) > ABS(sample[Z])) {
|
||||||
//Y-axis
|
//Y-axis
|
||||||
return (sample[Y] > 0) ? 4 : 5;
|
return (sample[Y] > 0) ? 2 : 4;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue