mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 13:45:15 +00:00
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).
31 lines
799 B
C++
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
|