Library for Sabertooth motor driver ported from the oficial Arduino library. Packetized Serial Mode
I ported the official arduino library for Sabertooth dual motor drivers. In the porting process I did not used const methods as the original library does, but the functionality stays the same. I also added some methods that I find useful. According to the documentation of the driver this code should be compatible with SyRen drivers.
Diff: ArduinoMath.cpp
- Revision:
- 0:70797f033fe0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ArduinoMath.cpp Mon Feb 20 11:10:08 2017 +0000 @@ -0,0 +1,27 @@ +#include "ArduinoMath.h" + +int ArduinoMath::constrain(int x, int a, int b){ + if (x < a) return (a); + if (x > b) return (b); + return (x); +} + +int ArduinoMath::min(int a, int b){ + if (a < b) return (a); + return (b); +} + +int ArduinoMath::max(int a, int b){ + if (a < b) return (b); + return (a); +} + +int ArduinoMath::map(int x, int in_min, int in_max, int out_min, int out_max){ + return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; +} + +int ArduinoMath::abs(int x){ + if (x < 0) return (-x); + return (x); +} +