![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
GDP group 24 node core
Dependencies: EthernetInterface SDFileSystem mbed-rtos mbed snail MbedJSONValue
Diff: sensorinterface.h
- Revision:
- 0:fcab3b154e49
- Child:
- 3:71b090ec5c69
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sensorinterface.h Tue Nov 11 17:33:41 2014 +0000 @@ -0,0 +1,45 @@ +#ifndef SENSORINTERFACE_H + +#define SENSORINTERFACE_H + +#include "mbed.h" +#include <map> +#include <vector> + +#define DEBUG + +struct sensor +{ + char type; + int interval; +}; + + +struct d_reply +{ + char type; + vector<uint16_t> readings; +}; + + +class sensorinterface +{ + public: + sensorinterface(); + void requestData(); + bool isDataWaiting(); + d_reply readData(); + private: + map<char, sensor> sensors; + map<char, sensor>::iterator currentSensor; + int update(); + void error(int); + char findType(int address); + int sendRequest(char address); + void readyTrigger(); + bool ready; + + I2C i2c; + InterruptIn readyLine; +}; +#endif \ No newline at end of file