ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
mcp4728.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace esphome::mcp4728 {
7
8enum class CMD {
9 FAST_WRITE = 0x00,
10 MULTI_WRITE = 0x40,
11 SINGLE_WRITE = 0x58,
12 SEQ_WRITE = 0x50,
13 SELECT_VREF = 0x80,
14 SELECT_GAIN = 0xC0,
16};
17
19
26
28
30
37
39class MCP4728Component final : public Component, public i2c::I2CDevice {
40 public:
41 MCP4728Component(bool store_in_eeprom) : store_in_eeprom_(store_in_eeprom) {}
42
43 void setup() override;
44 void dump_config() override;
45 float get_setup_priority() const override { return setup_priority::HARDWARE; }
46 void loop() override;
47
49 void write_channel(uint8_t channel, float state);
50
51 protected:
52 bool multi_write_();
53 bool seq_write_();
54
55 private:
56 DACInputData reg_[4]{};
57 bool store_in_eeprom_ = false;
58 bool update_ = false;
59};
60
61} // namespace esphome::mcp4728
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
MCP4728 float output component.
Definition mcp4728.h:39
MCP4728Component(bool store_in_eeprom)
Definition mcp4728.h:41
void configure_channel(MCP4728ChannelIdx channel, MCP4728Vref vref, MCP4728Gain gain, MCP4728PwrDown pd)
Definition mcp4728.cpp:81
float get_setup_priority() const override
Definition mcp4728.h:45
void write_channel(uint8_t channel, float state)
Definition mcp4728.cpp:42
bool state
Definition fan.h:2
AlsGain501 gain
@ MCP4728_VREF_INTERNAL_2_8V
Definition mcp4728.h:18
@ MCP4728_PD_GND_100KOHM
Definition mcp4728.h:23
@ MCP4728_PD_GND_500KOHM
Definition mcp4728.h:24
constexpr float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition component.h:43