ESPHome 2026.6.0-dev
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::mcp4728 {
7
9 const uint16_t max_duty = 4095;
10 const float duty_rounded = roundf(state * max_duty);
11 auto duty = static_cast<uint16_t>(duty_rounded);
12 this->parent_->set_channel_value_(this->channel_, duty);
13}
14
15} // namespace esphome::mcp4728
void write_state(float state) override
void set_channel_value_(MCP4728ChannelIdx channel, uint16_t value)
Definition mcp4728.cpp:45
bool state
Definition fan.h:2