ESPHome 2025.5.0
Loading...
Searching...
No Matches
mcp4728_output.cpp
Go to the documentation of this file.
1#include "mcp4728_output.h"
2
4#include "esphome/core/log.h"
5
6namespace esphome {
7namespace 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 write_state(float state) override
void set_channel_value_(MCP4728ChannelIdx channel, uint16_t value)
Definition mcp4728.cpp:47
bool state
Definition fan.h:0
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7