mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +03:00
beginnings of the great sensor orientation unfucking. WORK IN PROGRESS DO NOT FLY.
git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@397 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
This commit is contained in:
parent
edb0ef01b7
commit
1cc306493b
15 changed files with 213 additions and 747 deletions
|
@ -177,3 +177,51 @@ void systemReset(bool toBootloader)
|
|||
// Generate system reset
|
||||
SCB->AIRCR = AIRCR_VECTKEY_MASK | (uint32_t)0x04;
|
||||
}
|
||||
|
||||
void alignSensors(int16_t *src, int16_t *dest, uint8_t rotation)
|
||||
{
|
||||
switch (rotation) {
|
||||
case CW0_DEG:
|
||||
dest[X] = src[X];
|
||||
dest[Y] = src[Y];
|
||||
dest[Z] = src[Z];
|
||||
break;
|
||||
case CW90_DEG:
|
||||
dest[X] = src[Y];
|
||||
dest[Y] = -src[X];
|
||||
dest[Z] = src[Z];
|
||||
break;
|
||||
case CW180_DEG:
|
||||
dest[X] = -src[X];
|
||||
dest[Y] = -src[Y];
|
||||
dest[Z] = src[Z];
|
||||
break;
|
||||
case CW270_DEG:
|
||||
dest[X] = -src[Y];
|
||||
dest[Y] = src[X];
|
||||
dest[Z] = src[Z];
|
||||
break;
|
||||
case CW0_DEG_FLIP:
|
||||
dest[X] = -src[X];
|
||||
dest[Y] = src[Y];
|
||||
dest[Z] = -src[Z];
|
||||
break;
|
||||
case CW90_DEG_FLIP:
|
||||
dest[X] = src[Y];
|
||||
dest[Y] = src[X];
|
||||
dest[Z] = -src[Z];
|
||||
break;
|
||||
case CW180_DEG_FLIP:
|
||||
dest[X] = src[X];
|
||||
dest[Y] = -src[Y];
|
||||
dest[Z] = -src[Z];
|
||||
break;
|
||||
case CW270_DEG_FLIP:
|
||||
dest[X] = -src[Y];
|
||||
dest[Y] = -src[X];
|
||||
dest[Z] = -src[Z];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue