Skip to content

Commit e8d0bce

Browse files
committed
Appropriate SonarQube inspection changes
1 parent 81b3f1c commit e8d0bce

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Adafruit_TSL2561/Adafruit_TSL2561.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ def get_data(self):
233233
self.disable()
234234
logging.debug('getData_end"')
235235

236+
# noinspection PyMissingConstructor
236237
def __init__(self, address=TSL2561_ADDR_FLOAT, debug=False):
237238
"""
238239
Constructor
@@ -364,7 +365,7 @@ def get_luminosity(self):
364365
return
365366

366367
# Read data until we find a valid range */
367-
_agcCheck = False
368+
agc_check = False
368369
while not valid:
369370
_it = self._tsl2561IntegrationTime
370371

@@ -382,21 +383,21 @@ def get_luminosity(self):
382383
self.get_data()
383384

384385
# Run an auto-gain check if we haven't already done so ... */
385-
if not _agcCheck:
386+
if not agc_check:
386387
if (self._broadband < _lo) and (self._tsl2561Gain == self.TSL2561_GAIN_1X):
387388
# Increase the gain and try again */
388389
self.set_gain(self.TSL2561_GAIN_16X)
389390
# Drop the previous conversion results */
390391
self.get_data()
391392
# Set a flag to indicate we've adjusted the gain */
392-
_agcCheck = True
393+
agc_check = True
393394
elif (self._broadband > _hi) and (self._tsl2561Gain == self.TSL2561_GAIN_16X):
394395
# Drop gain to 1x and try again */
395396
self.set_gain(self.TSL2561_GAIN_1X)
396397
# Drop the previous conversion results */
397398
self.get_data()
398399
# Set a flag to indicate we've adjusted the gain */
399-
_agcCheck = True
400+
agc_check = True
400401
else:
401402
# Nothing to look at here, keep moving ....
402403
# Reading is either valid, or we're already at the chips limits */
@@ -436,7 +437,7 @@ def calculate_lux(self):
436437
elif self._tsl2561IntegrationTime ==self.TSL2561_INTEGRATIONTIME_101MS:
437438
ch_scale = self.TSL2561_LUX_CHSCALE_TINT1
438439
else:
439-
ch_scale = (1 << self.TSL2561_LUX_CHSCALE)
440+
ch_scale = 1 << self.TSL2561_LUX_CHSCALE
440441

441442
# Scale for gain (1x or 16x) */
442443
if not self._tsl2561Gain:
@@ -507,14 +508,14 @@ def calculate_lux(self):
507508
# endif
508509

509510
# noinspection PyUnboundLocalVariable,PyUnboundLocalVariable
510-
temp = ((channel0 * b) - (channel1 * m))
511+
temp = (channel0 * b) - (channel1 * m)
511512

512513
# Do not allow negative lux value */
513514
if temp < 0:
514515
temp = 0
515516

516517
# Round lsb (2^(LUX_SCALE-1)) */
517-
temp += (1 << (self.TSL2561_LUX_LUXSCALE - 1))
518+
temp += 1 << (self.TSL2561_LUX_LUXSCALE - 1)
518519

519520
# Strip off fractional portion */
520521
lux = temp >> self.TSL2561_LUX_LUXSCALE

0 commit comments

Comments
 (0)