3 unstable releases
0.2.1 | Dec 11, 2020 |
---|---|
0.2.0 | Dec 11, 2020 |
0.1.0 | Dec 9, 2020 |
#987 in Embedded development
37KB
470 lines
pololu-smc
A hardware-independent driver for the Pololu Simple Motor Controller G2 (https://www.pololu.com/category/94/pololu-simple-motor-controllers). Note that only the new generation of controllers, with the "G2" suffix, are supported.
This crate aims to provide a user-friendly interface to the motor controller. Commands and variables are represented as structs and enums, to avoid having to bother the user with the details of the low-level communication protocols.
Currently only the I2C protocol is implemented. It should however be easy to add support for the serial protocol as well.
Example
use pololu_smc::{SimpleMotorController, Command};
...
// Here, "interface" implements some I2C traits from embedded_hal
// 0x12 is the device number/address
let mut controller = SimpleMotorController::new(interface, 0x12);
let errors = controller.get_error_status()?;
controller.send_command(Command::ExitSafeStart)?;
controller.send_command(Command::MotorFwd{speed: 500})?;
Dependencies
~71KB