NOT FINISHED YET!!! My first try to get a self built fully working Quadrocopter based on an mbed, a self built frame and some other more or less cheap parts.

Dependencies:   mbed MODI2C

Committer:
maetugr
Date:
Wed Oct 31 16:53:01 2012 +0000
Revision:
17:e096e85f6c36
Parent:
16:74a6531350b5
Child:
18:c8c09a3913ba
alle Sensoren mit i2c auf I2C_Sensor umgestellt (nicht getestet), noch keine calibration save per I2C_Sensor

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maetugr 17:e096e85f6c36 1 // by MaEtUgR
maetugr 17:e096e85f6c36 2
maetugr 14:cf260677ecde 3 #ifndef I2C_Sensor_H
maetugr 14:cf260677ecde 4 #define I2C_Sensor_H
maetugr 14:cf260677ecde 5
maetugr 17:e096e85f6c36 6 #include "mbed.h"
maetugr 17:e096e85f6c36 7
maetugr 14:cf260677ecde 8 class I2C_Sensor
maetugr 14:cf260677ecde 9 {
maetugr 14:cf260677ecde 10 public:
maetugr 14:cf260677ecde 11 I2C_Sensor(PinName sda, PinName scl, int8_t address);
maetugr 14:cf260677ecde 12
maetugr 14:cf260677ecde 13 float data[3];
maetugr 14:cf260677ecde 14 void read();
maetugr 14:cf260677ecde 15 void calibrate();
maetugr 14:cf260677ecde 16
maetugr 14:cf260677ecde 17 protected:
maetugr 16:74a6531350b5 18 // Calibration value saving
maetugr 16:74a6531350b5 19 void saveCalibrationValues(float values[], int size, char * filename);
maetugr 16:74a6531350b5 20 void loadCalibrationValues(float values[], int size, char * filename);
maetugr 16:74a6531350b5 21
maetugr 14:cf260677ecde 22 // I2C functions
maetugr 15:753c5d6a63b3 23 char readRegister(char reg);
maetugr 15:753c5d6a63b3 24 void writeRegister(char reg, char data);
maetugr 15:753c5d6a63b3 25 void readMultiRegister(char reg, char* output, int size);
maetugr 14:cf260677ecde 26
maetugr 14:cf260677ecde 27 // raw data and function to measure it
maetugr 14:cf260677ecde 28 int raw[3];
maetugr 14:cf260677ecde 29 void readraw();
maetugr 14:cf260677ecde 30
maetugr 15:753c5d6a63b3 31 private:
maetugr 15:753c5d6a63b3 32 I2C i2c; // I2C-Bus
maetugr 15:753c5d6a63b3 33 int8_t i2c_address; // address
maetugr 15:753c5d6a63b3 34
maetugr 14:cf260677ecde 35 LocalFileSystem local; // file access to save calibration values
maetugr 14:cf260677ecde 36 };
maetugr 14:cf260677ecde 37
maetugr 14:cf260677ecde 38 #endif