ESPHome 2026.5.0b1
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
38class MCP4728Channel;
39
42 public:
43 MCP4728Component(bool store_in_eeprom) : store_in_eeprom_(store_in_eeprom) {}
44
45 void setup() override;
46 void dump_config() override;
47 float get_setup_priority() const override { return setup_priority::HARDWARE; }
48 void loop() override;
49
50 protected:
52 void set_channel_value_(MCP4728ChannelIdx channel, uint16_t value);
53 bool multi_write_();
54 bool seq_write_();
55 void select_vref_(MCP4728ChannelIdx channel, MCP4728Vref vref);
58
59 private:
60 DACInputData reg_[4]{};
61 bool store_in_eeprom_ = false;
62 bool update_ = false;
63};
64
65} // namespace esphome::mcp4728
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:132
MCP4728 float output component.
Definition mcp4728.h:41
void set_channel_value_(MCP4728ChannelIdx channel, uint16_t value)
Definition mcp4728.cpp:45
MCP4728Component(bool store_in_eeprom)
Definition mcp4728.h:43
void select_vref_(MCP4728ChannelIdx channel, MCP4728Vref vref)
Definition mcp4728.cpp:93
void select_gain_(MCP4728ChannelIdx channel, MCP4728Gain gain)
Definition mcp4728.cpp:105
float get_setup_priority() const override
Definition mcp4728.h:47
void select_power_down_(MCP4728ChannelIdx channel, MCP4728PwrDown pd)
Definition mcp4728.cpp:99
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:41