Eurobot_2012_Secondary

Dependencies:   mbed tvmet

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers motors.h Source File

motors.h

00001 #ifndef MOTORS_H
00002 #define MOTORS_H
00003 
00004 #include "mbed.h"
00005 #include "TSH.h"
00006 
00007 class Motors {
00008 public:
00009     Motors(TSI2C &i2cin);//, Mutex );
00010     //Motors(I2C &i2cin);
00011 
00012     //Functions declaration
00013     void disableAcceleration();
00014     void resetEncoders();
00015     int getEncoder1();
00016     int getEncoder2();
00017     void move(int distance, int speed);
00018     void turn(int angle, int speed);
00019     int getSignOfInt(int direction);
00020     void stop();
00021     void setSpeed(int speed);
00022     void setSpeed(int speed1, int speed2);
00023     void setMode(int mode);
00024     float encoderToDistance(int encoder);
00025     int distanceToEncoder(float distance);
00026     void sendCommand(char command);
00027     void sendCommand(char command1, char command2 );
00028     int get4Bytes(char command);
00029 
00030 
00031 private:
00032     I2C& i2c;
00033     //Mutex&
00034 
00035     //Constants declaration
00036     static const int md25Address = 0xB0;
00037     static const char cmdSetMotor1 = 0x00;
00038     static const char cmdSetMotor2 = 0x01;
00039     static const char cmdByte = 0x10;
00040     static const char cmdSetMode = 0x0F;
00041     static const char cmdResetEncoders = 0x20;
00042     static const char cmdGetEncoder1 = 0x02;
00043     static const char cmdGetEncoder2 = 0x06;
00044     static const char cmdDisableAcceleration = 0x30;
00045 };
00046 
00047 #endif