1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! GPIO dummy input/output
//!
//! The dummy module can be used instead of a GPIO implementation tied to
//! hardware to run unit tests or otherwise provide means to test an
//! application when no embedded device is around.
//!
//! It supports the same interface as other GPIOs and its input and output
//! behaviour can be configured in a flexible manner.
//!
//! ## Example
//!
//! The `DummyGpioIn` reads values from a callback:
//!
//! ```rust
//! use std::time;
//! use gpio::{GpioIn, GpioValue};
//! use gpio::dummy::DummyGpioIn;
//!
//! // a simple dummy gpio that is always `true`/`High`
//! let mut dg = DummyGpioIn::new(|| true);
//! assert_eq!(GpioValue::High, dg.read_value().unwrap());
//!
//! // another example that flips every second
//! let mut timed_gpio = DummyGpioIn::new(|| {
//! std::time::SystemTime::now()
//! .duration_since(time::UNIX_EPOCH)
//! .unwrap()
//! .as_secs() % 2 == 0
//! });
//! println!("timed: {:?}", timed_gpio.read_value().unwrap());
//! ```
//!
//! Output can simple be swallowed by a dummy output port:
//!
//! ```rust
//! use gpio::{GpioOut};
//! use gpio::dummy::DummyGpioOut;
//!
//! let mut dg = DummyGpioOut::new(|_| ());
//! dg.set_value(true);
//! ```
use ;
/// Dummy GPIO input pin
/// Dummy GPIO output pin