ESPHome 2025.5.0
Loading...
Searching...
No Matches
sx1509_float_output.cpp
Go to the documentation of this file.
3#include "esphome/core/log.h"
4
5namespace esphome {
6namespace sx1509 {
7
8static const char *const TAG = "sx1509_float_channel";
9
11 const uint16_t max_duty = 255;
12 const float duty_rounded = roundf(state * max_duty);
13 auto duty = static_cast<uint16_t>(duty_rounded);
14 this->parent_->set_pin_value(this->pin_, duty);
15}
16
18 ESP_LOGD(TAG, "setup pin %d", this->pin_);
20 this->parent_->setup_led_driver(this->pin_);
21 this->turn_off();
22}
23
25 ESP_LOGCONFIG(TAG, "SX1509 PWM:");
26 ESP_LOGCONFIG(TAG, " sx1509 pin: %d", this->pin_);
27 LOG_FLOAT_OUTPUT(this);
28}
29
30} // namespace sx1509
31} // namespace esphome
virtual void turn_off()
Disable this binary output.
void pin_mode(uint8_t pin, gpio::Flags flags)
Definition sx1509.cpp:88
void setup_led_driver(uint8_t pin)
Definition sx1509.cpp:148
void set_pin_value(uint8_t pin, uint8_t i_on)
Definition sx1509.h:41
bool state
Definition fan.h:0
@ FLAG_OUTPUT
Definition gpio.h:19
const char *const TAG
Definition spi.cpp:8
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7