ba

Fork of m3pi by Chris Styles

Files at this revision

API Documentation at this revision

Comitter:
scarcyon
Date:
Sun Jul 05 09:50:36 2015 +0000
Parent:
8:4b7d6ea9b35b
Commit message:
a

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
diff -r 4b7d6ea9b35b -r 3fc886273b7a m3pi.cpp
--- a/m3pi.cpp	Thu May 12 13:26:37 2011 +0000
+++ b/m3pi.cpp	Sun Jul 05 09:50:36 2015 +0000
@@ -24,6 +24,8 @@
 #include "mbed.h"
 #include "m3pi.h"
 
+#define SEND_CALIBRATED_SENSOR_VALUES 0x87
+
 m3pi::m3pi(PinName nrst, PinName tx, PinName rx) :  Stream("m3pi"), _nrst(nrst), _ser(tx, rx)  {
     _ser.baud(115200);
     reset();
@@ -194,6 +196,23 @@
     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;
+}
+
 
 
 
diff -r 4b7d6ea9b35b -r 3fc886273b7a m3pi.h
--- a/m3pi.h	Thu May 12 13:26:37 2011 +0000
+++ b/m3pi.h	Sun Jul 05 09:50:36 2015 +0000
@@ -216,6 +216,9 @@
      * @param text A pointer to a char array
      * @param int The character to send to the 3pi
      */
+     
+     void readsensor (int *sensor);
+     
     int print(char* text, int length);
 
 #ifdef MBED_RPC