Skip to content

Commit

Permalink
Merge pull request #13 from adafruit/MCP4728A4_update
Browse files Browse the repository at this point in the history
Updating for MCP4728A4
  • Loading branch information
tekktrik committed Aug 8, 2022
2 parents 99c8739 + ca6e96b commit b9abe1f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 4 additions & 2 deletions adafruit_mcp4728.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
from time import sleep
from adafruit_bus_device import i2c_device

_MCP4728_DEFAULT_ADDRESS = 0x60
MCP4728_DEFAULT_ADDRESS = 0x60

MCP4728A4_DEFAULT_ADDRESS = 0x64

_MCP4728_CH_A_MULTI_EEPROM = 0x50

Expand Down Expand Up @@ -115,7 +117,7 @@ class MCP4728:
"""

def __init__(self, i2c_bus, address=_MCP4728_DEFAULT_ADDRESS):
def __init__(self, i2c_bus, address: int = MCP4728_DEFAULT_ADDRESS):

self.i2c_device = i2c_device.I2CDevice(i2c_bus, address)

Expand Down
1 change: 1 addition & 0 deletions examples/mcp4728_generalcalltest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
mcp4728.channel_d.value = 0 # 0V

mcp4728.save_settings() # save current voltages into EEPROM

print("Settings Saved into EEPROM")

input("Press Enter to modify the channel outputs...")
Expand Down
8 changes: 7 additions & 1 deletion examples/mcp4728_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
import board
import adafruit_mcp4728

MCP4728_DEFAULT_ADDRESS = 0x60
MCP4728A4_DEFAULT_ADDRESS = 0x64

i2c = board.I2C() # uses board.SCL and board.SDA
mcp4728 = adafruit_mcp4728.MCP4728(i2c)
# use for MCP4728 variant
mcp4728 = adafruit_mcp4728.MCP4728(i2c, adafruit_mcp4728.MCP4728_DEFAULT_ADDRESS)
# use for MCP4728A4 variant
# mcp4728 = adafruit_mcp4728.MCP4728(i2c, adafruit_mcp4728.MCP4728A4_DEFAULT_ADDRESS)

mcp4728.channel_a.value = 65535 # Voltage = VDD
mcp4728.channel_b.value = int(65535 / 2) # VDD/2
Expand Down

0 comments on commit b9abe1f

Please sign in to comment.