0,0 → 1,72 |
//PPM FRAME |
#define PPM_CHANNELS 8 //number of channels. Depends on RC, eg. FX-30 wants 8 or 12. |
//All but HDG, PIT and ROL channel will be fixed to DEFAULT_US |
|
#define PPM_FRAME 22000; //PPM frame length in microseconds |
#define PPM_SYNC_PW 300; //PPM sync pulse length in microseconds. 300-400us usually |
#define PPM_PIN (1<<PD4) //OCR1B |
#define PPM_INV 0 //0= normal PPM, 1= inverted PPM |
#define DEFAULT_US 1500 |
|
//HEADING |
#define HDG_MIN -45.0 //min. Heading angle from starting point after which hdg will be clipped |
#define HDG_MAX +45.0 //max. Heading angle |
#define HDG_US_MIN 1000 //min. Heading Servo PWM pulse width in microseconds |
#define HDG_US_MAX 2000 //max. Heading Servo PWM pulse width in microseconds |
#define HDG_CH 6 //Heading CH number |
|
//PITCH |
#define PIT_MIN -45.0 |
#define PIT_MAX +45.0 |
#define PIT_US_MIN 1000 |
#define PIT_US_MAX 2000 |
#define PIT_CH 7 |
|
//ROLL |
#define ROL_MIN -45.0 |
#define ROL_MAX +45.0 |
#define ROL_US_MIN 1000 |
#define ROL_US_MAX 2000 |
#define ROL_CH 8 |
|
/* |
* m_max and m_min are calibration values for the maximum and minimum |
* measurements recorded on each magnetic axis, which can vary for each |
* LSM303DLH. You should replace the values below with max and min readings from |
* your particular device. |
* |
* To obtain the max and min values, you can use this program's |
* calibration mode, which is enabled by setting J1 |
*/ |
|
const vector p = {0, -1, 0}; |
const vector right = {1, 0, 0}; |
const vector down = {0, 0, -1}; |
vector m_max = {371, 583, 507}; |
vector m_min = {-798, -543, -471}; |
|
void i2c_start(); |
|
void i2c_write_byte(char byte); |
|
char i2c_read_byte(); |
|
char i2c_read_last_byte(); |
|
void i2c_stop(); |
|
void ppm_init(void); |
|
void read_data_raw(vector *a, vector *m); |
|
float IIR2(float x, float* z); |
|
int thr_filter(int x, int * x_reg, int * y_reg); |
|
void read_data(vector *a, vector *m); |
|
float get_heading(const vector *a, const vector *m, const vector *p); |
|
float get_perpendicular(const vector *a, const vector *d, const vector *q); |
|
int get_us(float angle, float deg_min, float deg_max, int pwm_min,int pwm_max); |