Standard m3pi with one extra method.

Fork of m3pi by Chris Styles

Files at this revision

API Documentation at this revision

Comitter:
bertgereels
Date:
Wed May 09 15:35:12 2018 +0000
Parent:
7:9b128cebb3c2
Commit message:
LineFollower + VLC Decoder

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	Fri Mar 25 15:44:52 2011 +0000
+++ b/m3pi.cpp	Wed May 09 15:35:12 2018 +0000
@@ -112,6 +112,24 @@
     return(fpos);
 }
 
+void m3pi::get_raw_values(unsigned int *values)
+{
+    while (_ser.readable() ) {  // flush buffer
+     _ser.getc();   
+    }
+    
+    char vals[10];                  // array to receive 10 byte return message
+    _ser.putc(0x86);                // send command
+ 
+    for (int i=0; i < 10; i++) {
+        vals[i] =  _ser.getc();   
+    }
+ 
+    for(int i=0; i<5; i++) {            // construct the 2-byte values
+        values[i] = (vals[2*i+1] << 8) | vals[2*i];
+    }
+}
+
 char m3pi::sensor_auto_calibrate() {
     _ser.putc(AUTO_CALIBRATE);
     return(_ser.getc());
--- a/m3pi.h	Fri Mar 25 15:44:52 2011 +0000
+++ b/m3pi.h	Wed May 09 15:35:12 2018 +0000
@@ -163,6 +163,11 @@
      *   1.0 means the line is on the right
      */
     float line_position (void);
+    
+    /** Read raw sensor values from IR sensors (0 - 2000)
+    * @param values - array of size 5 to store values
+    */
+    void get_raw_values(unsigned int *values);
 
 
     /** Calibrate the sensors. This turns the robot left then right, looking for a line