ESPHome
2025.5.0
Loading...
Searching...
No Matches
esphome
components
mcp4728
output
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
9
void
MCP4728Channel::write_state
(
float
state
) {
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
esphome::mcp4728::MCP4728Channel::write_state
void write_state(float state) override
Definition
mcp4728_output.cpp:9
esphome::mcp4728::MCP4728Channel::parent_
MCP4728Component * parent_
Definition
mcp4728_output.h:27
esphome::mcp4728::MCP4728Channel::channel_
MCP4728ChannelIdx channel_
Definition
mcp4728_output.h:28
esphome::mcp4728::MCP4728Component::set_channel_value_
void set_channel_value_(MCP4728ChannelIdx channel, uint16_t value)
Definition
mcp4728.cpp:47
state
bool state
Definition
fan.h:0
helpers.h
log.h
mcp4728_output.h
esphome
Providing packet encoding functions for exchanging data with a remote host.
Definition
a01nyub.cpp:7
Generated by
1.12.0