Library for Pololu m3pi line-following robot. Implements the serial slave commands.

Dependents:   3pi_Example_2 3pi_Lab1_Task2_Example1 3pi_Lab2_Task1_Example1 3pi_Line_Follow ... more

Revision:
9:074ce6197b51
Parent:
8:92167bd3eb44
--- a/m3pi.cpp	Wed Jul 05 14:39:33 2017 +0000
+++ b/m3pi.cpp	Mon Mar 19 13:06:40 2018 +0000
@@ -9,10 +9,14 @@
     _reset = new DigitalOut(p8);
     _last_line_position = 0.0;
     
+    // initialise the arrays
     _bar_graph[0] = ' ';
     for (int i = 0; i < 6; i++) {
         _bar_graph[i+1] = i;    
     }
+    for (int i = 0; i < 5; i++) {
+       _values[i]=0;  
+    }
 }
 
 m3pi::~m3pi()
@@ -34,6 +38,10 @@
 
 /////////////////////////////// serial slave commands ////////////////////////////////
 
+void m3pi::scan() 
+{
+    get_calibrated_values(_values);
+}
 
 void m3pi::get_signature(char *signature)
 {
@@ -112,7 +120,6 @@
     }
 }
 
-
 void m3pi::calibrate()
 {
     _serial->putc(0xB4);
@@ -302,6 +309,17 @@
 
 }
 
+void m3pi::display_data() 
+{
+    display_sensor_values(_values,1);   
+    
+    char buffer[8]={0};
+    sprintf(buffer,"% .3f",_last_line_position);
+    lcd_goto_xy(0,0);
+    lcd_print(buffer,6); 
+       
+}
+
 unsigned int m3pi::get_sensor_array_value(unsigned int values[])
 {
     unsigned int value = 0;
@@ -350,6 +368,11 @@
     return _last_line_position;
 }
 
+float m3pi::read_line() {
+    return calc_line_position(_values); 
+}
+
+
 /////////////////////////////// private methods ////////////////////////////////
 
 void m3pi::reset()