GDP group 24 node core

Dependencies:   EthernetInterface SDFileSystem mbed-rtos mbed snail MbedJSONValue

Committer:
jakehodges
Date:
Mon Dec 15 00:19:48 2014 +0000
Revision:
3:71b090ec5c69
Parent:
0:fcab3b154e49
Child:
8:fd531fe7637b
Added functionality to vary reading size depending on sensor type.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Trumple 0:fcab3b154e49 1 #ifndef SENSORINTERFACE_H
Trumple 0:fcab3b154e49 2
Trumple 0:fcab3b154e49 3 #define SENSORINTERFACE_H
Trumple 0:fcab3b154e49 4
Trumple 0:fcab3b154e49 5 #include "mbed.h"
Trumple 0:fcab3b154e49 6 #include <map>
Trumple 0:fcab3b154e49 7 #include <vector>
Trumple 0:fcab3b154e49 8
Trumple 0:fcab3b154e49 9 #define DEBUG
Trumple 0:fcab3b154e49 10
Trumple 0:fcab3b154e49 11 struct sensor
Trumple 0:fcab3b154e49 12 {
Trumple 0:fcab3b154e49 13 char type;
jakehodges 3:71b090ec5c69 14 char readingSize;
Trumple 0:fcab3b154e49 15 };
Trumple 0:fcab3b154e49 16
Trumple 0:fcab3b154e49 17
Trumple 0:fcab3b154e49 18 struct d_reply
Trumple 0:fcab3b154e49 19 {
Trumple 0:fcab3b154e49 20 char type;
jakehodges 3:71b090ec5c69 21 vector<char> readings;
Trumple 0:fcab3b154e49 22 };
Trumple 0:fcab3b154e49 23
Trumple 0:fcab3b154e49 24
Trumple 0:fcab3b154e49 25 class sensorinterface
Trumple 0:fcab3b154e49 26 {
Trumple 0:fcab3b154e49 27 public:
Trumple 0:fcab3b154e49 28 sensorinterface();
Trumple 0:fcab3b154e49 29 void requestData();
Trumple 0:fcab3b154e49 30 bool isDataWaiting();
Trumple 0:fcab3b154e49 31 d_reply readData();
Trumple 0:fcab3b154e49 32 private:
Trumple 0:fcab3b154e49 33 map<char, sensor> sensors;
Trumple 0:fcab3b154e49 34 map<char, sensor>::iterator currentSensor;
Trumple 0:fcab3b154e49 35 int update();
Trumple 0:fcab3b154e49 36 void error(int);
jakehodges 3:71b090ec5c69 37 sensor& findType(sensor& s, int address);
Trumple 0:fcab3b154e49 38 int sendRequest(char address);
Trumple 0:fcab3b154e49 39 void readyTrigger();
Trumple 0:fcab3b154e49 40 bool ready;
Trumple 0:fcab3b154e49 41
Trumple 0:fcab3b154e49 42 I2C i2c;
Trumple 0:fcab3b154e49 43 InterruptIn readyLine;
Trumple 0:fcab3b154e49 44 };
Trumple 0:fcab3b154e49 45 #endif