first_library
Dependents: 2019_tourobo_upper minirobo_upper_reserve minirobo_under_reserve serial_RTX_NUCLEA
Diff: Sabertooth_Serial.cpp
- Revision:
- 0:03e99bd9339e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Sabertooth_Serial.cpp Mon Feb 04 04:30:22 2019 +0000 @@ -0,0 +1,12 @@ +#include "Sabertooth_Serial.h" + +SaberSerial::SaberSerial(int baudrate, PinName tx, PinName rx) : _Sabertooth(tx, rx){ + _Sabertooth.baud(baudrate); +} + +void SaberSerial::Serial(int address, int direction, int cmd){ + _Sabertooth.putc(address); + _Sabertooth.putc(direction); + _Sabertooth.putc(abs(cmd)); + _Sabertooth.putc((address + direction + abs(cmd)) & 0b01111111); +} \ No newline at end of file