Crates.io | pololu-smc |
lib.rs | pololu-smc |
version | 0.2.1 |
source | src |
created_at | 2020-12-09 21:08:25.391758 |
updated_at | 2020-12-11 19:54:02.062291 |
description | A driver for the Pololu Simple Motor Controller G2 |
homepage | |
repository | https://github.com/Karlinde/pololu-smc |
max_upload_size | |
id | 321298 |
size | 38,391 |
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.
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})?;