Skip to content

Commit

Permalink
pca9685: Fix initial setup
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <[email protected]>
  • Loading branch information
patrickelectric committed Nov 27, 2024
1 parent 3f2d1c9 commit 179ac24
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pca9685.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Pca9685DeviceBuilder {
/// Builds the `Pca9685Device`.
pub fn build(self) -> Result<Pca9685Device, Box<dyn Error>> {
let device = I2cdev::new(self.i2c_bus)?;
let pwm = Pca9685::new(device, self.address).expect("Failed to open PWM controller");
let mut pwm = Pca9685::new(device, self.address).expect("Failed to open PWM controller");

let oe_pin = {
let pin = Pin::new(self.oe_pin_number);
Expand All @@ -96,6 +96,10 @@ impl Pca9685DeviceBuilder {
pin
};

pwm.reset_internal_driver_state();
pwm.use_external_clock().unwrap();
pwm.enable().unwrap();

Ok(Pca9685Device {
pwm,
oe_pin,
Expand Down

0 comments on commit 179ac24

Please sign in to comment.