Crate on_off_sequence_output[][src]

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

OnOffSequenceOutput

Output of blinking patterns on an LED

Enums

Repeat

How often shall the output repeated

Traits

OutputUpdate

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