algoritmo logica difusa sensores navegacion
Dependencies: GPS MODI2C SRF05 mbed HMC5883
Diff: Sensors/I2C_Sensor.h
- Revision:
- 0:1c15748ff0e1
diff -r 000000000000 -r 1c15748ff0e1 Sensors/I2C_Sensor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Sensors/I2C_Sensor.h Sat Jul 19 05:35:58 2014 +0000 @@ -0,0 +1,40 @@ +// by MaEtUgR + +#ifndef I2C_Sensor_H +#define I2C_Sensor_H + +#include "mbed.h" +#include "MODI2C.h" + +class I2C_Sensor +{ + public: + I2C_Sensor(PinName sda, PinName scl, char address); + + float data[3]; // where the measured data is saved + virtual void read() = 0; // read all axis from register to array data + //TODO: virtual void calibrate() = 0; // calibrate the sensor and if desired write calibration values to a file + + protected: + // Calibration + void saveCalibrationValues(float values[], int size, char * filename); + void loadCalibrationValues(float values[], int size, char * filename); + + // I2C functions + char readRegister(char reg); + void writeRegister(char reg, char data); + void readMultiRegister(char reg, char* output, int size); + + // raw data and function to measure it + int raw[3]; + virtual void readraw() = 0; + + private: + I2C i2c_init; // original mbed I2C-library just to initialise the control registers + MODI2C i2c; // I2C-Bus + char i2c_address; // address + + LocalFileSystem local; // file access to save calibration values +}; + +#endif