Expand description
Output of a sequence of on/off states
- the state sequence can be modified
- the sequence can be repeated
- An
update()
should be called periodically progress the output in time.
§Implementation
- The OutputLED Structure aggregates a GPIO, (bound at init)
- Output Pattern can be changed, while the GPIO binding is fixed
- A trait (for update) is used to cope with propagate GPIO errors
- A prelude simplifies getting the trait in scope
§Example
For examples check the examples directory directory in the repository.
ⓘ
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))
loop {
if led.update().unwrap() { break; };
wait(1.ms());
}
led.set(0b10, 2, Repeat::Forever)
loop {
led.update().unwrap();
wait(1.ms());
}
Modules§
- macros
- morse
- Allow morse code output as sequence of states
- prelude
- Import the needed types and traits to use the
update()
method.
Macros§
- set_
output_ forever - Simplified setting of the output with infinite repetitions
- set_
output_ once - Simplified setting of the output without repetitions
Structs§
- OnOff
Sequence Output - Output of blinking patterns on an LED
Enums§
- Repeat
- How often shall the output repeated
Traits§
- Output
Update - OutputUpdate Trait which provides an
update()
method
Functions§
- position_
of_ highest_ one - Determine at position of the most left one in the bitfield represented as u128