After struggling with setting up a Vacuum Florescent Display via I2C for a while I ended up getting about as low level as possible with wires and LEDs to solve the problem. Along the way I needed the most foolproof GPIO level control I could create.
extern crate sysfs_gpio;
use sysfs_gpio::{Direction, Pin};
fn led_fun() {
let led_sca = Pin::new(475); // number depends on chip, etc.
led_sca.set_direction(Direction::Out);
led_sca.export();
led_sca.set_value(1);
let led_sck = Pin::new(474);
led_sck.set_direction(Direction::Out);
led_sck.export();
led_sck.set_value(1);
}
fn main() {
led_fun();
}
After a cargo run
you'll need to use sudo to execute the binary i.e. sudo ./target/debug/led-fun-binary
to avoid a permission denied error when you attempt to access the GPIO bus.
I really thought I'd hate Rust at first with it's...well, just look at it. It's not pretty. It's damn unpretty - but after a while you can see the elegance in the sparsity.
https://chanc.ee/20210611-rust-and-leds.html