Crate pca9685_rppal

Source
Expand description

A rppal-based wrapper for the Adafruit PCA9685 Servo/PWM Controller.

This crate provides a convenient interface to the PCA9685 PWM driver via I²C on the Raspberry Pi, using the rppal library.

The PCA9685 is often used to control servos or LEDs, offering up to 16 independent PWM channels.

§Example

use pca9685_rppal::*;

let mut pwm = Pca9685::new().expect("Create Pca9685");
pwm.init().expect("Initialize Pca9685");
pwm.set_pwm_freq(50.0).expect("Set Frequency to 50hz (common for servos)");
pwm.set_pwm(0, 0, 1500).expect("Set PWM on channel 0");

Structs§

Pca9685
Represents a PCA9685 device connected via I²C.

Constants§

ALLCALL
Bit mask for enabling the ALLCALL address, allowing all devices to respond to a general call.
ALL_LED_OFF_H
ALL_LED_OFF_H register address, high byte for turning all LEDs OFF.
ALL_LED_OFF_L
ALL_LED_OFF_L register address, low byte for turning all LEDs OFF.
ALL_LED_ON_H
ALL_LED_ON_H register address, high byte for turning all LEDs ON.
ALL_LED_ON_L
ALL_LED_ON_L register address, low byte for turning all LEDs ON.
INVRT
Bit mask for inverting the output logic of the PCA9685.
LED0_OFF_H
LED0_OFF_H register address, high byte of the LED0 OFF time.
LED0_OFF_L
LED0_OFF_L register address, low byte of the LED0 OFF time.
LED0_ON_H
LED0_ON_H register address, high byte of the LED0 ON time.
LED0_ON_L
LED0_ON_L register address, low byte of the LED0 ON time.
MODE1
Mode 1 register address, used for configuring basic operation modes of the PCA9685.
MODE2
Mode 2 register address, used for configuring output behavior of the PCA9685.
OUTDRV
Bit mask for setting the output driver mode to totem-pole (instead of open-drain).
PCA9685_ADDRESS
The default I²C address of the PCA9685 device.
PRESCALE
Prescale register, used to configure the PWM frequency of the PCA9685.
RESTART
Bit mask for restarting the PCA9685 oscillator and resetting its state.
SLEEP
Bit mask for enabling low-power sleep mode.
SUBADR1
Subaddress 1 register, used to set the first alternative I²C subaddress.
SUBADR2
Subaddress 2 register, used to set the second alternative I²C subaddress.
SUBADR3
Subaddress 3 register, used to set the third alternative I²C subaddress.
SWRST
Software reset command for the PCA9685, used to reset all devices on the I²C bus.