Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Eurobot_2012_Secondary by
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 void coastStop(void); 00030 00031 00032 private: 00033 I2C& i2c; 00034 //Mutex& 00035 00036 //Constants declaration 00037 static const int md25Address = 0xB0; 00038 static const char cmdSetMotor1 = 0x00; 00039 static const char cmdSetMotor2 = 0x01; 00040 static const char cmdByte = 0x10; 00041 static const char cmdSetMode = 0x0F; 00042 static const char cmdSetAcceleration = 0x0E; 00043 static const char cmdResetEncoders = 0x20; 00044 static const char cmdGetEncoder1 = 0x02; 00045 static const char cmdGetEncoder2 = 0x06; 00046 static const char cmdDisableAcceleration = 0x30; 00047 }; 00048 00049 #endif
Generated on Tue Jul 12 2022 21:02:13 by
1.7.2
