pub struct AdManager { /* private fields */ }Expand description
AD manager for handling multiple channels
Implementations§
Source§impl AdManager
impl AdManager
pub fn new(obniz: Obniz) -> Self
Sourcepub fn channel(&self, channel: u8) -> ObnizResult<AdChannel>
pub fn channel(&self, channel: u8) -> ObnizResult<AdChannel>
Get specific AD channel (0-11)
Sourcepub async fn get_voltage(&self, channel: u8) -> ObnizResult<f64>
pub async fn get_voltage(&self, channel: u8) -> ObnizResult<f64>
Get voltage from specific channel
Sourcepub async fn get_voltages(&self, channels: Vec<u8>) -> ObnizResult<Vec<AdValue>>
pub async fn get_voltages(&self, channels: Vec<u8>) -> ObnizResult<Vec<AdValue>>
Get voltages from multiple channels
Sourcepub async fn enable_channel_stream(&self, channel: u8) -> ObnizResult<()>
pub async fn enable_channel_stream(&self, channel: u8) -> ObnizResult<()>
Enable streaming on specific channel
Sourcepub async fn disable_channel_stream(&self, channel: u8) -> ObnizResult<()>
pub async fn disable_channel_stream(&self, channel: u8) -> ObnizResult<()>
Disable streaming on specific channel
Sourcepub async fn set_channel_callback<F>(
&self,
channel: u8,
callback: F,
) -> ObnizResult<()>
pub async fn set_channel_callback<F>( &self, channel: u8, callback: F, ) -> ObnizResult<()>
Set callback for specific channel
Sourcepub fn remove_channel_callback(&self, channel: u8) -> ObnizResult<()>
pub fn remove_channel_callback(&self, channel: u8) -> ObnizResult<()>
Remove callback for specific channel
Sourcepub async fn deinit_channel(&self, channel: u8) -> ObnizResult<()>
pub async fn deinit_channel(&self, channel: u8) -> ObnizResult<()>
Deinitialize specific channel
Sourcepub async fn deinit_all(&self) -> ObnizResult<()>
pub async fn deinit_all(&self) -> ObnizResult<()>
Deinitialize all channels
Sourcepub async fn read_all(&self) -> ObnizResult<Vec<AdValue>>
pub async fn read_all(&self) -> ObnizResult<Vec<AdValue>>
Get readings from all channels
Sourcepub fn voltage_to_percentage(voltage: f64) -> f64
pub fn voltage_to_percentage(voltage: f64) -> f64
Utility function to convert voltage to percentage (0V = 0%, 5V = 100%)
Sourcepub fn is_voltage_safe(voltage: f64) -> bool
pub fn is_voltage_safe(voltage: f64) -> bool
Utility function to check if voltage is within safe range
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for AdManager
impl !UnwindSafe for AdManager
impl Freeze for AdManager
impl Send for AdManager
impl Sync for AdManager
impl Unpin for AdManager
impl UnsafeUnpin for AdManager
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