File tree Expand file tree Collapse file tree 3 files changed +11
-21
lines changed Expand file tree Collapse file tree 3 files changed +11
-21
lines changed Original file line number Diff line number Diff line change 32
32
from time import sleep
33
33
from adafruit_bus_device import i2c_device
34
34
35
- _MCP4728_DEFAULT_ADDRESS = 0x60
35
+ MCP4728_DEFAULT_ADDRESS = 0x60
36
+
37
+ MCP4728A4_DEFAULT_ADDRESS = 0x64
36
38
37
39
_MCP4728_CH_A_MULTI_EEPROM = 0x50
38
40
@@ -115,7 +117,7 @@ class MCP4728:
115
117
116
118
"""
117
119
118
- def __init__ (self , i2c_bus , address : int = _MCP4728_DEFAULT_ADDRESS ):
120
+ def __init__ (self , i2c_bus , address : int = MCP4728_DEFAULT_ADDRESS ):
119
121
120
122
self .i2c_device = i2c_device .I2CDevice (i2c_bus , address )
121
123
Original file line number Diff line number Diff line change 1
1
# SPDX-FileCopyrightText: 2021 codenio (Aananth K)
2
-
3
2
# SPDX-License-Identifier: MIT
4
3
5
-
6
4
import board
7
-
8
5
import adafruit_mcp4728
9
6
10
-
11
7
i2c = board .I2C () # uses board.SCL and board.SDA
12
-
13
8
mcp4728 = adafruit_mcp4728 .MCP4728 (i2c )
14
9
15
-
16
10
mcp4728 .channel_a .value = 65535 # Voltage = VDD
17
-
18
11
mcp4728 .channel_b .value = int (65535 / 2 ) # VDD/2
19
-
20
12
mcp4728 .channel_c .value = int (65535 / 4 ) # VDD/4
21
-
22
13
mcp4728 .channel_d .value = 0 # 0V
23
14
24
-
25
15
mcp4728 .save_settings () # save current voltages into EEPROM
26
16
27
17
print ("Settings Saved into EEPROM" )
28
18
29
-
30
19
input ("Press Enter to modify the channel outputs..." )
31
20
32
-
33
21
mcp4728 .channel_a .value = 0 # Modify output
34
-
35
22
mcp4728 .channel_b .value = 0 # Modify output
36
-
37
23
mcp4728 .channel_c .value = 0 # Modify output
38
-
39
24
mcp4728 .channel_d .value = 65535 # Modify output
40
25
41
-
42
26
print ("Channel Outputs Modified" )
43
27
44
-
45
28
input ("Press Enter to invoke General Call Reset ..." )
46
29
47
-
48
30
mcp4728 .reset () # reset MCP4728
Original file line number Diff line number Diff line change 4
4
import board
5
5
import adafruit_mcp4728
6
6
7
+ MCP4728_DEFAULT_ADDRESS = 0x60
8
+ MCP4728A4_DEFAULT_ADDRESS = 0x64
9
+
7
10
i2c = board .I2C () # uses board.SCL and board.SDA
8
- mcp4728 = adafruit_mcp4728 .MCP4728 (i2c )
11
+ # use for MCP4728 variant
12
+ mcp4728 = adafruit_mcp4728 .MCP4728 (i2c , adafruit_mcp4728 .MCP4728_DEFAULT_ADDRESS )
13
+ # use for MCP4728A4 variant
14
+ # mcp4728 = adafruit_mcp4728.MCP4728(i2c, adafruit_mcp4728.MCP4728A4_DEFAULT_ADDRESS)
9
15
10
16
mcp4728 .channel_a .value = 65535 # Voltage = VDD
11
17
mcp4728 .channel_b .value = int (65535 / 2 ) # VDD/2
You can’t perform that action at this time.
0 commit comments