Library for the m3pi robot. This works with a Pololu 3pi robot with the Serial Slave firmware, and exposes and API. This is a fork of cstyles m3pi library.

Dependencies:   btbee

Dependents:   configure_btbee m3pi_btTest Test_SlowDown TurnAround ... more

Fork of m3pi by Chris Styles

Revision:
10:f89d2a3a9ed2
Parent:
9:deb9547909c3
Child:
11:7bfb33432791
diff -r deb9547909c3 -r f89d2a3a9ed2 m3pi_ng.cpp
--- a/m3pi_ng.cpp	Mon May 13 10:54:18 2013 +0000
+++ b/m3pi_ng.cpp	Tue May 14 11:05:33 2013 +0000
@@ -38,37 +38,31 @@
 }
 
 
-char * m3pi::signature () {
-    char* sig = new char[6]; //must be initialised with new, else it is destroyed when the function exits
+void m3pi::signature (char * sig) {
     _ser.putc(SEND_SIGNATURE);
     for (int i=0; i<6;i++){
         sig[i]=_ser.getc();
     }
-    return sig;
 }
 
-int * m3pi::raw_sensor () {
+void m3pi::raw_sensor (int * raw) {
     _ser.putc(SEND_RAW_SENSOR_VALUES);
-    int* raw = new int[5]; //must be initialised with new, else it is destroyed when the function exits
     for (int i=0; i<5; i++){
         char lowbyte = _ser.getc();
         char hibyte  = _ser.getc();
         int s = (lowbyte + (hibyte << 8));
         raw[i] = s;
     }
-    return(raw);
 }
 
-int * m3pi::calibrated_sensor () {
+void m3pi::calibrated_sensor (int * cal) {
     _ser.putc(SEND_CALIBRATED_SENSOR_VALUES);
-    int* cal = new int[5]; //must be initialised with new, else it is destroyed when the function exits
     for (int i=0; i<5; i++){
         char lowbyte = _ser.getc();
         char hibyte  = _ser.getc();
         int s = (lowbyte + (hibyte << 8));
         cal[i] = s;
     }
-    return(cal);
 }
 
 void m3pi::playtune (char* text, int length) {