Skip to content

Commit b5d5733

Browse files
authored
Merge pull request #166 from craigargh/master
Pylint
2 parents 9cf83e8 + 97131f0 commit b5d5733

File tree

193 files changed

+3638
-2955
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+3638
-2955
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*~
22
Hue_Controller/secrets.h
3+
.idea

.pylintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ confidence=
5252
# no Warning level messages displayed, use"--disable=all --enable=classes
5353
# --disable=W"
5454
# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call
55-
disable=too-many-instance-attributes,len-as-condition,too-few-public-methods,anomalous-backslash-in-string,no-else-return,simplifiable-if-statement,too-many-arguments,duplicate-code,no-name-in-module,no-member,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,missing-docstring,invalid-name,bad-whitespace, --msg-template='{path} {line}: {msg} ({symbol})' */*.py
55+
disable=too-many-instance-attributes,len-as-condition,too-few-public-methods,anomalous-backslash-in-string,no-else-return,simplifiable-if-statement,too-many-arguments,duplicate-code,no-name-in-module,no-member,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,missing-docstring,invalid-name,bad-whitespace,unused-variable
5656

5757
# Enable the message, report, category or checker with the given id(s). You can
5858
# either give multiple identifier separated by comma (,) or put this option
@@ -72,7 +72,7 @@ evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / stateme
7272

7373
# Template used to display messages. This is a python new-style format string
7474
# used to format the message information. See doc for all details
75-
#msg-template=
75+
msg-template='{path} {line}: {msg} ({symbol})'
7676

7777
# Set the output format. Available formats are text, parseable, colorized, json
7878
# and msvs (visual studio).You can also give a reporter class, eg
Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,50 @@
11
# 3D_Printed_Guardian_Sword
22
# https://learn.adafruit.com/breath-of-the-wild-guardian-sword-led-3d-printed
33

4+
import time
5+
46
import board
57
import neopixel
6-
import time
78

8-
pin = board.D4 # DIGITAL IO pin for NeoPixel OUTPUT from GEMMA
9-
pixel_count = 93 # number of neopixels
10-
delayval = .01 # 10 ms delay
9+
pin = board.D4 # DIGITAL IO pin for NeoPixel OUTPUT from GEMMA
10+
pixel_count = 93 # number of neopixels
11+
delayval = .01 # 10 ms delay
1112

12-
APIXELS = 14 # number of first orange pixels
13-
BPIXELS = 84 # number of blue pixels
14-
CPIXELS = 93 # second orange pixels
13+
APIXELS = 14 # number of first orange pixels
14+
BPIXELS = 84 # number of blue pixels
15+
CPIXELS = 93 # second orange pixels
1516

1617
# initialize neopixels
1718
pixels = neopixel.NeoPixel(pin, pixel_count, brightness=1, auto_write=False)
1819

1920
while True:
2021

21-
# For the first 14 pixels, make them orange,
22+
# For the first 14 pixels, make them orange,
2223
# starting from pixel number 0.
23-
for i in range( 0, APIXELS ):
24-
# Set Pixels to Orange Color
25-
pixels[i] = ( 255, 50, 0 )
24+
for i in range(0, APIXELS):
25+
# Set Pixels to Orange Color
26+
pixels[i] = (255, 50, 0)
2627
# This sends the updated pixel color to the hardware.
27-
pixels.write()
28-
# Delay for a period of time (in milliseconds).
29-
time.sleep(delayval)
28+
pixels.write()
29+
# Delay for a period of time (in milliseconds).
30+
time.sleep(delayval)
3031

31-
# Fill up 84 pixels with blue,
32+
# Fill up 84 pixels with blue,
3233
# starting with pixel number 14.
33-
for i in range ( 14, BPIXELS ):
34-
# Set Pixels to Orange Color
35-
pixels[i] = ( 0, 250, 200 )
34+
for i in range(14, BPIXELS):
35+
# Set Pixels to Orange Color
36+
pixels[i] = (0, 250, 200)
3637
# This sends the updated pixel color to the hardware.
37-
pixels.write()
38-
# Delay for a period of time (in milliseconds).
39-
time.sleep(delayval)
38+
pixels.write()
39+
# Delay for a period of time (in milliseconds).
40+
time.sleep(delayval)
4041

41-
# Fill up 9 pixels with orange,
42+
# Fill up 9 pixels with orange,
4243
# starting from pixel number 84.
43-
for i in range ( 84, CPIXELS ):
44-
# Set Pixels to Orange Color
45-
pixels[i] = ( 250, 50, 0 )
44+
for i in range(84, CPIXELS):
45+
# Set Pixels to Orange Color
46+
pixels[i] = (250, 50, 0)
4647
# This sends the updated pixel color to the hardware.
47-
pixels.write()
48-
# Delay for a period of time (in milliseconds).
49-
time.sleep(delayval)
48+
pixels.write()
49+
# Delay for a period of time (in milliseconds).
50+
time.sleep(delayval)

3D_Printed_LED_Microphone_Flag/3D_Printed_LED_Microphone_Flag.py

Lines changed: 70 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -27,42 +27,46 @@
2727
# Modified fromhere code by Greg Shakar
2828
# Ported to Circuit Python by Mikey Sklar
2929

30+
import time
31+
3032
import board
3133
import neopixel
32-
import time
3334
from analogio import AnalogIn
34-
import array
35-
36-
n_pixels = 16 # Number of pixels you are using
37-
mic_pin = AnalogIn(board.A1) # Microphone is attached to this analog pin
38-
led_pin = board.D1 # NeoPixel LED strand is connected to this pin
39-
sample_window = .1 # Sample window for average level
40-
peak_hang = 24 # Time of pause before peak dot falls
41-
peak_fall = 4 # Rate of falling peak dot
42-
input_floor = 10 # Lower range of analogRead input
43-
input_ceiling = 300 # Max range of analogRead input, the lower the value the more sensitive (1023 = max)
44-
45-
peak = 16 # Peak level of column; used for falling dots
35+
36+
n_pixels = 16 # Number of pixels you are using
37+
mic_pin = AnalogIn(board.A1) # Microphone is attached to this analog pin
38+
led_pin = board.D1 # NeoPixel LED strand is connected to this pin
39+
sample_window = .1 # Sample window for average level
40+
peak_hang = 24 # Time of pause before peak dot falls
41+
peak_fall = 4 # Rate of falling peak dot
42+
input_floor = 10 # Lower range of analogRead input
43+
# Max range of analogRead input, the lower the value the more sensitive
44+
# (1023 = max)
45+
input_ceiling = 300
46+
47+
peak = 16 # Peak level of column; used for falling dots
4648
sample = 0
4749

48-
dotcount = 0 # Frame counter for peak dot
49-
dothangcount = 0 # Frame counter for holding peak dot
50+
dotcount = 0 # Frame counter for peak dot
51+
dothangcount = 0 # Frame counter for holding peak dot
5052

5153
strip = neopixel.NeoPixel(led_pin, n_pixels, brightness=1, auto_write=False)
5254

55+
5356
def wheel(pos):
5457
# Input a value 0 to 255 to get a color value.
5558
# The colours are a transition r - g - b - back to r.
56-
if (pos < 0) or (pos > 255):
59+
if pos < 0 or pos > 255:
5760
return (0, 0, 0)
58-
if (pos < 85):
59-
return (int(pos * 3), int(255 - (pos*3)), 0)
60-
elif (pos < 170):
61+
if pos < 85:
62+
return (int(pos * 3), int(255 - (pos * 3)), 0)
63+
elif pos < 170:
6164
pos -= 85
62-
return (int(255 - pos*3), 0, int(pos*3))
65+
return (int(255 - pos * 3), 0, int(pos * 3))
6366
else:
6467
pos -= 170
65-
return (0, int(pos*3), int(255 - pos*3))
68+
return (0, int(pos * 3), int(255 - pos * 3))
69+
6670

6771
def remapRange(value, leftMin, leftMax, rightMin, rightMax):
6872
# this remaps a value fromhere original (left) range to new (right) range
@@ -76,91 +80,89 @@ def remapRange(value, leftMin, leftMax, rightMin, rightMax):
7680
# Convert the 0-1 range into a value in the right range.
7781
return int(rightMin + (valueScaled * rightSpan))
7882

83+
7984
def fscale(originalmin, originalmax, newbegin, newend, inputvalue, curve):
80-
originalrange = 0
81-
newrange = 0
82-
zerorefcurval = 0
83-
normalizedcurval = 0
84-
rangedvalue = 0
8585
invflag = 0
8686

8787
# condition curve parameter
8888
# limit range
89-
if (curve > 10):
89+
if curve > 10:
9090
curve = 10
91-
if (curve < -10):
91+
if curve < -10:
9292
curve = -10
9393

94-
# - invert and scale -
95-
# this seems more intuitive
94+
# - invert and scale -
95+
# this seems more intuitive
9696
# postive numbers give more weight to high end on output
97-
curve = (curve * -.1)
98-
curve = pow(10, curve) # convert linear scale into lograthimic exponent for other pow function
97+
curve = (curve * -.1)
98+
# convert linear scale into lograthimic exponent for other pow function
99+
curve = pow(10, curve)
99100

100101
# Check for out of range inputValues
101-
if (inputvalue < originalmin):
102+
if inputvalue < originalmin:
102103
inputvalue = originalmin
103104

104-
if (inputvalue > originalmax):
105+
if inputvalue > originalmax:
105106
inputvalue = originalmax
106107

107108
# Zero Refference the values
108109
originalrange = originalmax - originalmin
109110

110-
if (newend > newbegin):
111+
if newend > newbegin:
111112
newrange = newend - newbegin
112113
else:
113114
newrange = newbegin - newend
114115
invflag = 1
115116

116117
zerorefcurval = inputvalue - originalmin
117-
normalizedcurval = zerorefcurval / originalrange # normalize to 0 - 1 float
118+
# normalize to 0 - 1 float
119+
normalizedcurval = zerorefcurval / originalrange
118120

119-
# Check for originalMin > originalMax
120-
# -the math for all other cases
121+
# Check for originalMin > originalMax
122+
# -the math for all other cases
121123
# i.e. negative numbers seems to work out fine
122-
if (originalmin > originalmax ):
123-
return(0)
124-
125-
if (invflag == 0):
126-
rangedvalue = (pow(normalizedcurval, curve) * newrange) + newbegin
127-
else: # invert the ranges
128-
rangedvalue = newbegin - (pow(normalizedcurval, curve) * newrange);
124+
if originalmin > originalmax:
125+
return 0
129126

130-
return(rangedvalue)
127+
if invflag == 0:
128+
rangedvalue = (pow(normalizedcurval, curve) * newrange) + newbegin
129+
else: # invert the ranges
130+
rangedvalue = newbegin - (pow(normalizedcurval, curve) * newrange)
131131

132-
def drawLine(fromhere, to):
132+
return rangedvalue
133133

134-
fromheretemp = 0
135134

136-
if (fromhere > to):
135+
def drawLine(fromhere, to):
136+
if fromhere > to:
137137
fromheretemp = fromhere
138138
fromhere = to
139139
to = fromheretemp
140140

141-
for i in range(fromhere, to):
142-
strip[i] = (0,0,0)
141+
for index in range(fromhere, to):
142+
strip[index] = (0, 0, 0)
143+
143144

144145
while True:
145146

146-
time_start = time.monotonic() # current time used for sample window
147-
peaktopeak = 0 # peak-to-peak level
147+
time_start = time.monotonic() # current time used for sample window
148+
peaktopeak = 0 # peak-to-peak level
148149
signalmax = 0
149-
signalmin = 1023
150+
signalmin = 1023
150151
c = 0
151152
y = 0
152153

153154
# collect data for length of sample window (in seconds)
154-
while ( ( time.monotonic() - time_start ) < sample_window):
155+
while (time.monotonic() - time_start) < sample_window:
155156

156-
sample = mic_pin.value / 64 # convert to arduino 10-bit [1024] fromhere 16-bit [65536]
157+
# convert to arduino 10-bit [1024] fromhere 16-bit [65536]
158+
sample = mic_pin.value / 64
157159

158-
if (sample < 1024): # toss out spurious readings
160+
if sample < 1024: # toss out spurious readings
159161

160-
if (sample > signalmax):
161-
signalmax = sample # save just the max levels
162-
elif (sample < signalmin):
163-
signalmin = sample # save just the min levels
162+
if sample > signalmax:
163+
signalmax = sample # save just the max levels
164+
elif sample < signalmin:
165+
signalmin = sample # save just the min levels
164166

165167
peaktopeak = signalmax - signalmin # max - min = peak-peak amplitude
166168

@@ -171,11 +173,11 @@ def drawLine(fromhere, to):
171173
# Scale the input logarithmically instead of linearly
172174
c = fscale(input_floor, input_ceiling, (n_pixels - 1), 0, peaktopeak, 2)
173175

174-
if (c < peak):
175-
peak = c # keep dot on top
176-
dothangcount = 0 # make the dot hang before falling
176+
if c < peak:
177+
peak = c # keep dot on top
178+
dothangcount = 0 # make the dot hang before falling
177179

178-
if (c <= n_pixels): # fill partial column with off pixels
180+
if c <= n_pixels: # fill partial column with off pixels
179181
drawLine(n_pixels, n_pixels - int(c))
180182

181183
# Set the peak dot to match the rainbow gradient
@@ -184,8 +186,9 @@ def drawLine(fromhere, to):
184186
strip.write()
185187

186188
# Frame based peak dot animation
187-
if(dothangcount > peak_hang): # Peak pause length
188-
if(++dotcount >= peak_fall): # Fall rate
189+
if dothangcount > peak_hang: # Peak pause length
190+
dotcount += 1
191+
if dotcount >= peak_fall: # Fall rate
189192
peak += 1
190193
dotcount = 0
191194
else:

0 commit comments

Comments
 (0)