Added individual sensors reading to the original m3pi lib from Chris Style.
Fork of m3pi by
Revision 9:2cdac562fcea, committed 2017-05-31
- Comitter:
- OHL
- Date:
- Wed May 31 08:09:14 2017 +0000
- Parent:
- 8:4b7d6ea9b35b
- Commit message:
- Add raw sensors reading to m3pi lib;
Changed in this revision
m3pi.cpp | Show annotated file Show diff for this revision Revisions of this file |
m3pi.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/m3pi.cpp Thu May 12 13:26:37 2011 +0000 +++ b/m3pi.cpp Wed May 31 08:09:14 2017 +0000 @@ -194,6 +194,22 @@ return(_ser.getc()); } +void m3pi::readsensor (int *sensor){ + + _ser.putc(SEND_CALIBRATED_SENSOR_VALUES); + sensor[0] = _ser.getc(); + sensor[0] += _ser.getc() << 8; + sensor[1] = _ser.getc(); + sensor[1] += _ser.getc() << 8; + sensor[2] = _ser.getc(); + sensor[2] += _ser.getc() << 8; + sensor[3] = _ser.getc(); + sensor[3] += _ser.getc() << 8; + sensor[4] = _ser.getc(); + sensor[4] += _ser.getc() << 8; + + return; +}
--- a/m3pi.h Thu May 12 13:26:37 2011 +0000 +++ b/m3pi.h Wed May 31 08:09:14 2017 +0000 @@ -32,6 +32,7 @@ #define SEND_SIGNATURE 0x81 #define SEND_RAW_SENSOR_VALUES 0x86 +#define SEND_CALIBRATED_SENSOR_VALUES 0x87 #define SEND_TRIMPOT 0xB0 #define SEND_BATTERY_MILLIVOLTS 0xB1 #define DO_PLAY 0xB3 @@ -217,6 +218,8 @@ * @param int The character to send to the 3pi */ int print(char* text, int length); + + void readsensor(int *sensor); #ifdef MBED_RPC virtual const struct rpc_method *get_rpc_methods();