Skip to content

Commit

Permalink
ad4080: add device_name parameter
Browse files Browse the repository at this point in the history
Make the device_name parameter explicit.

Signed-off-by: Antoniu Miclaus <[email protected]>
  • Loading branch information
amiclaus authored and PopPaul2021 committed Jul 10, 2024
1 parent 3134f81 commit 5687d39
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions adi/ad4080.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,26 @@ class ad4080(rx, context_manager):

""" AD4080 ADC """

_compatible_parts = ["ad4080"]
_complex_data = False
_rx_channel_names = ["voltage0"]
_device_name = "ad4080"
_device_name = ""

def __init__(self, uri=""):
def __init__(self, uri="", device_name="ad4080"):

"""Initialize."""
context_manager.__init__(self, uri, self._device_name)

self._rxadc = self._ctx.find_device("ad4080")
self._ctrl = self._ctx.find_device("ad4080")
if device_name not in self._compatible_parts:
raise Exception(
"Not a compatible device: "
+ str(device_name)
+ ". Please select from "
+ str(self.self._compatible_parts)
)
else:
self._ctrl = self._ctx.find_device(device_name)
self._rxadc = self._ctx.find_device(device_name)

rx.__init__(self)

Expand Down
2 changes: 1 addition & 1 deletion examples/ad4080_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
my_uri = sys.argv[1] if len(sys.argv) >= 2 else "ip:analog.local"
print("uri: " + str(my_uri))

my_adc = ad4080(uri=my_uri)
my_adc = ad4080(uri=my_uri, device_name="ad4080")

print("Sampling frequency: ", my_adc.sampling_frequency)
print("Test mode: ", my_adc.test_mode)
Expand Down

0 comments on commit 5687d39

Please sign in to comment.