Sabertooth.h
Go to the documentation of this file.
00001 /*
00002 Arduino Library for SyRen/Sabertooth Packet Serial
00003 Copyright (c) 2012-2013 Dimension Engineering LLC
00004 http://www.dimensionengineering.com/arduino
00005 
00006 Permission to use, copy, modify, and/or distribute this software for any
00007 purpose with or without fee is hereby granted, provided that the above
00008 copyright notice and this permission notice appear in all copies.
00009 
00010 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
00011 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00012 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
00013 SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
00014 RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
00015 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
00016 USE OR PERFORMANCE OF THIS SOFTWARE.
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


ric_mc
Author(s): RoboTiCan
autogenerated on Thu Aug 27 2015 14:39:50