raslib
raslib is a library to manage Raspberry PI devices, written in Rust.
It provides GPIO¹ ports access in order to manage leds or motors (direct support for L298N circuit motors).
Installation • Overview • Examples
Installation
In your "Cargo.toml" file :
[]
= "*"
Check the current version on crates.io.
Overview
-
GPIO
The library provides a structure to manipulate GPIO ports simply called
Gpio
.Implementation
; ; ; ;
Usage
use Gpio;
let gpio = new?; gpio.write?; let pin: u32 = gpio.pin;
The Raspberry PI has different GPIO pins following the version. Make sure to connect to the right numbers.
This example is tested on Raspberry PI 4 Model B and the port 16 is not a power (PWR) nor a ground (GND) pin !
See its example.
-
L298N
The library provides a simple way to manipulate motors using the L298N circuit. Because the motors wires are connected to the GPIO pins,
L298n
actually usesGpio
.Implementation
; ; ; ;
Usage
use L298n;
let mut motor_left = new; let mut motor_right = new; motor_left.forward?; motor_right.forward?;
See its example.
-
Utils
The library provides a simple
sleep
function that makes the current thread wait for a duration in milliseconds.;
Usage
; // waits 1 second. sleep
To make writing values prettier, it also provides two constants:
const HIGH: bool = true; const LOW: bool = false;
Usage
gpio.write; gpio.write; // same as above