uyvli

Dependents:   theRobot3

Fork of PololuQik2 by Thomas Ashworth

Files at this revision

API Documentation at this revision

Comitter:
Fairy_Paolina
Date:
Sat Apr 12 20:25:58 2014 +0000
Parent:
3:01272a06e922
Commit message:
modified;

Changed in this revision

PololuQik2.cpp Show annotated file Show diff for this revision Revisions of this file
PololuQik2.h Show annotated file Show diff for this revision Revisions of this file
diff -r 01272a06e922 -r 33ca85c52dc0 PololuQik2.cpp
--- a/PololuQik2.cpp	Sat Apr 05 07:25:28 2014 +0000
+++ b/PololuQik2.cpp	Sat Apr 12 20:25:58 2014 +0000
@@ -41,6 +41,18 @@
     errorPin.rise(ErrorFunction);
 }
 
+uint8_t PololuQik2::GetMotor0Current() {
+    unsigned char message[] = { MOTOR0CURRENTPACKET };
+    sendMessage(message , 1);
+    return readByte();
+}
+
+uint8_t PololuQik2::GetMotor1Current() {
+    unsigned char message[] = { MOTOR1CURRENTPACKET };
+    sendMessage(message , 1);
+    return readByte();
+}
+
 void PololuQik2::begin() {
     serialConnection.baud(38400);
     wait_ms(100); // Allow Serial baud rate to propagate
diff -r 01272a06e922 -r 33ca85c52dc0 PololuQik2.h
--- a/PololuQik2.h	Sat Apr 05 07:25:28 2014 +0000
+++ b/PololuQik2.h	Sat Apr 12 20:25:58 2014 +0000
@@ -48,6 +48,9 @@
 #define MOTOR1COASTPACKET 0x87 /**< The packet used to all motor 1 to coast */
 #define FWVERSIONPACKET 0x81 /**< The packet to query the firmware version of the motor controller */
 #define ERRORPACKET 0x82 /**< The packet to request the error state from the motor controller */
+#define MOTOR0CURRENTPACKET 0x90
+#define MOTOR1CURRENTPACKET 0x91
+
 
 #define DATAOVERRUNERRORBIT 3 /**< The bit which signifies a data over run error */
 #define FRAMEERRORBIT 4 /**< The bit which signifies a frame error */
@@ -84,6 +87,10 @@
      */
     PololuQik2::PololuQik2(PinName TxPin, PinName RxPin, PinName RSTPin, PinName errPin, void (*errorFunction)(void), bool enCRC);
 
+    // get current
+    uint8_t PololuQik2::GetMotor0Current();
+    uint8_t PololuQik2::GetMotor1Current();
+    //
     /**
      * This method initialises and begins communication with the motor controller.
      * This method is also called when an error is exhibited.