Files
esphome/esphome/components/mcp4728/output/mcp4728_output.h
Jesse Hills 223596a25f Mark user-configurable classes as final (part 10/21)
Add the C++ `final` specifier to leaf, user-configurable component classes and
automation action/trigger/condition primitives so that classes meant to be
terminal cannot be subclassed by external components. Only classes never used as
a base anywhere in the tree are marked. Part 10 of 21, split alphabetically by
component (matrix_keypad .. micronova).
2026-06-15 13:20:32 +12:00

31 lines
799 B
C++

#pragma once
#include "../mcp4728.h"
#include "esphome/core/component.h"
#include "esphome/components/output/float_output.h"
#include "esphome/components/i2c/i2c.h"
namespace esphome::mcp4728 {
class MCP4728Channel final : public output::FloatOutput {
public:
MCP4728Channel(MCP4728Component *parent, MCP4728ChannelIdx channel, MCP4728Vref vref, MCP4728Gain gain,
MCP4728PwrDown pwrdown)
: parent_(parent), channel_(channel) {
// update VREF
parent->select_vref_(channel, vref);
// update PD
parent->select_power_down_(channel, pwrdown);
// update GAIN
parent->select_gain_(channel, gain);
}
protected:
void write_state(float state) override;
MCP4728Component *parent_;
MCP4728ChannelIdx channel_;
};
} // namespace esphome::mcp4728