1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 08:15:30 +03:00

Fixed point math Implementation instead of floats

This commit is contained in:
borisbstyle 2016-02-18 00:25:44 +01:00
parent 5435fd0cb7
commit 7fd88f060d
8 changed files with 82 additions and 37 deletions

View file

@ -40,6 +40,22 @@ typedef struct stdev_s
int m_n;
} stdev_t;
#define Q12(x) ((1 << 12) / x)
#define Q13(x) ((1 << 13) / x)
#define Q14(x) ((1 << 14) / x)
typedef enum {
Q12_NUMBER = 12,
Q13_NUMBER,
Q14_NUMBER
} qTypeIndex_e;
typedef struct q_number_s {
int16_t num;
int16_t den;
} q_number_t;
// Floating point 3 vector.
typedef struct fp_vector {
float X;
@ -108,3 +124,7 @@ float acos_approx(float x);
#endif
void arraySubInt32(int32_t *dest, int32_t *array1, int32_t *array2, int count);
int16_t qPercent(q_number_t q);
int16_t qMultiply(q_number_t q, int16_t input);
void qConstruct(q_number_t *qNumber, int16_t num, int16_t den, int qType);