ESPHome  2024.10.2
mcp4728_output.cpp
Go to the documentation of this file.
1 #include "mcp4728_output.h"
2 
3 #include "esphome/core/helpers.h"
4 #include "esphome/core/log.h"
5 
6 namespace esphome {
7 namespace mcp4728 {
8 
10  const uint16_t max_duty = 4095;
11  const float duty_rounded = roundf(state * max_duty);
12  auto duty = static_cast<uint16_t>(duty_rounded);
13  this->parent_->set_channel_value_(this->channel_, duty);
14 }
15 
16 } // namespace mcp4728
17 } // namespace esphome
void set_channel_value_(MCP4728ChannelIdx channel, uint16_t value)
Definition: mcp4728.cpp:47
void write_state(float state) override
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
bool state
Definition: fan.h:34