Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef Sabertooth_h
00020 #define Sabertooth_h
00021
00022 #if defined(ARDUINO) && ARDUINO >= 100
00023 #include <Arduino.h>
00024 typedef Stream SabertoothStream;
00025 #else
00026 #include <WProgram.h>
00027 typedef Print SabertoothStream;
00028 #endif
00029
00030 #if defined(USBCON)
00031 #define SabertoothTXPinSerial Serial1 // Arduino Leonardo has TX->1 on Serial1, not Serial.
00032 #else
00033 #define SabertoothTXPinSerial Serial1
00034 #endif
00035 #define SyRenTXPinSerial SabertoothTXPinSerial
00036
00041 class Sabertooth
00042 {
00043 public:
00049 Sabertooth(byte address);
00050
00057 Sabertooth(byte address, SabertoothStream& port);
00058
00059 public:
00064 inline byte address() const { return _address; }
00065
00070 inline SabertoothStream& port() const { return _port; }
00071
00076 void autobaud(boolean dontWait = false) const;
00077
00083 static void autobaud(SabertoothStream& port, boolean dontWait = false);
00084
00090 void command(byte command, byte value) const;
00091
00092 public:
00097 void motor(int power) const;
00098
00104 void motor(byte motor, int power) const;
00105
00110 void drive(int power) const;
00111
00116 void turn(int power) const;
00117
00121 void stop() const;
00122
00123 public:
00128 void setMinVoltage(byte value) const;
00129
00135 void setMaxVoltage(byte value) const;
00136
00142 void setBaudRate(long baudRate) const;
00143
00152 void setDeadband(byte value) const;
00153
00159 void setRamping(byte value) const;
00160
00169 void setTimeout(int milliseconds) const;
00170
00171 private:
00172 void throttleCommand(byte command, int power) const;
00173
00174 private:
00175 const byte _address;
00176 SabertoothStream& _port;
00177 };
00178
00179 #endif