ESPHome 2025.5.0
Loading...
Searching...
No Matches
mcp4728.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace esphome {
7namespace mcp4728 {
8
9enum class CMD {
10 FAST_WRITE = 0x00,
11 MULTI_WRITE = 0x40,
12 SINGLE_WRITE = 0x58,
13 SEQ_WRITE = 0x50,
14 SELECT_VREF = 0x80,
15 SELECT_GAIN = 0xC0,
17};
18
20
27
29
31
38
39class MCP4728Channel;
40
43 public:
44 MCP4728Component(bool store_in_eeprom) : store_in_eeprom_(store_in_eeprom) {}
45
46 void setup() override;
47 void dump_config() override;
48 float get_setup_priority() const override { return setup_priority::HARDWARE; }
49 void loop() override;
50
51 protected:
53 void set_channel_value_(MCP4728ChannelIdx channel, uint16_t value);
54 bool multi_write_();
55 bool seq_write_();
56 void select_vref_(MCP4728ChannelIdx channel, MCP4728Vref vref);
59
60 private:
61 DACInputData reg_[4];
62 bool store_in_eeprom_ = false;
63 bool update_ = false;
64};
65
66} // namespace mcp4728
67} // namespace esphome
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:133
MCP4728 float output component.
Definition mcp4728.h:42
void set_channel_value_(MCP4728ChannelIdx channel, uint16_t value)
Definition mcp4728.cpp:47
MCP4728Component(bool store_in_eeprom)
Definition mcp4728.h:44
void select_vref_(MCP4728ChannelIdx channel, MCP4728Vref vref)
Definition mcp4728.cpp:95
void select_gain_(MCP4728ChannelIdx channel, MCP4728Gain gain)
Definition mcp4728.cpp:107
float get_setup_priority() const override
Definition mcp4728.h:48
void select_power_down_(MCP4728ChannelIdx channel, MCP4728PwrDown pd)
Definition mcp4728.cpp:101
AlsGain501 gain
@ MCP4728_VREF_INTERNAL_2_8V
Definition mcp4728.h:19
@ MCP4728_PD_GND_100KOHM
Definition mcp4728.h:24
@ MCP4728_PD_GND_500KOHM
Definition mcp4728.h:25
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition component.cpp:18
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7