ESPHome 2025.12.3
Loading...
Searching...
No Matches
pca9685_output.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome {
8namespace pca9685 {
9
10enum class PhaseBalancer {
11 NONE = 0x00,
12 LINEAR = 0x01,
13};
14
16extern const uint8_t PCA9685_MODE_INVERTED;
18extern const uint8_t PCA9685_MODE_OUTPUT_ONACK;
20extern const uint8_t PCA9685_MODE_OUTPUT_TOTEM_POLE;
22extern const uint8_t PCA9685_MODE_OUTNE_HIGHZ;
24extern const uint8_t PCA9685_MODE_OUTNE_LOW;
25
26class PCA9685Output;
27
29 public:
30 void set_channel(uint8_t channel) { channel_ = channel; }
31 void set_parent(PCA9685Output *parent) { parent_ = parent; }
32
33 protected:
34 friend class PCA9685Output;
35
36 void write_state(float state) override;
37
38 uint8_t channel_;
40};
41
43class PCA9685Output : public Component, public i2c::I2CDevice {
44 public:
46
47 void register_channel(PCA9685Channel *channel);
48
49 void setup() override;
50 void dump_config() override;
51 float get_setup_priority() const override { return setup_priority::HARDWARE; }
52 void loop() override;
53 void set_extclk(bool extclk) { this->extclk_ = extclk; }
55 void set_phase_balancer(PhaseBalancer balancer) { this->balancer_ = balancer; }
56
57 protected:
59
60 void set_channel_value_(uint8_t channel, uint16_t value) {
61 if (this->pwm_amounts_[channel] != value)
62 this->update_ = true;
63 this->pwm_amounts_[channel] = value;
64 }
65
67 uint8_t mode_;
68 bool extclk_ = false;
70
71 uint8_t min_channel_{0xFF};
72 uint8_t max_channel_{0x00};
73 uint16_t pwm_amounts_[16] = {
74 0,
75 };
76 bool update_{true};
77};
78
79} // namespace pca9685
80} // namespace esphome
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:133
Base class for all output components that can output a variable level, like PWM.
void write_state(float state) override
void set_parent(PCA9685Output *parent)
void set_channel(uint8_t channel)
PCA9685 float output component.
PCA9685Output(uint8_t mode=PCA9685_MODE_OUTPUT_ONACK|PCA9685_MODE_OUTPUT_TOTEM_POLE)
void set_channel_value_(uint8_t channel, uint16_t value)
void set_frequency(float frequency)
void register_channel(PCA9685Channel *channel)
float get_setup_priority() const override
void set_phase_balancer(PhaseBalancer balancer)
bool state
Definition fan.h:0
const uint8_t PCA9685_MODE_OUTPUT_ONACK
Channel update happens upon ACK (post-set) rather than on STOP (endTransmission)
const uint8_t PCA9685_MODE_OUTPUT_TOTEM_POLE
Use a totem-pole (push-pull) style output rather than an open-drain structure.
const uint8_t PCA9685_MODE_OUTNE_HIGHZ
For active low output enable, sets channel output to high-impedance state.
const uint8_t PCA9685_MODE_OUTNE_LOW
Similarly, sets channel output to high if in totem-pole mode, otherwise.
const uint8_t PCA9685_MODE_INVERTED
Inverts polarity of channel output signal.
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition component.cpp:80
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7