Library for the m3pi robot. This works with a Pololu 3pi robot with the Serial Slave firmware, and exposes and API. Added a read sensors function
Dependents: pololu_mpi3_V2 pololu_mpi3
Fork of m3pi by
REZO
Revision 9:b256a26ca39c, committed 2015-11-22
- Comitter:
- adrienPPS
- Date:
- Sun Nov 22 02:05:03 2015 +0000
- Parent:
- 8:4b7d6ea9b35b
- Child:
- 10:b84673574e1a
- Commit message:
- Ajoute fonction lecture sensors
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 Sun Nov 22 02:05:03 2015 +0000 @@ -195,6 +195,22 @@ } +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 Sun Nov 22 02:05:03 2015 +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,11 @@ * @param int The character to send to the 3pi */ int print(char* text, int length); + + /** Read IR values + * @param array of 5 + */ + void readsensor (int *sensor); #ifdef MBED_RPC virtual const struct rpc_method *get_rpc_methods();