From 179ac242655241c826f1d19fd0f3342003f6f0cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Wed, 27 Nov 2024 09:16:06 -0300 Subject: [PATCH] pca9685: Fix initial setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- src/pca9685.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pca9685.rs b/src/pca9685.rs index 89028cceb..38ab86f28 100644 --- a/src/pca9685.rs +++ b/src/pca9685.rs @@ -86,7 +86,7 @@ impl Pca9685DeviceBuilder { /// Builds the `Pca9685Device`. pub fn build(self) -> Result> { 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); @@ -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,