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.

Committer:
Elefantul_umilit
Date:
Thu Sep 21 12:32:29 2017 +0300
Revision:
1:013fa8604413
Parent:
0:70797f033fe0
solved bug in setBaudRate. Now the baud is updated on the mcu as well

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Elefantul_umilit 0:70797f033fe0 1 #include "ArduinoMath.h"
Elefantul_umilit 0:70797f033fe0 2
Elefantul_umilit 0:70797f033fe0 3 int ArduinoMath::constrain(int x, int a, int b){
Elefantul_umilit 0:70797f033fe0 4 if (x < a) return (a);
Elefantul_umilit 0:70797f033fe0 5 if (x > b) return (b);
Elefantul_umilit 0:70797f033fe0 6 return (x);
Elefantul_umilit 0:70797f033fe0 7 }
Elefantul_umilit 0:70797f033fe0 8
Elefantul_umilit 0:70797f033fe0 9 int ArduinoMath::min(int a, int b){
Elefantul_umilit 0:70797f033fe0 10 if (a < b) return (a);
Elefantul_umilit 0:70797f033fe0 11 return (b);
Elefantul_umilit 0:70797f033fe0 12 }
Elefantul_umilit 0:70797f033fe0 13
Elefantul_umilit 0:70797f033fe0 14 int ArduinoMath::max(int a, int b){
Elefantul_umilit 0:70797f033fe0 15 if (a < b) return (b);
Elefantul_umilit 0:70797f033fe0 16 return (a);
Elefantul_umilit 0:70797f033fe0 17 }
Elefantul_umilit 0:70797f033fe0 18
Elefantul_umilit 0:70797f033fe0 19 int ArduinoMath::map(int x, int in_min, int in_max, int out_min, int out_max){
Elefantul_umilit 0:70797f033fe0 20 return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
Elefantul_umilit 0:70797f033fe0 21 }
Elefantul_umilit 0:70797f033fe0 22
Elefantul_umilit 0:70797f033fe0 23 int ArduinoMath::abs(int x){
Elefantul_umilit 0:70797f033fe0 24 if (x < 0) return (-x);
Elefantul_umilit 0:70797f033fe0 25 return (x);
Elefantul_umilit 0:70797f033fe0 26 }
Elefantul_umilit 0:70797f033fe0 27