Skip to content

Commit 367e4d7

Browse files
committed
Updating for CI
Updating for CI
1 parent e89e726 commit 367e4d7

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

adafruit_mcp4728.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def __init__(self, dac_instance, cache_page, index):
289289
@property
290290
def normalized_value(self):
291291
"""The DAC value as a floating point number in the range 0.0 to 1.0."""
292-
return self.raw_value / (2 ** 12 - 1)
292+
return self.raw_value / (2**12 - 1)
293293

294294
@normalized_value.setter
295295
def normalized_value(self, value):
@@ -302,13 +302,13 @@ def normalized_value(self, value):
302302
def value(self):
303303
"""The 16-bit scaled current value for the channel. Note that the MCP4728 is a 12-bit piece
304304
so quantization errors will occur"""
305-
return self.normalized_value * (2 ** 16 - 1)
305+
return self.normalized_value * (2**16 - 1)
306306

307307
@value.setter
308308
def value(self, value):
309-
if value < 0 or value > (2 ** 16 - 1):
309+
if value < 0 or value > (2**16 - 1):
310310
raise AttributeError(
311-
"`value` must be a 16-bit integer between 0 and %s" % (2 ** 16 - 1)
311+
"`value` must be a 16-bit integer between 0 and %s" % (2**16 - 1)
312312
)
313313

314314
# Scale from 16-bit to 12-bit value (quantization errors will occur!).
@@ -321,9 +321,9 @@ def raw_value(self):
321321

322322
@raw_value.setter
323323
def raw_value(self, value):
324-
if value < 0 or value > (2 ** 12 - 1):
324+
if value < 0 or value > (2**12 - 1):
325325
raise AttributeError(
326-
"`raw_value` must be a 12-bit integer between 0 and %s" % (2 ** 12 - 1)
326+
"`raw_value` must be a 12-bit integer between 0 and %s" % (2**12 - 1)
327327
)
328328
self._raw_value = value
329329
# disabling the protected access warning here because making it public would be

examples/mcp4728_generalcalltest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,48 @@
11
# SPDX-FileCopyrightText: 2021 codenio (Aananth K)
2+
23
# SPDX-License-Identifier: MIT
34

5+
46
import board
7+
58
import adafruit_mcp4728
69

10+
711
i2c = board.I2C() # uses board.SCL and board.SDA
12+
813
mcp4728 = adafruit_mcp4728.MCP4728(i2c)
914

15+
1016
mcp4728.channel_a.value = 65535 # Voltage = VDD
17+
1118
mcp4728.channel_b.value = int(65535 / 2) # VDD/2
19+
1220
mcp4728.channel_c.value = int(65535 / 4) # VDD/4
21+
1322
mcp4728.channel_d.value = 0 # 0V
1423

24+
1525
mcp4728.save_settings() # save current voltages into EEPROM
26+
1627
print("Settings Saved into EEPROM")
1728

29+
1830
input("Press Enter to modify the channel outputs...")
1931

32+
2033
mcp4728.channel_a.value = 0 # Modify output
34+
2135
mcp4728.channel_b.value = 0 # Modify output
36+
2237
mcp4728.channel_c.value = 0 # Modify output
38+
2339
mcp4728.channel_d.value = 65535 # Modify output
2440

41+
2542
print("Channel Outputs Modified")
2643

44+
2745
input("Press Enter to invoke General Call Reset ...")
2846

47+
2948
mcp4728.reset() # reset MCP4728

0 commit comments

Comments
 (0)