Successful acro and level mode now! Relying on MPU9250 as base sensor. I'm working continuously on tuning and features :) NEWEST VERSION ON: https://github.com/MaEtUgR/FlyBed (CODE 100% compatible/copyable)

Dependencies:   mbed

Committer:
maetugr
Date:
Thu Nov 19 18:47:27 2015 +0000
Revision:
8:609a2ad4c30e
made I2C-Sensors working in parallel, added rolling buffer for PID derivative, played with the PID and frequency parameters in main

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maetugr 8:609a2ad4c30e 1 // by MaEtUgR
maetugr 8:609a2ad4c30e 2
maetugr 8:609a2ad4c30e 3 #ifndef I2C_Sensor_H
maetugr 8:609a2ad4c30e 4 #define I2C_Sensor_H
maetugr 8:609a2ad4c30e 5
maetugr 8:609a2ad4c30e 6 #include "mbed.h"
maetugr 8:609a2ad4c30e 7
maetugr 8:609a2ad4c30e 8 class I2C_Sensor
maetugr 8:609a2ad4c30e 9 {
maetugr 8:609a2ad4c30e 10 public:
maetugr 8:609a2ad4c30e 11 I2C_Sensor(PinName sda, PinName scl, char address);
maetugr 8:609a2ad4c30e 12
maetugr 8:609a2ad4c30e 13 float data[3]; // where the measured data is saved
maetugr 8:609a2ad4c30e 14 //TODO: virtual void calibrate() = 0; // calibrate the sensor and if desired write calibration values to a file
maetugr 8:609a2ad4c30e 15
maetugr 8:609a2ad4c30e 16 //protected:
maetugr 8:609a2ad4c30e 17 // Calibration
maetugr 8:609a2ad4c30e 18 void saveCalibrationValues(float values[], int size, char * filename);
maetugr 8:609a2ad4c30e 19 void loadCalibrationValues(float values[], int size, char * filename);
maetugr 8:609a2ad4c30e 20
maetugr 8:609a2ad4c30e 21 // I2C functions
maetugr 8:609a2ad4c30e 22 char readRegister(char reg);
maetugr 8:609a2ad4c30e 23 void writeRegister(char reg, char data);
maetugr 8:609a2ad4c30e 24 int readMultiRegister(char reg, char* output, int size);
maetugr 8:609a2ad4c30e 25
maetugr 8:609a2ad4c30e 26 // raw data and function to measure it
maetugr 8:609a2ad4c30e 27 short raw[3];
maetugr 8:609a2ad4c30e 28
maetugr 8:609a2ad4c30e 29 private:
maetugr 8:609a2ad4c30e 30 I2C i2c; // original mbed I2C-library just to initialise the control registers
maetugr 8:609a2ad4c30e 31 char i2c_address; // address
maetugr 8:609a2ad4c30e 32
maetugr 8:609a2ad4c30e 33 LocalFileSystem local; // file access to save calibration values
maetugr 8:609a2ad4c30e 34 };
maetugr 8:609a2ad4c30e 35
maetugr 8:609a2ad4c30e 36 #endif