linting update
This commit is contained in:
parent
c49b0d0369
commit
67c2a02bbd
8 changed files with 20 additions and 12 deletions
|
|
@ -1,5 +1,5 @@
|
|||
from adafruit_circuitplayground.express import cpx
|
||||
import time
|
||||
from adafruit_circuitplayground.express import cpx
|
||||
|
||||
# Main loop gets x, y and z axis acceleration, prints the values, and turns on
|
||||
# red, green and blue, at levels related to the x, y and z values.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from adafruit_circuitplayground.express import cpx
|
||||
from adafruit_circuitplayground.express import cpx
|
||||
|
||||
cpx.pixels.brightness = 0.3
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,6 @@ cpx.detect_taps = 2
|
|||
# We're looking for 2 double-taps before moving on.
|
||||
while tap_count < 2:
|
||||
if cpx.tapped:
|
||||
tap_count += 1
|
||||
tap_count += 1
|
||||
print("Reached 2 double-taps!")
|
||||
print("Done.")
|
||||
print("Done.")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import time
|
||||
from adafruit_circuitplayground.express import cpx
|
||||
|
||||
while True:
|
||||
print("Slide switch:", cpx.switch)
|
||||
time.sleep(1)
|
||||
time.sleep(0.5)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
from express import cpx
|
||||
import array
|
||||
import math
|
||||
import audiobusio
|
||||
import board
|
||||
from adafruit_circuitplayground.express import cpx
|
||||
|
||||
|
||||
def constrain(value, floor, ceiling):
|
||||
|
|
@ -14,10 +16,13 @@ def log_scale(input_value, input_min, input_max, output_min, output_max):
|
|||
|
||||
def normalized_rms(values):
|
||||
minbuf = int(sum(values) / len(values))
|
||||
return math.sqrt(sum(float(sample - minbuf) * (sample - minbuf) for sample in values) / len(values))
|
||||
return math.sqrt(sum(float(sample - minbuf) *
|
||||
(sample - minbuf) for sample in values) / len(values))
|
||||
|
||||
|
||||
mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, frequency=16000, bit_depth=16)
|
||||
samples = array.array('H', [0] * 160)
|
||||
mic.record(samples, len(samples))
|
||||
input_floor = normalized_rms(samples) + 10
|
||||
|
||||
# Lower number means more sensitive - more LEDs will light up with less sound.
|
||||
|
|
@ -26,9 +31,11 @@ input_ceiling = input_floor + sensitivity
|
|||
|
||||
peak = 0
|
||||
while True:
|
||||
print(cpx.magnitude())
|
||||
mic.record(samples, len(samples))
|
||||
magnitude = normalized_rms(samples)
|
||||
print((magnitude,))
|
||||
|
||||
c = log_scale(constrain(cpx.magnitude(), input_floor, input_ceiling),
|
||||
c = log_scale(constrain(magnitude, input_floor, input_ceiling),
|
||||
input_floor, input_ceiling, 0, 10)
|
||||
|
||||
cpx.pixels.fill((0, 0, 0))
|
||||
|
|
|
|||
|
|
@ -6,4 +6,4 @@ while True:
|
|||
elif cpx.button_b:
|
||||
cpx.start_tone(294)
|
||||
else:
|
||||
cpx.stop_tone()
|
||||
cpx.stop_tone()
|
||||
|
|
|
|||
|
|
@ -16,4 +16,4 @@ while True:
|
|||
print("Touched A6!")
|
||||
if cpx.touch_A7:
|
||||
print("Touched A7!")
|
||||
time.sleep(0.1)
|
||||
time.sleep(0.1)
|
||||
|
|
|
|||
|
|
@ -25,4 +25,4 @@ while True:
|
|||
if cpx.touch_A7:
|
||||
print("Touched A7!")
|
||||
cpx.pixels.fill((100, 0, 155))
|
||||
time.sleep(0.1)
|
||||
time.sleep(0.1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue