Adafruit MCP4728 DAC Library
Adafruit_MCP4728.h
Go to the documentation of this file.
1 
17 #ifndef _ADAFRUIT_MCP4728_H
18 #define _ADAFRUIT_MCP4728_H
19 
20 #include "Arduino.h"
21 #include <Adafruit_BusIO_Register.h>
22 #include <Adafruit_I2CDevice.h>
23 #include <Wire.h>
24 
25 #define MCP4728_I2CADDR_DEFAULT 0x60
26 
27 #define MCP4728_MULTI_IR_CMD \
28  0x40
29 #define MCP4728_MULTI_EEPROM_CMD \
30  0x50
31 #define MCP4728_FAST_WRITE_CMD \
32  0xC0
33 
34 
40 typedef enum pd_mode {
50 
56 typedef enum gain {
57  MCP4728_GAIN_1X,
58  MCP4728_GAIN_2X,
60 
66 typedef enum vref {
67  MCP4728_VREF_VDD,
68  MCP4728_VREF_INTERNAL,
70 
76 typedef enum channel {
77  MCP4728_CHANNEL_A,
78  MCP4728_CHANNEL_B,
79  MCP4728_CHANNEL_C,
80  MCP4728_CHANNEL_D,
82 
88 public:
90  bool begin(uint8_t i2c_address = MCP4728_I2CADDR_DEFAULT,
91  TwoWire *wire = &Wire);
92 
93  bool setChannelValue(MCP4728_channel_t channel, uint16_t new_value,
94  MCP4728_vref_t new_vref = MCP4728_VREF_VDD,
95  MCP4728_gain_t new_gain = MCP4728_GAIN_1X,
97  bool udac = false);
98 
99  bool fastWrite(uint16_t channel_a_value, uint16_t channel_b_value,
100  uint16_t channel_c_value, uint16_t channel_d_value);
101  bool saveToEEPROM(void);
102 
103 private:
104  bool _init(void);
105 
106  Adafruit_I2CDevice *i2c_dev;
107 };
108 
109 #endif
channel
Example enum values.
Definition: Adafruit_MCP4728.h:76
enum gain MCP4728_gain_t
Example enum values.
bool begin(uint8_t i2c_address=MCP4728_I2CADDR_DEFAULT, TwoWire *wire=&Wire)
Sets up the hardware and initializes I2C.
Definition: Adafruit_MCP4728.cpp:52
Definition: Adafruit_MCP4728.h:45
bool fastWrite(uint16_t channel_a_value, uint16_t channel_b_value, uint16_t channel_c_value, uint16_t channel_d_value)
Set the values of all four channels simultaneously with minimal delay or configuration.
Definition: Adafruit_MCP4728.cpp:116
Adafruit_MCP4728()
Instantiates a new MCP4728 class.
Definition: Adafruit_MCP4728.cpp:42
enum channel MCP4728_channel_t
Example enum values.
Definition: Adafruit_MCP4728.h:43
bool saveToEEPROM(void)
Saves the DAC&#39;s input register settings to the internal EEPROM, makeing them the default values when ...
Definition: Adafruit_MCP4728.cpp:149
Class that stores state and functions for interacting with the MCP4728 I2C Digital Potentiometer...
Definition: Adafruit_MCP4728.h:87
Definition: Adafruit_MCP4728.h:41
gain
Example enum values.
Definition: Adafruit_MCP4728.h:56
vref
Ex.
Definition: Adafruit_MCP4728.h:66
#define MCP4728_I2CADDR_DEFAULT
MCP4728 default i2c address.
Definition: Adafruit_MCP4728.h:25
enum vref MCP4728_vref_t
Ex.
pd_mode
Power status values.
Definition: Adafruit_MCP4728.h:40
Definition: Adafruit_MCP4728.h:47
bool setChannelValue(MCP4728_channel_t channel, uint16_t new_value, MCP4728_vref_t new_vref=MCP4728_VREF_VDD, MCP4728_gain_t new_gain=MCP4728_GAIN_1X, MCP4728_pd_mode_t new_pd_mode=MCP4728_PD_MODE_NORMAL, bool udac=false)
Sets the input register for a given channel to the specified settings.
Definition: Adafruit_MCP4728.cpp:78
enum pd_mode MCP4728_pd_mode_t
Power status values.