Skip to content

Commit

Permalink
extend example
Browse files Browse the repository at this point in the history
  • Loading branch information
hacknus committed Sep 11, 2023
1 parent f90c42b commit d3bbf8c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,29 @@ Should be able to be passed on to any function that expects an OutputPin or an I


Example:

```rust
use shared_pin::SharedPin;
use embedded_hal::digital::v2::OutputPin;

pub fn do_something_with_the_cloned_pin<PIN>(pin: PIN)
where PIN: OuputPin
{
pin.set_high();
// ...
}

{
let mut shared_output_pin_1 = SharedPin::new(output_pin);
let mut shared_output_pin_2 = shared_output_pin_1.clone();
let mut shared_output_pin_3 = shared_output_pin_1.clone();

do_something_with_the_cloned_pin(shared_output_pin_2);
shared_output_pin_3.set_low();

let mut shared_input_pin_1 = SharedPin::new(input_pin);
let mut shared_input_pin_2 = shared_input_pin_1.clone();
let mut shared_input_pin_3 = shared_input_pin_1.clone();

if shared_input_pin_3.is_low() {
// ...
}
Expand Down

0 comments on commit d3bbf8c

Please sign in to comment.