@@ -51,7 +51,8 @@ def read_adc_difference(self, differential, gain=1, data_rate=None):
51
51
- 2 = Channel 1 minus channel 3
52
52
- 3 = Channel 2 minus channel 3
53
53
"""
54
- assert 0 <= differential <= 3 , 'Differential must be a value within 0-3!'
54
+ if not 0 <= differential <= 3 :
55
+ raise ValueError ('Differential must be a value within 0-3!' )
55
56
# Perform a single shot read using the provided differential value
56
57
# as the mux value (which will enable differential mode).
57
58
return self ._read (differential , gain , data_rate , ADS1X15_CONFIG_MODE_SINGLE )
@@ -64,7 +65,8 @@ def read_volts_difference(self, differential, gain=1, data_rate=None):
64
65
- 2 = Channel 1 minus channel 3
65
66
- 3 = Channel 2 minus channel 3
66
67
"""
67
- assert 0 <= differential <= 3 , 'Differential must be a value within 0-3!'
68
+ if not 0 <= differential <= 3 :
69
+ raise ValueError ('Differential must be a value within 0-3!' )
68
70
raw = self .read_adc_difference (differential , gain , data_rate )
69
71
volts = raw * (ADS1X15_PGA_RANGE [gain ] / (2 ** (self .bits - 1 ) - 1 ))
70
72
return volts
@@ -80,7 +82,8 @@ def start_adc_difference(self, differential, gain=1, data_rate=None):
80
82
function continuously to read the most recent conversion result. Call
81
83
stop_adc() to stop conversions.
82
84
"""
83
- assert 0 <= differential <= 3 , 'Differential must be a value within 0-3!'
85
+ if not 0 <= differential <= 3 :
86
+ raise ValueError ('Differential must be a value within 0-3!' )
84
87
# Perform a single shot read using the provided differential value
85
88
# as the mux value (which will enable differential mode).
86
89
return self ._read (differential , gain , data_rate , ADS1X15_CONFIG_MODE_CONTINUOUS )
0 commit comments