ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
pca9685_output.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace esphome::pca9685 {
7
8enum class PhaseBalancer {
9 NONE = 0x00,
10 LINEAR = 0x01,
11};
12
14inline constexpr uint8_t PCA9685_MODE_INVERTED = 0x10;
16inline constexpr uint8_t PCA9685_MODE_OUTPUT_ONACK = 0x08;
18inline constexpr uint8_t PCA9685_MODE_OUTPUT_TOTEM_POLE = 0x04;
20inline constexpr uint8_t PCA9685_MODE_OUTNE_HIGHZ = 0x02;
22inline constexpr uint8_t PCA9685_MODE_OUTNE_LOW = 0x01;
23
25class PCA9685Output final : public Component, public i2c::I2CDevice {
26 public:
28
29 void register_channel(uint8_t channel);
30 void write_channel(uint8_t channel, float state);
31
32 void setup() override;
33 void dump_config() override;
34 float get_setup_priority() const override { return setup_priority::HARDWARE; }
35 void loop() override;
36 void set_extclk(bool extclk) { this->extclk_ = extclk; }
38 void set_phase_balancer(PhaseBalancer balancer) { this->balancer_ = balancer; }
39
40 protected:
42 bool setup_registers_();
44 uint8_t mode_;
45 bool extclk_ = false;
47
48 uint8_t min_channel_{0xFF};
49 uint8_t max_channel_{0x00};
50 uint16_t pwm_amounts_[16] = {
51 0,
52 };
53 bool update_{true};
54};
55
56} // namespace esphome::pca9685
BedjetMode mode
BedJet operating mode.
uint16_le_t frequency
Definition bl0942.h:6
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
PCA9685 float output component.
PCA9685Output(uint8_t mode=PCA9685_MODE_OUTPUT_ONACK|PCA9685_MODE_OUTPUT_TOTEM_POLE)
void set_frequency(float frequency)
void write_channel(uint8_t channel, float state)
float get_setup_priority() const override
bool setup_registers_()
Configure the chip; false on an I2C failure.
void set_phase_balancer(PhaseBalancer balancer)
void register_channel(uint8_t channel)
bool state
Definition fan.h:2
constexpr uint8_t PCA9685_MODE_INVERTED
Inverts polarity of channel output signal.
constexpr uint8_t PCA9685_MODE_OUTPUT_TOTEM_POLE
Use a totem-pole (push-pull) style output rather than an open-drain structure.
constexpr uint8_t PCA9685_MODE_OUTNE_LOW
Similarly, sets channel output to high if in totem-pole mode, otherwise.
constexpr uint8_t PCA9685_MODE_OUTNE_HIGHZ
For active low output enable, sets channel output to high-impedance state.
constexpr uint8_t PCA9685_MODE_OUTPUT_ONACK
Channel update happens upon ACK (post-set) rather than on STOP (endTransmission)
constexpr float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition component.h:43