Skip to content

Commit

Permalink
ad7606: add handling in to_volts() method for 'int' and 'list'
Browse files Browse the repository at this point in the history
At least the 'raw' channel attribute returns int.
So,  'ad7606.to_volts(0, channel0.raw)' won't work with checking for numpy
types.

Signed-off-by: Alexandru Ardelean <aardelean@baylibre.com>
  • Loading branch information
commodo committed Aug 26, 2024
1 parent dee8914 commit 4351f41
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions adi/ad7606.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ def to_volts(self, index, val):
"""Converts raw value to SI"""
_scale = self.channel[index].scale

if isinstance(val, int):
return val * _scale

if isinstance(val, list):
return [x * _scale for x in val]

# ADC7606C-18 will return int32 samples from the driver
if isinstance(val, np.int32):
return val * _scale
Expand Down

0 comments on commit 4351f41

Please sign in to comment.