@@ -104,7 +104,7 @@ def duty_cycle(self):
104
104
105
105
@duty_cycle .setter
106
106
def duty_cycle (self , val ):
107
- if (0 > val ) or (65535 < val ):
107
+ if (val < 0 ) or (val > 65535 ):
108
108
raise ValueError ("PWM intensity {0} outside supported range [0;65535]" .format (val ))
109
109
# Convert to 12-bit value (quantization error will occur!).
110
110
val = (val >> 4 ) & 0xFFF
@@ -129,7 +129,7 @@ def frequency(self, val):
129
129
130
130
131
131
def __init__ (self , spi , latch , * , auto_write = True , num_drivers = 1 ):
132
- if ( 1 > num_drivers ) :
132
+ if num_drivers < 1 :
133
133
raise ValueError ("need at least one driver; {0} is not supported." .format (num_drivers ))
134
134
self ._spi = spi
135
135
self ._latch = latch
@@ -168,8 +168,9 @@ def write(self):
168
168
def _get_gs_value (self , channel ):
169
169
# pylint: disable=no-else-return
170
170
# Disable should be removed when refactor can be tested
171
- if (0 > channel ) or (_CHANNELS * self ._n <= channel ):
172
- raise ValueError ("channel {0} not available with {1} board(s)." .format (channel , self ._n ))
171
+ if (channel < 0 ) or (channel >= _CHANNELS * self ._n ):
172
+ raise ValueError (
173
+ "channel {0} not available with {1} board(s)." .format (channel , self ._n ))
173
174
# Invert channel position as the last channel needs to be written first.
174
175
# I.e. is in the first position of the shift registr.
175
176
channel = _CHANNELS * self ._n - 1 - channel
@@ -194,9 +195,10 @@ def _get_gs_value(self, channel):
194
195
raise RuntimeError ('Unsupported bit offset!' )
195
196
196
197
def _set_gs_value (self , channel , val ):
197
- if (0 > channel ) or (_CHANNELS * self ._n <= channel ):
198
- raise ValueError ("channel {0} not available with {1} board(s)." .format (channel , self ._n ))
199
- if (0 > val ) or (4095 < val ):
198
+ if (channel < 0 ) or (channel >= _CHANNELS * self ._n ):
199
+ raise ValueError (
200
+ "channel {0} not available with {1} board(s)." .format (channel , self ._n ))
201
+ if (val < 0 ) or (val > 4095 ):
200
202
raise ValueError ("PWM intensity {0} outside supported range [0;4095]" .format (val ))
201
203
202
204
# Invert channel position as the last channel needs to be written first.
0 commit comments