25#ifndef DETERMINISTICESPASYNCWEBSERVER_PCA9685_H
26#define DETERMINISTICESPASYNCWEBSERVER_PCA9685_H
31#define PCA9685_CHANNELS 16
32#define PCA9685_COUNT_MAX 4095
33#define PCA9685_FULL_ON 0x1000
34#define PCA9685_FULL_OFF 0x1000
37#define PCA9685_REG_MODE1 0x00
38#define PCA9685_REG_MODE2 0x01
39#define PCA9685_REG_LED0_ON_L 0x06
40#define PCA9685_REG_PRESCALE 0xFE
bool pca9685_begin(uint8_t addr, uint32_t freq_hz)
Reset the PCA9685 at addr and set the PWM frequency freq_hz.
uint16_t pca9685_us_to_count(uint32_t microseconds, uint32_t freq_hz)
Convert a servo pulse width (microseconds) at freq_hz to a 12-bit OFF count (rounded),...
uint8_t pca9685_prescale(uint32_t freq_hz)
Compute the PRESCALE register value for a PWM output frequency (25 MHz oscillator): round(25e6 / (409...
bool pca9685_set_servo_us(uint8_t channel, uint32_t microseconds)
Drive a servo on channel to a microseconds pulse (uses the configured frequency).
bool pca9685_set_pwm(uint8_t channel, uint16_t on, uint16_t off)
Set channel's raw 12-bit ON / OFF counts.
uint8_t pca9685_channel_reg(uint8_t channel)
The register base (LED_ON_L) for channel (0..15); 0 for an out-of-range channel.
size_t pca9685_set_pwm_bytes(uint8_t *buf, size_t cap, uint8_t channel, uint16_t on, uint16_t off)
Emit the 5-byte channel PWM write: [LED_ON_L(channel), ON_L, ON_H, OFF_L, OFF_H] (each count 12-bit l...