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
:
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 ...
```rust use onoffsequence_output::prelude::*;
// This is up to the implementation details of the embeddedhal you are using. let ledpin: OutputPin = halfunctionwhichreturnsoutput_pin();
const UPDATESCALE: u16 = 500; let mut led = OnOffSequenceOutput::new(ledpin, UPDATE_SCALE);
let outputstates = 0b10011101; let numberofoutputstates = 8; led.set(outputstates, numberofoutputstates, Repeat::Never) loop { if led.update().unwrap() { break; }; wait(1.ms()); }
led.set(0b010, 3, Repeat::Times(2)) loop { if led.update().unwrap() { break; }; wait(1.ms()); }
led.set(0b10, 2, Repeat::Forever) 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
sh
cargo build --target thumbv7em-none-eabihf --example show-led-output
openocd-flash.sh target/thumbv7em-none-eabihf/release/examples/show-led-output
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
sh
cargo test --lib --tests
... to exclude examples because they do not compile on host
This project is licensed under
LICENSE.md
or
online)