Adafruit MCP4728 DAC Library
Public Member Functions | List of all members
Adafruit_MCP4728 Class Reference

Class that stores state and functions for interacting with the MCP4728 I2C Digital Potentiometer. More...

#include <Adafruit_MCP4728.h>

Public Member Functions

 Adafruit_MCP4728 ()
 Instantiates a new MCP4728 class.
 
bool begin (uint8_t i2c_address=MCP4728_I2CADDR_DEFAULT, TwoWire *wire=&Wire)
 Sets up the hardware and initializes I2C. More...
 
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. More...
 
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. More...
 
bool saveToEEPROM (void)
 Saves the DAC's input register settings to the internal EEPROM, makeing them the default values when the ADC is powered on. More...
 

Detailed Description

Class that stores state and functions for interacting with the MCP4728 I2C Digital Potentiometer.

Member Function Documentation

◆ begin()

boolean Adafruit_MCP4728::begin ( uint8_t  i2c_address = MCP4728_I2CADDR_DEFAULT,
TwoWire *  wire = &Wire 
)

Sets up the hardware and initializes I2C.

Parameters
i2c_addressThe I2C address to be used.
wireThe Wire object to be used for I2C connections.
Returns
True if initialization was successful, otherwise false.

◆ setChannelValue()

bool Adafruit_MCP4728::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.

Parameters
channelThe channel to update
new_valueThe new value to assign
new_vrefOptional vref setting - Defaults to MCP4728_VREF_VDD
new_gainOptional gain setting - Defaults to MCP4728_GAIN_1X
new_pd_modeOptional power down mode setting - Defaults to MCP4728_PD_MOOE_NORMAL
udacOptional UDAC setting - Defaults to false, latching immediately. Set to true to latch when the LDAC pin is pulled low
Returns
true if the write was successful
false if there was an error with I2C communication between the MCU and the DAC

◆ fastWrite()

bool Adafruit_MCP4728::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.

Parameters
channel_a_valueThe value to assign to channel A
channel_b_valueThe value to assign to channel B
channel_c_valueThe value to assign to channel C
channel_d_valueThe value to assign to channel D
Returns
true if the write was successful
false if there was an error with I2C communication between the MCU and the DAC

◆ saveToEEPROM()

bool Adafruit_MCP4728::saveToEEPROM ( void  )

Saves the DAC's input register settings to the internal EEPROM, makeing them the default values when the ADC is powered on.

Returns
true if the write was successful
false if there was an error with I2C communication between the MCU and the DAC

The documentation for this class was generated from the following files: