mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 03:20:00 +03:00
moved alignSensors from drv_system to utils updating uvproj to keil5 git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@431 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
60 lines
1.4 KiB
C
60 lines
1.4 KiB
C
#include "board.h"
|
|
#include "mw.h"
|
|
|
|
int constrain(int amt, int low, int high)
|
|
{
|
|
if (amt < low)
|
|
return low;
|
|
else if (amt > high)
|
|
return high;
|
|
else
|
|
return amt;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|