mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 06:15:16 +03:00
Changed alignSensors to have common src/dest
This commit is contained in:
parent
1c3838320b
commit
dc56f143f3
5 changed files with 8 additions and 9 deletions
|
@ -219,7 +219,7 @@ void updateAccelerationReadings(rollAndPitchTrims_t *rollAndPitchTrims)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
alignSensors(accSmooth, accSmooth, accAlign);
|
alignSensors(accSmooth, accAlign);
|
||||||
|
|
||||||
if (!isAccelerationCalibrationComplete()) {
|
if (!isAccelerationCalibrationComplete()) {
|
||||||
performAcclerationCalibration(rollAndPitchTrims);
|
performAcclerationCalibration(rollAndPitchTrims);
|
||||||
|
|
|
@ -62,13 +62,12 @@ static void alignBoard(int32_t *vec)
|
||||||
vec[Z] = lrintf(boardRotation[0][Z] * x + boardRotation[1][Z] * y + boardRotation[2][Z] * z);
|
vec[Z] = lrintf(boardRotation[0][Z] * x + boardRotation[1][Z] * y + boardRotation[2][Z] * z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void alignSensors(const int32_t *src, int32_t *dest, uint8_t rotation)
|
void alignSensors(int32_t *dest, uint8_t rotation)
|
||||||
{
|
{
|
||||||
const int32_t x = src[X];
|
const int32_t x = dest[X];
|
||||||
const int32_t y = src[Y];
|
const int32_t y = dest[Y];
|
||||||
const int32_t z = src[Z];
|
const int32_t z = dest[Z];
|
||||||
|
|
||||||
// note src and dest may point to the same address
|
|
||||||
switch (rotation) {
|
switch (rotation) {
|
||||||
default:
|
default:
|
||||||
case CW0_DEG:
|
case CW0_DEG:
|
||||||
|
|
|
@ -23,5 +23,5 @@ typedef struct boardAlignment_s {
|
||||||
int32_t yawDegrees;
|
int32_t yawDegrees;
|
||||||
} boardAlignment_t;
|
} boardAlignment_t;
|
||||||
|
|
||||||
void alignSensors(const int32_t *src, int32_t *dest, uint8_t rotation);
|
void alignSensors(int32_t *dest, uint8_t rotation);
|
||||||
void initBoardAlignment(const boardAlignment_t *boardAlignment);
|
void initBoardAlignment(const boardAlignment_t *boardAlignment);
|
||||||
|
|
|
@ -62,7 +62,7 @@ void compassUpdate(uint32_t currentTime, flightDynamicsTrims_t *magZero)
|
||||||
|
|
||||||
mag.read(magADCRaw);
|
mag.read(magADCRaw);
|
||||||
for (axis = 0; axis < XYZ_AXIS_COUNT; axis++) magADC[axis] = magADCRaw[axis]; // int32_t copy to work with
|
for (axis = 0; axis < XYZ_AXIS_COUNT; axis++) magADC[axis] = magADCRaw[axis]; // int32_t copy to work with
|
||||||
alignSensors(magADC, magADC, magAlign);
|
alignSensors(magADC, magAlign);
|
||||||
|
|
||||||
if (STATE(CALIBRATE_MAG)) {
|
if (STATE(CALIBRATE_MAG)) {
|
||||||
tCal = currentTime;
|
tCal = currentTime;
|
||||||
|
|
|
@ -170,7 +170,7 @@ void gyroUpdate(void)
|
||||||
gyroADC[Y] = gyroADCRaw[Y];
|
gyroADC[Y] = gyroADCRaw[Y];
|
||||||
gyroADC[Z] = gyroADCRaw[Z];
|
gyroADC[Z] = gyroADCRaw[Z];
|
||||||
|
|
||||||
alignSensors(gyroADC, gyroADC, gyroAlign);
|
alignSensors(gyroADC, gyroAlign);
|
||||||
|
|
||||||
if (!isGyroCalibrationComplete()) {
|
if (!isGyroCalibrationComplete()) {
|
||||||
performGyroCalibration(gyroConfig->gyroMovementCalibrationThreshold);
|
performGyroCalibration(gyroConfig->gyroMovementCalibrationThreshold);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue