Struct pwm_pca9685::Pca9685
source · pub struct Pca9685<I2C> { /* private fields */ }
Expand description
PCA9685 PWM/Servo/LED controller.
Implementations
sourceimpl<I2C, E> Pca9685<I2C>where
I2C: Write<Error = E>,
impl<I2C, E> Pca9685<I2C>where
I2C: Write<Error = E>,
sourcepub fn set_channel_on(
&mut self,
channel: Channel,
value: u16
) -> Result<(), Error<E>>
pub fn set_channel_on(
&mut self,
channel: Channel,
value: u16
) -> Result<(), Error<E>>
Set the ON
counter for the selected channel.
sourcepub fn set_channel_off(
&mut self,
channel: Channel,
value: u16
) -> Result<(), Error<E>>
pub fn set_channel_off(
&mut self,
channel: Channel,
value: u16
) -> Result<(), Error<E>>
Set the OFF
counter for the selected channel.
sourcepub fn set_channel_full_on(
&mut self,
channel: Channel,
value: u16
) -> Result<(), Error<E>>
pub fn set_channel_full_on(
&mut self,
channel: Channel,
value: u16
) -> Result<(), Error<E>>
Set the channel always on.
The turning on is delayed by the value argument.
sourcepub fn set_channel_full_off(&mut self, channel: Channel) -> Result<(), Error<E>>
pub fn set_channel_full_off(&mut self, channel: Channel) -> Result<(), Error<E>>
Set the channel always off.
This takes precedence over the on
settings and can be cleared by setting
the off
counter with set_channel_off
.
sourcepub fn set_output_logic_state(
&mut self,
state: OutputLogicState
) -> Result<(), Error<E>>
pub fn set_output_logic_state(
&mut self,
state: OutputLogicState
) -> Result<(), Error<E>>
Set the output logic state
This allows for inversion of the output logic.
sourcepub fn use_external_clock(&mut self) -> Result<(), Error<E>>
pub fn use_external_clock(&mut self) -> Result<(), Error<E>>
Enable using the EXTCLK pin as clock source input.
This setting is sticky. It can only be cleared by a power cycle or a software reset.
sourcepub fn set_prescale(&mut self, prescale: u8) -> Result<(), Error<E>>
pub fn set_prescale(&mut self, prescale: u8) -> Result<(), Error<E>>
Set the prescale value.
The prescale value can be calculated for an update rate with the formula:
prescale_value = round(osc_value / (4096 * update_rate)) - 1
The minimum prescale value is 3, which corresonds to an update rate of 1526 Hz. The maximum prescale value is 255, which corresponds to an update rate of 24 Hz.
If you want to control a servo, set a prescale value of 100. This will correspond to a frequency of about 60 Hz, which is the frequency at which servos work.
Internally this function stops the oscillator and restarts it after setting the prescale value if it was running.
sourcepub fn reset_internal_driver_state(&mut self)
pub fn reset_internal_driver_state(&mut self)
Reset the internal state of this driver to the default values.
Note: This does not alter the state or configuration of the device.
This resets the cached configuration register value in this driver to the power-up (reset) configuration of the device.
This needs to be called after performing a reset on the device, for example through an I2C general-call Reset command, which was not done through this driver to ensure that the configurations in the device and in the driver match.