![](/media/cache/profiles/8ad6635f33710af6a535e8fb8486975e.50x50_q85.jpg)
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@21:c2a2e7cbabdd, 2012-11-17 (annotated)
- Committer:
- maetugr
- Date:
- Sat Nov 17 11:49:21 2012 +0000
- Revision:
- 21:c2a2e7cbabdd
- Parent:
- 20:e116e596e540
Erster Flugtest, noch nicht stabil!
Who changed what in which revision?
User | Revision | Line number | New 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 | 21:c2a2e7cbabdd | 11 | I2C_Sensor(PinName sda, PinName scl, char address); |
maetugr | 14:cf260677ecde | 12 | |
maetugr | 18:c8c09a3913ba | 13 | float data[3]; // where the measured data is saved |
maetugr | 18:c8c09a3913ba | 14 | virtual void read() = 0; // read all axis from register to array data |
maetugr | 18:c8c09a3913ba | 15 | //TODO: virtual void calibrate() = 0; // calibrate the sensor and if desired write calibration values to a file |
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 | 20:e116e596e540 | 29 | virtual void readraw() = 0; |
maetugr | 14:cf260677ecde | 30 | |
maetugr | 15:753c5d6a63b3 | 31 | private: |
maetugr | 15:753c5d6a63b3 | 32 | I2C i2c; // I2C-Bus |
maetugr | 21:c2a2e7cbabdd | 33 | char 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 |