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.
Sensors/I2C_Sensor.h@16:74a6531350b5, 2012-10-31 (annotated)
- Committer:
- maetugr
- Date:
- Wed Oct 31 14:44:07 2012 +0000
- Revision:
- 16:74a6531350b5
- Parent:
- 15:753c5d6a63b3
- Child:
- 17:e096e85f6c36
nach Kompassumstellung auf I2C_Sensor (nicht getestet)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maetugr | 14:cf260677ecde | 1 | #ifndef I2C_Sensor_H |
maetugr | 14:cf260677ecde | 2 | #define I2C_Sensor_H |
maetugr | 14:cf260677ecde | 3 | |
maetugr | 14:cf260677ecde | 4 | class I2C_Sensor |
maetugr | 14:cf260677ecde | 5 | { |
maetugr | 14:cf260677ecde | 6 | public: |
maetugr | 14:cf260677ecde | 7 | I2C_Sensor(PinName sda, PinName scl, int8_t address); |
maetugr | 14:cf260677ecde | 8 | |
maetugr | 14:cf260677ecde | 9 | float data[3]; |
maetugr | 14:cf260677ecde | 10 | void read(); |
maetugr | 14:cf260677ecde | 11 | void calibrate(); |
maetugr | 14:cf260677ecde | 12 | |
maetugr | 14:cf260677ecde | 13 | protected: |
maetugr | 16:74a6531350b5 | 14 | // Calibration value saving |
maetugr | 16:74a6531350b5 | 15 | void saveCalibrationValues(float values[], int size, char * filename); |
maetugr | 16:74a6531350b5 | 16 | void loadCalibrationValues(float values[], int size, char * filename); |
maetugr | 16:74a6531350b5 | 17 | |
maetugr | 14:cf260677ecde | 18 | // I2C functions |
maetugr | 15:753c5d6a63b3 | 19 | char readRegister(char reg); |
maetugr | 15:753c5d6a63b3 | 20 | void writeRegister(char reg, char data); |
maetugr | 15:753c5d6a63b3 | 21 | void readMultiRegister(char reg, char* output, int size); |
maetugr | 14:cf260677ecde | 22 | |
maetugr | 14:cf260677ecde | 23 | // raw data and function to measure it |
maetugr | 14:cf260677ecde | 24 | int raw[3]; |
maetugr | 14:cf260677ecde | 25 | void readraw(); |
maetugr | 14:cf260677ecde | 26 | |
maetugr | 15:753c5d6a63b3 | 27 | private: |
maetugr | 15:753c5d6a63b3 | 28 | I2C i2c; // I2C-Bus |
maetugr | 15:753c5d6a63b3 | 29 | int8_t i2c_address; // address |
maetugr | 15:753c5d6a63b3 | 30 | |
maetugr | 14:cf260677ecde | 31 | LocalFileSystem local; // file access to save calibration values |
maetugr | 14:cf260677ecde | 32 | }; |
maetugr | 14:cf260677ecde | 33 | |
maetugr | 14:cf260677ecde | 34 | #endif |