From bf7c8a29c20203a2a0605965ccc4365fa031d8b9 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Mon, 19 Aug 2024 12:10:29 +0300 Subject: [PATCH] ad7606: add handling in to_volts() method for 'int' and 'list' 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 --- adi/ad7606.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/adi/ad7606.py b/adi/ad7606.py index f32c54992..ecabc5784 100644 --- a/adi/ad7606.py +++ b/adi/ad7606.py @@ -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