[][src]Struct pca9685_lib::PCA9685

pub struct PCA9685 { /* fields omitted */ }

A Representation of a PCA9685 Chip

Methods

impl PCA9685[src]

pub fn new(address: u8, bus: I2c) -> Result<PCA9685, Error>[src]

Creates a new PCA9865

pub async fn begin<'_>(&'_ mut self, prescale: u8) -> Result<(), Error>[src]

Restarts the deice and sets a prescale

Panics

If the prescale is less than the minium, or greater than the max, this function will panic.

pub async fn reset<'_>(&'_ mut self) -> Result<(), Error>[src]

Send a reset command to the chip

pub async fn sleep<'_>(&'_ mut self) -> Result<(), Error>[src]

Put the chip into sleep mode

pub async fn wakeup<'_>(&'_ mut self) -> Result<(), Error>[src]

Awaken the chip out of sleep mode

pub fn write_micros(&mut self, channel: u8, micros: u16) -> Result<(), Error>[src]

Sets the pwm output of a pin based on the input of microseconds

Imprecise: This function is not 100% accurate due to the nature of the chip.

pub async fn set_pwm_freq<'_>(&'_ mut self, freq: f32) -> Result<(), Error>[src]

Sets the PWM frequency for the entire chip, up to ~1.6 KHz

Panics

This function will panic if the frequency is not within 1 < freq < 3052

Imprecise: This function is not 100% accurate due to the nature of the chip.

pub fn set_pin(
    &mut self,
    channel: u8,
    on_tick: u16,
    invert: bool
) -> Result<usize, Error>
[src]

Helper to set pin PWM Output. Sets pin wihtout having to deal with on/off tick placement and properly handles a zero value as completely off and 4095 as completely on

pub fn set_pwm(
    &mut self,
    channel: u8,
    on: u16,
    off: u16
) -> Result<usize, Error>
[src]

Set the PWM output of one of the pins on the chip

Panics

This function will panic if channel is > 15

pub fn get_osc_frequency(&self) -> u32[src]

Getter for the internally tracked oscillator used for freq calculations

pub fn set_osc_frequency(&mut self, freq: u32)[src]

Sets the internally tracked oscillator used for frequency calculations.

pub fn get_prescale(&mut self) -> (usize, Result<()>)[src]

Just returns the private prescale value. (PCA9685 doesn't have introspection)

pub async fn set_ext_clock<'_>(&'_ mut self, prescale: u8) -> Result<(), Error>[src]

Sets EXTCLK pin to use the external clock.

pub fn set_output_mode(&mut self, totempole: bool) -> Result<(), Error>[src]

Sets the output mode of the PCA9685 to either open drain or push pull / totempole

Warning

LEDs with integrated zener diodes should only be driven in open drain mode.

Auto Trait Implementations

impl RefUnwindSafe for PCA9685

impl Send for PCA9685

impl !Sync for PCA9685

impl Unpin for PCA9685

impl UnwindSafe for PCA9685

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.