Skip to content

Commit 36fd4fd

Browse files
committed
Fixed pylint issues
1 parent e197ba5 commit 36fd4fd

8 files changed

+95
-106
lines changed

examples/example1_basic_lightning_i2c.py

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
event occurs.
2626
"""
2727

28-
import sys
2928
from time import sleep
3029
import board
3130
import busio
@@ -47,37 +46,35 @@
4746
lightning = sparkfun_qwiicas3935.Sparkfun_QwiicAS3935_I2C(i2c)
4847

4948
# define functions
50-
def reduce_noise():
51-
global noise_floor
52-
"""This function helps to adjust the sensor to your environment. More
53-
environmental noise leads to more false positives. If you see lots of noise
54-
events, try increasing the noise threshold with this function. The datsheet
55-
warns that smartphone and smart watch displays, DC-DC converters, and/or
56-
anything that operates in 500 kHz range are noise sources to be avoided.
57-
The manufacturer's default value is 2 with a maximum value of 7."""
58-
noise_floor += 1
59-
60-
if noise_floor > 7:
49+
def reduce_noise(value):
50+
# This function helps to adjust the sensor to your environment. More
51+
# environmental noise leads to more false positives. If you see lots of noise
52+
# events, try increasing the noise threshold with this function. The datsheet
53+
# warns that smartphone and smart watch displays, DC-DC converters, and/or
54+
# anything that operates in 500 kHz range are noise sources to be avoided.
55+
# The manufacturer's default value is 2 with a maximum value of 7."""
56+
value += 1
57+
58+
if value > 7:
6159
print('Noise floor is at the maximum value.')
6260
return
63-
print('Increasing the noise event threshold to ', noise_floor)
64-
lightning.noise_level = noise_floor
65-
66-
67-
def increase_watchdog_threshold():
68-
"""This function is similar to the one above in that it will increase the
69-
antenna's robustness against false positives. However, this function helps
70-
to increase the robustness against "distrubers" and not "noise". If you
71-
have a lot of disturbers trying increasing the watchdog threshold.
72-
The default value is 2 and goes up to 10."""
73-
global threshold
74-
75-
watchdog_threshold += 1
76-
if watchdog_threshold > 10:
61+
print('Increasing the noise event threshold to ', value)
62+
lightning.noise_level = value
63+
return value
64+
65+
def increase_threshold(value):
66+
# This function is similar to the one above in that it will increase the
67+
# antenna's robustness against false positives. However, this function helps
68+
# to increase the robustness against "distrubers" and not "noise". If you
69+
# have a lot of disturbers trying increasing the watchdog threshold.
70+
# The default value is 2 and goes up to 10.
71+
72+
value += 1
73+
if value > 10:
7774
print('Watchdog threshold is at its maximum value')
7875
return
79-
print('Increasing the disturber watchdog threshold to ', watchdog_threshold)
80-
lightning.watchdog_threshold = watchdog_threshold
76+
print('Increasing the disturber watchdog threshold to ', value)
77+
lightning.watchdog_threshold = value
8178

8279
# main code
8380

@@ -109,12 +106,14 @@ def increase_watchdog_threshold():
109106

110107
if interrupt_value == lightning.NOISE:
111108
print('Noise.')
112-
# uncomment line below to adjust the noise level (see function comments above)
113-
# reduce_noise()
109+
# uncomment line below to adjust the noise level
110+
#(see function comments above)
111+
# noise_floor = reduce_noise(noise_floor)
114112
elif interrupt_value == lightning.DISTURBER:
115113
print('Disturber.')
116-
# uncomment the line below to adjust the watchdog threshold (see function comments above)
117-
# increase_watchdog_threshold()
114+
# uncomment the line below to adjust the watchdog threshold
115+
#(see function comments above)
116+
# watchdog_threshold = increase_threshold(watchdog_threshold)
118117
elif interrupt_value == lightning.LIGHTNING:
119118
print('Lightning strike detected!')
120119
print('Approximately: ' + str(lightning.distance_to_storm) + 'km away!')

examples/example1_basic_lightning_spi.py

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
event occurs.
2626
"""
2727

28-
import sys
2928
from time import sleep
3029
import board
3130
import busio
@@ -51,37 +50,36 @@
5150
lightning = sparkfun_qwiicas3935.Sparkfun_QwiicAS3935_SPI(spi, cs)
5251

5352
# define functions
54-
def reduce_noise():
55-
global noise_floor
56-
"""This function helps to adjust the sensor to your environment. More
57-
environmental noise leads to more false positives. If you see lots of noise
58-
events, try increasing the noise threshold with this function. The datsheet
59-
warns that smartphone and smart watch displays, DC-DC converters, and/or
60-
anything that operates in 500 kHz range are noise sources to be avoided.
61-
The manufacturer's default value is 2 with a maximum value of 7."""
62-
noise_floor += 1
63-
64-
if noise_floor > 7:
53+
def reduce_noise(value):
54+
# This function helps to adjust the sensor to your environment. More
55+
# environmental noise leads to more false positives. If you see lots of noise
56+
# events, try increasing the noise threshold with this function. The datsheet
57+
# warns that smartphone and smart watch displays, DC-DC converters, and/or
58+
# anything that operates in 500 kHz range are noise sources to be avoided.
59+
# The manufacturer's default value is 2 with a maximum value of 7.
60+
value += 1
61+
62+
if value > 7:
6563
print('Noise floor is at the maximum value.')
6664
return
67-
print('Increasing the noise event threshold to ', noise_floor)
68-
lightning.noise_level = noise_floor
69-
70-
71-
def increase_watchdog_threshold():
72-
"""This function is similar to the one above in that it will increase the
73-
antenna's robustness against false positives. However, this function helps
74-
to increase the robustness against "distrubers" and not "noise". If you
75-
have a lot of disturbers trying increasing the watchdog threshold.
76-
The default value is 2 and goes up to 10."""
77-
global threshold
78-
79-
watchdog_threshold += 1
80-
if watchdog_threshold > 10:
65+
print('Increasing the noise event threshold to ', value)
66+
lightning.noise_level = value
67+
return value
68+
69+
def increase_threshold(value):
70+
# This function is similar to the one above in that it will increase the
71+
# antenna's robustness against false positives. However, this function helps
72+
# to increase the robustness against "distrubers" and not "noise". If you
73+
# have a lot of disturbers trying increasing the watchdog threshold.
74+
# The default value is 2 and goes up to 10."""
75+
76+
value += 1
77+
if value > 10:
8178
print('Watchdog threshold is at its maximum value')
8279
return
83-
print('Increasing the disturber watchdog threshold to ', watchdog_threshold)
84-
lightning.watchdog_threshold = watchdog_threshold
80+
print('Increasing the disturber watchdog threshold to ', value)
81+
lightning.watchdog_threshold = value
82+
return value
8583

8684
# main code
8785

@@ -114,11 +112,12 @@ def increase_watchdog_threshold():
114112
if interrupt_value == lightning.NOISE:
115113
print('Noise.')
116114
# uncomment line below to adjust the noise level (see function comments above)
117-
# reduce_noise()
115+
# noise_floor = reduce_noise(noise_floor)
118116
elif interrupt_value == lightning.DISTURBER:
119117
print('Disturber.')
120-
# uncomment the line below to adjust the watchdog threshold (see function comments above)
121-
# increase_watchdog_threshold()
118+
# uncomment the line below to adjust the watchdog threshold
119+
# (see function comments above)
120+
# watchdog_threshold = increase_threshold(watchdog_threshold)
122121
elif interrupt_value == lightning.LIGHTNING:
123122
print('Lightning strike detected!')
124123
print('Approximately: ' + str(lightning.distance_to_storm) + 'km away!')
@@ -127,6 +126,3 @@ def increase_watchdog_threshold():
127126

128127
except KeyboardInterrupt:
129128
pass
130-
131-
132-

examples/example2_more_lightning_features_i2c.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
event occurs.
2323
"""
2424

25-
import sys
2625
from time import sleep
2726
import board
2827
import busio
@@ -152,6 +151,3 @@
152151

153152
except KeyboardInterrupt:
154153
pass
155-
156-
157-

examples/example2_more_lightning_features_spi.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
event occurs.
2323
"""
2424

25-
import sys
2625
from time import sleep
2726
import board
2827
import busio
@@ -155,6 +154,3 @@
155154

156155
except KeyboardInterrupt:
157156
pass
158-
159-
160-

examples/example3_tune_antenna_i2c.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
on the frequency divsior used) on the INT pin.
2020
"""
2121

22-
import sys
23-
from time import sleep
2422
import board
2523
import busio
2624
import digitalio

examples/example3_tune_antenna_spi.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
on the frequency divsior used) on the INT pin.
2020
"""
2121

22-
import sys
23-
from time import sleep
2422
import board
2523
import busio
2624
import digitalio

examples/qwiicas3935_simpletest.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
that status of the Qwiic AS3935 Lightning Detector.
1414
"""
1515

16-
from time import sleep
1716
import board
1817
import busio
1918
import sparkfun_qwiicas3935
@@ -44,4 +43,3 @@
4443
print('The Lightning Detector is in the Indoor mode.')
4544
else:
4645
print('The Lightning Detector is in an Unknown mode.')
47-

0 commit comments

Comments
 (0)