Skip to content

Updating for MCP4728A4 #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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