Example use of I2CTransaction class. In this example, the master mbed is talking to 3 legs of the SIPPC3B robot.
LegInterface.h
- Committer:
- symbiotic
- Date:
- 2014-05-22
- Revision:
- 1:d3abc0577ebc
- Parent:
- 0:346370254254
- Child:
- 2:17c7a02f8401
File content as of revision 1:d3abc0577ebc:
#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]); bool setLegGoal(float liftPos[NUM_LEGS], float 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