[−][src]Struct pwm_pca9685::Pca9685
PCA9685 PWM/Servo/LED controller.
Methods
impl<I2C, E> Pca9685<I2C> where
I2C: Write<Error = E> + WriteRead<Error = E>,
[src]
I2C: Write<Error = E> + WriteRead<Error = E>,
pub fn set_channel_on(
&mut self,
channel: Channel,
value: u16
) -> Result<(), Error<E>>
[src]
&mut self,
channel: Channel,
value: u16
) -> Result<(), Error<E>>
Set the ON
counter for the selected channel.
Note that the full off setting takes precedence over the on
settings.
See section 7.3.3 "LED output and PWM control" of the datasheet for
further details.
pub fn set_channel_off(
&mut self,
channel: Channel,
value: u16
) -> Result<(), Error<E>>
[src]
&mut self,
channel: Channel,
value: u16
) -> Result<(), Error<E>>
Set the OFF
counter for the selected channel.
pub fn set_channel_on_off(
&mut self,
channel: Channel,
on: u16,
off: u16
) -> Result<(), Error<E>>
[src]
&mut self,
channel: Channel,
on: u16,
off: u16
) -> Result<(), Error<E>>
Set the ON
and OFF
counters for the selected channel.
Note that the full off setting takes precedence over the on
settings.
See section 7.3.3 "LED output and PWM control" of the datasheet for
further details.
pub fn set_channel_full_on(
&mut self,
channel: Channel,
value: u16
) -> Result<(), Error<E>>
[src]
&mut self,
channel: Channel,
value: u16
) -> Result<(), Error<E>>
Set the channel always on.
The turning on is delayed by the value argument.
Note that the full off setting takes precedence over the on
settings.
See section 7.3.3 "LED output and PWM control" of the datasheet for further details.
pub fn set_channel_full_off(&mut self, channel: Channel) -> Result<(), Error<E>>
[src]
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
.
See section 7.3.3 "LED output and PWM control" of the datasheet for further details.
pub fn set_all_on_off(
&mut self,
on: &[u16; 16],
off: &[u16; 16]
) -> Result<(), Error<E>>
[src]
&mut self,
on: &[u16; 16],
off: &[u16; 16]
) -> Result<(), Error<E>>
Set the ON
and OFF
counter for each channel at once.
The index of the value in the arrays corresponds to the channel: 0-15.
Note that the full off setting takes precedence over the on
settings.
See section 7.3.3 "LED output and PWM control" of the datasheet for
further details.
impl<I2C, E> Pca9685<I2C> where
I2C: Write<Error = E> + WriteRead<Error = E>,
[src]
I2C: Write<Error = E> + WriteRead<Error = E>,
pub fn new(i2c: I2C, address: SlaveAddr) -> Self
[src]
Create a new instance of the device.
pub fn destroy(self) -> I2C
[src]
Destroy driver instance, return I²C bus instance.
pub fn enable(&mut self) -> Result<(), Error<E>>
[src]
Enable the controller.
pub fn disable(&mut self) -> Result<(), Error<E>>
[src]
Disable the controller (sleep).
pub fn enable_restart_and_disable(&mut self) -> Result<(), Error<E>>
[src]
Put the controller to sleep while keeping the PWM register contents in preparation for a future restart.
pub fn restart(&mut self, delay: &mut impl DelayUs<u16>) -> Result<(), Error<E>>
[src]
Re-enable the controller after a sleep with restart enabled so that previously active PWM channels are restarted.
This includes a delay of 500us in order for the oscillator to stabilize.
If you cannot afford a 500us delay you can use restart_nonblocking()
.
pub fn restart_nonblocking(&mut self) -> Result<(), Error<E>>
[src]
Re-enable the controller after a sleep with restart enabled so that previously active PWM channels are restarted (non-blocking version).
This is a nonblocking version where you are responsible for waiting at
least 500us after the receiving the first WouldBlock
error before
calling again to continue.
pub fn set_programmable_address(
&mut self,
address_type: ProgrammableAddress,
address: u8
) -> Result<(), Error<E>>
[src]
&mut self,
address_type: ProgrammableAddress,
address: u8
) -> Result<(), Error<E>>
Set one of the programmable addresses.
Initially these are not enabled. Once you set this, you can call
enable_programmable_address()
and then use set_address()
to configure
the driver to use the new address.
pub fn enable_programmable_address(
&mut self,
address_type: ProgrammableAddress
) -> Result<(), Error<E>>
[src]
&mut self,
address_type: ProgrammableAddress
) -> Result<(), Error<E>>
Enable responding to programmable address
pub fn disable_programmable_address(
&mut self,
address_type: ProgrammableAddress
) -> Result<(), Error<E>>
[src]
&mut self,
address_type: ProgrammableAddress
) -> Result<(), Error<E>>
Disable responding to programmable address
pub fn set_address(&mut self, address: u8) -> Result<(), Error<E>>
[src]
Sets the address used by the driver for communication.
This does not have any effect on the hardware and is useful when switching between programmable addresses and the fixed hardware address for communication.
pub fn set_output_change_behavior(
&mut self,
change_behavior: OutputStateChange
) -> Result<(), Error<E>>
[src]
&mut self,
change_behavior: OutputStateChange
) -> Result<(), Error<E>>
Set the output change behavior. Either byte-by-byte or all at the same time.
Note that update on ACK requires all 4 PWM channel registers to be loaded before outputs are changed on the last ACK.
pub fn set_output_driver(
&mut self,
driver: OutputDriver
) -> Result<(), Error<E>>
[src]
&mut self,
driver: OutputDriver
) -> Result<(), Error<E>>
Set the output driver configuration.
pub fn set_disabled_output_value(
&mut self,
value: DisabledOutputValue
) -> Result<(), Error<E>>
[src]
&mut self,
value: DisabledOutputValue
) -> Result<(), Error<E>>
Set the output value when outputs are disabled (OE
= 1).
pub fn set_output_logic_state(
&mut self,
state: OutputLogicState
) -> Result<(), Error<E>>
[src]
&mut self,
state: OutputLogicState
) -> Result<(), Error<E>>
Set the output logic state
This allows for inversion of the output logic. Applicable when OE = 0
.
pub fn use_external_clock(&mut self) -> Result<(), Error<E>>
[src]
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.
pub fn set_prescale(&mut self, prescale: u8) -> Result<(), Error<E>>
[src]
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.
pub fn reset_internal_driver_state(&mut self)
[src]
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.
Trait Implementations
Auto Trait Implementations
impl<I2C> Unpin for Pca9685<I2C> where
I2C: Unpin,
I2C: Unpin,
impl<I2C> Send for Pca9685<I2C> where
I2C: Send,
I2C: Send,
impl<I2C> Sync for Pca9685<I2C> where
I2C: Sync,
I2C: Sync,
impl<I2C> UnwindSafe for Pca9685<I2C> where
I2C: UnwindSafe,
I2C: UnwindSafe,
impl<I2C> RefUnwindSafe for Pca9685<I2C> where
I2C: RefUnwindSafe,
I2C: RefUnwindSafe,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,