ESPHome  2024.4.0
sx1509_float_output.cpp
Go to the documentation of this file.
1 #include "sx1509_float_output.h"
2 #include "esphome/core/helpers.h"
3 #include "esphome/core/log.h"
4 
5 namespace esphome {
6 namespace sx1509 {
7 
8 static 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_);
19  this->parent_->pin_mode(this->pin_, gpio::FLAG_OUTPUT);
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.
Definition: binary_output.h:51
void set_pin_value(uint8_t pin, uint8_t i_on)
Definition: sx1509.h:41
const char *const TAG
Definition: spi.cpp:8
void pin_mode(uint8_t pin, gpio::Flags flags)
Definition: sx1509.cpp:88
void setup_led_driver(uint8_t pin)
Definition: sx1509.cpp:118
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
bool state
Definition: fan.h:34