All Projects → eldruin → pwm-pca9685-rs

eldruin / pwm-pca9685-rs

Licence: other
Platform-agnostic Rust driver for the PCA9685 I2C 16-channel, 12-bit PWM/Servo/LED controller

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to pwm-pca9685-rs

embedded-ccs811-rs
Platform agnostic Rust driver for the CCS811 ultra-low power digital gas sensor for monitoring indoor air quality
Stars: ✭ 12 (-36.84%)
Mutual labels:  embedded, i2c, driver, embedded-hal, embedded-hal-driver
pigpio-client
A nodejs client for pigpio socket interface.
Stars: ✭ 24 (+26.32%)
Mutual labels:  i2c, servo, pwm
embedded-sps
Embedded i2c Driver for Sensirion Particulate Matter Sensors - Download the Zip Package from the Release Page
Stars: ✭ 36 (+89.47%)
Mutual labels:  embedded, i2c, driver
atat
no_std crate for parsing AT commands
Stars: ✭ 50 (+163.16%)
Mutual labels:  embedded, no-std, embedded-hal-driver
eruption
Realtime RGB LED Driver for Linux
Stars: ✭ 140 (+636.84%)
Mutual labels:  driver, led
embedded-sht
Embedded SHT Drivers for Sensirion Temperature and Humidity Sensors - Download the Zip Package from the Release Page
Stars: ✭ 53 (+178.95%)
Mutual labels:  i2c, driver
rust-sysfs-pwm
Linux PWM Access via Sysfs in Rust
Stars: ✭ 42 (+121.05%)
Mutual labels:  embedded, pwm
mfrc522
A platform agnostic driver to interface the MFRC522 (RFID reader/writer)
Stars: ✭ 27 (+42.11%)
Mutual labels:  no-std, embedded-hal
w1-gpio-cl
Command line configured kernel mode 1-wire bus master driver. w1-gpio standard Linux module enhancement/substitution.
Stars: ✭ 17 (-10.53%)
Mutual labels:  embedded, driver
cassette
A simple, single-future, non-blocking executor intended for building state machines. Designed to be no-std and embedded friendly.
Stars: ✭ 47 (+147.37%)
Mutual labels:  embedded, no-std
pca9685
This software is a devLib extension to wiringPi http://wiringpi.com/ and enables it to control the Adafruit PCA9685 16-Channel 12-bit PWM/Servo Driver http://www.adafruit.com/products/815 via I2C interface.
Stars: ✭ 48 (+152.63%)
Mutual labels:  servo, pwm
uchroma
An advanced driver for Razer Chroma hardware in Linux
Stars: ✭ 45 (+136.84%)
Mutual labels:  driver, led
DC-Servo
Analog speed control of Brushed DC Motor
Stars: ✭ 16 (-15.79%)
Mutual labels:  servo, pwm
MPU-9250-Sensors-Data-Collect
MPU9250 (MPU6500 + AK8963) I2C Driver in Python for Raspbery PI
Stars: ✭ 51 (+168.42%)
Mutual labels:  i2c, driver
rust-radio-sx127x
Rust driver for the Semtech SX127x series of Sub-GHz LoRa/ISM radio transceivers
Stars: ✭ 21 (+10.53%)
Mutual labels:  embedded, driver
async-stm32f1xx
Abstractions for asynchronous programming on the STM32F1xx family of microcontrollers.
Stars: ✭ 24 (+26.32%)
Mutual labels:  embedded, no-std
Jled
Non-blocking LED controlling library for Arduino and friends.
Stars: ✭ 197 (+936.84%)
Mutual labels:  embedded, led
Drivers
TinyGo drivers for sensors and other devices that use I2C, SPI, GPIO, ADC, and UART interfaces.
Stars: ✭ 250 (+1215.79%)
Mutual labels:  embedded, i2c
IOsonata
IOsonata multi-platform multi-architecture power & performance optimized software library for fast and easy IoT MCU firmware development. Object Oriented design, no board package to define, just pure plug & play any boards
Stars: ✭ 40 (+110.53%)
Mutual labels:  embedded, i2c
mpy-lib
HTS221, LPS22, LIS2DW12, LIS2MDL, LSM6DSO, STTS751, bme280, bmp280, APDS9930, TM1650, TM1637, LCD1602, all kinds of micropython drives, examples, libs
Stars: ✭ 118 (+521.05%)
Mutual labels:  i2c, led

Rust PCA9685 16-channel 12-bit I2C PWM/Servo/LED driver

crates.io Docs Minimum Supported Rust Version Build Status Coverage Status

This is a platform agnostic Rust driver for the PCA9685 PWM/Servo/LED controller, based on the embedded-hal traits.

This driver allows you to:

  • Enable/disable the device. See: enable().
  • Set the on and off counter for a channel or all of them. See: set_channel_on().
  • Set the on and off counters for a channel or all of them at once. See: set_channel_on_off().
  • Set a channel to be always on or off. See: set_channel_full_on().
  • Set the on and off counters for each channel at once. See: set_all_on_off().
  • Set the prescale value. See: set_prescale().
  • Select the output logic state direct or inverted. See: set_output_logic_state().
  • Set when the outputs change. See: set_output_change_behavior().
  • Set the output driver configuration. See: set_output_driver().
  • Set the output value when outputs are disabled. See: `set_disabled_output_value()]
  • Select the EXTCLK pin as clock source. See: use_external_clock().
  • Enable/disable a programmable address. See: enable_programmable_address().
  • Set a programmable address. See: set_programmable_address().
  • Change the address used by the driver. See: set_address().
  • Restart keeping the PWM register contents. See: enable_restart_and_disable().

Introductory blog post

The device

This device is an I2C-bus controlled 16-channel, 12-bit PWM controller. Its outputs can be used to control servo motors or LEDs, for example.

Each channel output has its own 12-bit resolution (4096 steps) fixed frequency individual PWM controller that operates at a programmable frequency from a typical of 24 Hz to 1526 Hz with a duty cycle that is adjustable from 0% to 100%. All outputs are set to the same PWM frequency.

Each channel output can be off or on (no PWM control), or set at its individual PWM controller value. The output driver is programmed to be either open-drain with a 25 mA current sink capability at 5 V or totem pole with a 25 mA sink, 10 mA source capability at 5 V. The PCA9685 operates with a supply voltage range of 2.3 V to 5.5 V and the inputs and outputs are 5.5 V tolerant. LEDs can be directly connected to the outputs (up to 25 mA, 5.5 V) or controlled with external drivers and a minimum amount of discrete components for larger current, higher voltage LEDs, etc. It is optimized to be used as an LED controller for Red/Green/Blue/Amber (RGBA) color backlighting applications.

Datasheet: PCA9685

Usage

Please find additional examples in this repository: driver-examples

To use this driver, import this crate and an embedded_hal implementation, then instantiate the appropriate device.

In this example we set a PWM frequency of 60 Hz and a duty cycle of 50% on channel 0.

use linux_embedded_hal::I2cdev;
use pwm_pca9685::{Address, Channel, Pca9685};

fn main() {
    let dev = I2cdev::new("/dev/i2c-1").unwrap();
    let address = Address::default();
    let mut pwm = Pca9685::new(dev, address).unwrap();

    // This corresponds to a frequency of 60 Hz.
    pwm.set_prescale(100).unwrap();

    // It is necessary to enable the device.
    pwm.enable().unwrap();

    // Turn on channel 0 at 0.
    pwm.set_channel_on(Channel::C0, 0).unwrap();

    // Turn off channel 0 at 2047, which is 50% in
    // the range `[0..4095]`.
    pwm.set_channel_off(Channel::C0, 2047).unwrap();

    let _dev = pwm.destroy(); // Get the I2C device back
}

Support

For questions, issues, feature requests, and other changes, please file an issue in the github project.

License

Licensed under either of

at your option.

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].