Example use of I2CTransaction class. In this example, the master mbed is talking to 3 legs of the SIPPC3B robot.

Revision:
0:346370254254
Child:
1:d3abc0577ebc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LegInterface.h	Wed May 21 21:21:22 2014 +0000
@@ -0,0 +1,55 @@
+#ifndef LEGINTERFACE_H
+#define LEGINTERFACE_H
+#include "I2CTransaction.h"
+#include "leg_packets.h"
+
+class LegInterface
+{
+public:
+    // Indices for the different legs
+    enum Leg {LEG_W=0, LEG_E, LEG_S, NUM_LEGS};
+
+    // An array of I2C addresses indexable by enum Leg
+    static const int LegAddress[];
+
+
+    LegInterface(Serial *pc = NULL);
+
+    bool sendEstop(bool estop);
+    bool queryStateInitiate();
+    bool queryStateCompleted(int timeout = 1000);
+    bool queryStateCopy(LegState_t legState[NUM_LEGS]);
+    void displayLegState(LegState_t *legState);
+    bool queryLegParams(Leg leg, LegControlParams_t *liftParams, LegControlParams_t *wheelParams);
+    void displayParams(LegControlParams_t *params);
+    bool setLegParams(Leg leg, LegControlParams_t *liftParams, LegControlParams_t *wheelParams);
+    bool setLegGoal(int32_t liftPos[NUM_LEGS], int32_t wheelVel[NUM_LEGS]);
+    void displayStatus();
+
+private:
+    I2CTransaction *transactionEstop[NUM_LEGS];
+    LegPacket_t legPacketEstop;
+
+    I2CTransaction *transactionQueryState[NUM_LEGS];
+    LegPacket_t legPacketQuery;
+    LegState_t legState[NUM_LEGS];
+
+    I2CTransaction *transactionQueryLiftParams[NUM_LEGS];
+    I2CTransaction *transactionQueryWheelParams[NUM_LEGS];
+    LegPacket_t legPacketQueryLiftParams;
+    LegPacket_t legPacketQueryWheelParams;
+    LegControlParams_t legLiftParams;
+    LegControlParams_t legWheelParams;
+
+    I2CTransaction *transactionSetLiftParams[NUM_LEGS];
+    I2CTransaction *transactionSetWheelParams[NUM_LEGS];
+    LegPacket_t legPacketSetLiftParams;
+    LegPacket_t legPacketSetWheelParams;
+    
+    I2CTransaction *transactionSetGoal[NUM_LEGS];
+    LegPacket_t legPacketSetGoal[NUM_LEGS];
+    Serial *pc;
+
+};
+
+#endif