ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
sx1509_float_output.cpp
Go to the documentation of this file.
3#include "esphome/core/log.h"
4
5namespace esphome::sx1509 {
6
7static const char *const TAG = "sx1509_float_channel";
8
10 const uint16_t max_duty = 255;
11 const float duty_rounded = roundf(state * max_duty);
12 auto duty = static_cast<uint16_t>(duty_rounded);
13 this->parent_->set_pin_value(this->pin_, duty);
14}
15
17 ESP_LOGD(TAG, "Pin %d", this->pin_);
19 this->parent_->setup_led_driver(this->pin_);
20 this->turn_off();
21}
22
24 ESP_LOGCONFIG(TAG,
25 "SX1509 PWM:\n"
26 " sx1509 pin: %d",
27 this->pin_);
28 LOG_FLOAT_OUTPUT(this);
29}
30
31} // namespace esphome::sx1509
virtual void turn_off()
Disable this binary output.
void pin_mode(uint8_t pin, gpio::Flags flags)
Definition sx1509.cpp:114
void setup_led_driver(uint8_t pin)
Definition sx1509.cpp:174
void set_pin_value(uint8_t pin, uint8_t i_on)
Definition sx1509.h:46
bool state
Definition fan.h:2
@ FLAG_OUTPUT
Definition gpio.h:28
const char *const TAG
Definition spi.cpp:7
Here you'll find the Arduino code used to interface with the SX1509 I2C 16 I/O expander.