Sabertooth Simplified Serial Library for Arduino: C:/Code/src/contract/sabertooth-arduino/SabertoothSimplified/SabertoothSimplified.h Source File

Sabertooth Simplified Serial Library

Sabertooth Simplified Serial Library for Arduino
Control your Sabertooth with Simplified Serial.
SabertoothSimplified.h
1 /*
2 Arduino Library for Sabertooth Simplified Serial
3 Copyright (c) 2012-2013 Dimension Engineering LLC
4 http://www.dimensionengineering.com/arduino
5 
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9 
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
13 SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
14 RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
15 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
16 USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 
19 #ifndef SabertoothSimplified_h
20 #define SabertoothSimplified_h
21 
22 #if defined(ARDUINO) && ARDUINO >= 100
23 #include <Arduino.h>
24 #else
25 #include <WProgram.h>
26 #endif
27 
28 #if defined(USBCON)
29 #define SabertoothTXPinSerial Serial1 // Arduino Leonardo has TX->1 on Serial1, not Serial.
30 #else
31 #define SabertoothTXPinSerial Serial
32 #endif
33 #define SyRenTXPinSerial SabertoothTXPinSerial
34 
40 {
41 public:
47 
53  SabertoothSimplified(Print& port);
54 
55 public:
60  void motor(int power);
61 
67  void motor(byte motor, int power);
68 
73  void drive(int power);
74 
79  void turn(int power);
80 
84  void stop();
85 
86 private:
87  void mixedMode(boolean enable);
88  void mixedUpdate();
89  void raw(byte motor, int power);
90 
91 private:
92  boolean _mixed;
93  int _mixedDrive, _mixedTurn;
94  boolean _mixedDriveSet, _mixedTurnSet;
95  Print& _port;
96 };
97 
98 #endif