Crates.io | on-off-sequence-output |
lib.rs | on-off-sequence-output |
version | 0.2.0 |
source | src |
created_at | 2021-05-30 07:16:36.779365 |
updated_at | 2021-06-03 08:00:26.770575 |
description | Sends a sequence of on/off states to a GPIO Pin |
homepage | https://github.com/almedso/on-off-sequence-output |
repository | https://github.com/almedso/on-off-sequence-output |
max_upload_size | |
id | 403761 |
size | 46,613 |
on-off-sequence-output
A platform-agnostic library that provides output of a sequence of on/off states e.g. on an LED.
Add this to your Cargo.toml
:
[dependencies]
on-off-sequence-output = "0.1"
This is a library crate and should work with any led that implements 'embedded_hal' trait 'OutputPin' on any cortex-m MCU.
The source could look like ...
use on_off_sequence_output::prelude::*;
// This is up to the implementation details of the embedded_hal you are using.
let led_pin: OutputPin = hal_function_which_returns_output_pin();
const UPDATE_SCALE: u16 = 500;
let mut led = OnOffSequenceOutput::new(led_pin, UPDATE_SCALE);
let output_states = 0b10011101;
let number_of_output_states = 8;
led.set(output_states, number_of_output_states, Repeat::Never)
loop {
if led.update().unwrap() { break; };
wait(1.ms());
}
led.set(0b010, 3, Repeat::Times(2)).unwrap();
loop {
if led.update().unwrap() { break; };
wait(1.ms());
}
// some morse code output is possible as well
ledout.set_morse("RUST IS GOOD ", Repeat::Forever).unwrap();
loop {
led.update().unwrap();
wait(1.ms());
}
The examples
folder contains a working example named show-led-output
.
The cargo tooling (.cargo, memory.x, openocd.cfg ..) is prepared for an STM NUCLEO F401RE evaluation board.
If you have that board avaliable run
cargo build --target thumbv7em-none-eabihf --example show-led-output
openocd-flash.sh target/thumbv7em-none-eabihf/release/examples/show-led-output
alternatively you can use use cargo-flash tool.
cargo flash --chip stm32f401re --example show-rust-is-good --target thumbv7em-none-eabihf
Since this is a library, there is no toolchain configured for build in .cargo/config
.
Testing is done via unit tests on host only. Run
cargo test --lib --tests
... to exclude examples because they do not compile on host
This project is licensed under
LICENSE.md
or
online)