pub struct Knob<I2C> { /* private fields */ }Expand description
Implementations§
Source§impl<I2C, E> Knob<I2C>where
I2C: I2c<Error = E>,
impl<I2C, E> Knob<I2C>where
I2C: I2c<Error = E>,
Sourcepub fn new_with_address(i2c: I2C, address: u8) -> Result<Self, E>
pub fn new_with_address(i2c: I2C, address: u8) -> Result<Self, E>
Create a new Knob instance with a custom address.
Sourcepub fn update(&mut self) -> Result<bool, E>
pub fn update(&mut self) -> Result<bool, E>
Update the encoder state.
This should be called periodically to read the latest values.
Returns true if the state has changed.
Sourcepub fn set_range(&mut self, min: i16, max: i16)
pub fn set_range(&mut self, min: i16, max: i16)
Set the value range for the encoder.
The encoder value will be constrained to this range.
Pass None to remove the range constraint.
Sourcepub fn clear_range(&mut self)
pub fn clear_range(&mut self)
Clear the range constraint.
Sourcepub fn rotation_delta(&self, previous_value: i16) -> i16
pub fn rotation_delta(&self, previous_value: i16) -> i16
Get the rotation direction since the last update.
Returns:
- Positive value for clockwise rotation
- Negative value for counter-clockwise rotation
- 0 for no rotation
Auto Trait Implementations§
impl<I2C> Freeze for Knob<I2C>where
I2C: Freeze,
impl<I2C> RefUnwindSafe for Knob<I2C>where
I2C: RefUnwindSafe,
impl<I2C> Send for Knob<I2C>where
I2C: Send,
impl<I2C> Sync for Knob<I2C>where
I2C: Sync,
impl<I2C> Unpin for Knob<I2C>where
I2C: Unpin,
impl<I2C> UnwindSafe for Knob<I2C>where
I2C: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more