ESPHome 2025.5.0
Loading...
Searching...
No Matches
pca9685_output.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome {
8namespace pca9685 {
9
11extern const uint8_t PCA9685_MODE_INVERTED;
13extern const uint8_t PCA9685_MODE_OUTPUT_ONACK;
15extern const uint8_t PCA9685_MODE_OUTPUT_TOTEM_POLE;
17extern const uint8_t PCA9685_MODE_OUTNE_HIGHZ;
19extern const uint8_t PCA9685_MODE_OUTNE_LOW;
20
21class PCA9685Output;
22
24 public:
25 void set_channel(uint8_t channel) { channel_ = channel; }
26 void set_parent(PCA9685Output *parent) { parent_ = parent; }
27
28 protected:
29 friend class PCA9685Output;
30
31 void write_state(float state) override;
32
33 uint8_t channel_;
35};
36
38class PCA9685Output : public Component, public i2c::I2CDevice {
39 public:
41
42 void register_channel(PCA9685Channel *channel);
43
44 void setup() override;
45 void dump_config() override;
46 float get_setup_priority() const override { return setup_priority::HARDWARE; }
47 void loop() override;
48 void set_extclk(bool extclk) { this->extclk_ = extclk; }
50
51 protected:
53
54 void set_channel_value_(uint8_t channel, uint16_t value) {
55 if (this->pwm_amounts_[channel] != value)
56 this->update_ = true;
57 this->pwm_amounts_[channel] = value;
58 }
59
61 uint8_t mode_;
62 bool extclk_ = false;
63
64 uint8_t min_channel_{0xFF};
65 uint8_t max_channel_{0x00};
66 uint16_t pwm_amounts_[16] = {
67 0,
68 };
69 bool update_{true};
70};
71
72} // namespace pca9685
73} // 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
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:18
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7