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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers I2C_Sensor.h Source File

I2C_Sensor.h

00001 // by MaEtUgR
00002 
00003 #ifndef I2C_Sensor_H
00004 #define I2C_Sensor_H
00005 
00006 #include "mbed.h"
00007 
00008 class I2C_Sensor
00009 {           
00010     public:
00011         I2C_Sensor(PinName sda, PinName scl, char address);
00012         
00013         float data[3];                  // where the measured data is saved
00014         //TODO: virtual void calibrate() = 0;   // calibrate the sensor and if desired write calibration values to a file
00015         
00016     //protected:
00017         // Calibration
00018         void saveCalibrationValues(float values[], int size, char * filename);
00019         void loadCalibrationValues(float values[], int size, char * filename);
00020     
00021         // I2C functions
00022         char readRegister(char reg);
00023         void writeRegister(char reg, char data);
00024         int readMultiRegister(char reg, char* output, int size);
00025         
00026         // raw data and function to measure it
00027         short raw[3];
00028         
00029     private:
00030         I2C i2c;            // original mbed I2C-library just to initialise the control registers
00031         char i2c_address;   // address
00032         
00033         LocalFileSystem local; // file access to save calibration values
00034 };
00035 
00036 #endif