diff --git a/src/cdev_pin.rs b/src/cdev_pin.rs
index a74e44b..77a3df8 100644
--- a/src/cdev_pin.rs
+++ b/src/cdev_pin.rs
@@ -73,6 +73,26 @@ impl CdevPin {
mode: PhantomData,
})
}
+
+ /// Converts this input pin into an output pin with the given `initial_state`.
+ pub fn into_output
(self, initial_state: PinState) -> Result, CdevPinError> {
+ let new_value = self.state_to_value(initial_state);
+
+ let req = self.req;
+ let mut new_config = req.as_ref().config();
+ new_config.as_output(new_value);
+ req.as_ref().reconfigure(&new_config)?;
+
+ let line = self.line;
+ let line_config = new_config.line_config(line).unwrap().clone();
+
+ Ok(CdevPin {
+ req,
+ line,
+ line_config,
+ mode: PhantomData,
+ })
+ }
}
impl CdevPin