]> vault307.fbx.one Git - Sensory_Wall.git/commitdiff
more sensory wall projects master
authorjimmy <jimipunk88@gmail.com>
Tue, 25 Jun 2024 00:46:03 +0000 (19:46 -0500)
committerjimmy <jimipunk88@gmail.com>
Tue, 25 Jun 2024 00:55:38 +0000 (19:55 -0500)
151 files changed:
5vLEDcontroller.py [new file with mode: 0644]
LEDstripbreathe.py [new file with mode: 0644]
RGBledStrip.py [new file with mode: 0644]
adafruit_soundboard.py [new file with mode: 0644]
circuitPython/PDMmic.py [new file with mode: 0644]
circuitPython/audioLEDvis.py [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/code.py [new file with mode: 0755]
circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_bus_device/__init__.py [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_bus_device/i2c_device.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_bus_device/spi_device.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_framebuf.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/__init__.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/issi_evb.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/led_glasses_animation.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/led_glasses_map.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/__init__.py [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_bcd_alarm.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_bcd_datetime.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_bit.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_bits.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_struct.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_struct_array.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/code.py [new file with mode: 0755]
circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_bus_device/__init__.py [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_bus_device/i2c_device.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_bus_device/spi_device.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_framebuf.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/__init__.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/issi_evb.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/led_glasses_animation.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/led_glasses_map.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/__init__.py [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_bcd_alarm.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_bcd_datetime.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_bit.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_bits.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_struct.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_struct_array.mpy [new file with mode: 0644]
circuitPython/audio_spectrum_lightshow/README.txt [new file with mode: 0644]
circuitPython/colorswirl.py [new file with mode: 0644]
circuitPython/ledmatrixTest.py [new file with mode: 0644]
circuitPython/test2.py [new file with mode: 0644]
circuitPython/testline.py [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/__init__.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/issi_evb.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/led_glasses_animation.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/led_glasses_map.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/__init__.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/__init__.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/blink.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/chase.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/colorcycle.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/comet.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/customcolorchase.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/grid_rain.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/pulse.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/rainbow.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/rainbowchase.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/rainbowcomet.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/rainbowsparkle.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/solid.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/sparkle.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/sparklepulse.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/color.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/grid.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/group.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/helper.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_led_animation/sequence.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_register/__init__.py [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_register/i2c_bcd_alarm.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_register/i2c_bcd_datetime.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_register/i2c_bit.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_register/i2c_bits.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_register/i2c_struct.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/adafruit_register/i2c_struct_array.mpy [new file with mode: 0644]
circuitPython/uploadFromMCU/lib/simpleio.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 7.x/code.py [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_bus_device/__init__.py [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_bus_device/i2c_device.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_bus_device/spi_device.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_framebuf.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/__init__.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/issi_evb.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/led_glasses_animation.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/led_glasses_map.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/__init__.py [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_bcd_alarm.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_bcd_datetime.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_bit.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_bits.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_struct.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_struct_array.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 8.x/code.py [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_bus_device/__init__.py [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_bus_device/i2c_device.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_bus_device/spi_device.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_framebuf.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/__init__.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/issi_evb.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/led_glasses_animation.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/led_glasses_map.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/__init__.py [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_bcd_alarm.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_bcd_datetime.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_bit.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_bits.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_struct.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_struct_array.mpy [new file with mode: 0644]
circuitPython/waterfall_visualizer/README.txt [new file with mode: 0644]
cpxtest.py [new file with mode: 0644]
demoRGB.py [new file with mode: 0644]
diary.txt
distanceTest.py
main.py [new file with mode: 0644]
pico_soundboard.py [new file with mode: 0644]
redlight.py [new file with mode: 0644]
sampleTracks/T00.ogg [new file with mode: 0644]
sampleTracks/T01RAND0.wav [new file with mode: 0644]
sampleTracks/T01RAND1.wav [new file with mode: 0644]
sampleTracks/T01RAND2.wav [new file with mode: 0644]
sampleTracks/T01RAND3.wav [new file with mode: 0644]
sampleTracks/T01RAND4.wav [new file with mode: 0644]
sampleTracks/T02.wav [new file with mode: 0644]
sampleTracks/T03.wav [new file with mode: 0644]
sampleTracks/T04HOLDL.wav [new file with mode: 0644]
sampleTracks/T05NEXT0.wav [new file with mode: 0644]
sampleTracks/T05NEXT1.wav [new file with mode: 0644]
sampleTracks/T05NEXT2.wav [new file with mode: 0644]
sampleTracks/T06LATCH.wav [new file with mode: 0644]
sampleTracks/T07.wav [new file with mode: 0644]
sampleTracks/T08.wav [new file with mode: 0644]
sampleTracks/T09.wav [new file with mode: 0644]
sampleTracks/T10.wav [new file with mode: 0644]
towertest.py [new file with mode: 0644]
trafficLight.py [new file with mode: 0644]
us100Demo.py [new file with mode: 0644]

diff --git a/5vLEDcontroller.py b/5vLEDcontroller.py
new file mode 100644 (file)
index 0000000..8ed5794
--- /dev/null
@@ -0,0 +1,85 @@
+import us100, machine, neopixel, time
+# TODO adjust pin #s to match soldered connections, adjust distance trigger, _thread?
+btn=machine.Pin(15, machine.Pin.IN,machine.Pin.PULL_UP)
+light=machine.Pin(1,machine.Pin.OUT)
+np=neopixel.NeoPixel(machine.Pin(0), 96)
+sensor=us100.US100UART(machine.UART(1))
+
+distance=0
+position=0
+brightness=0.5
+def measure():
+    global distance
+    distance=sensor.distance()
+    return distance
+
+
+def clear():
+    for i in range(np.n):
+        np[i]=(0,0,0)
+    np.write()
+    
+def fade(): #pick color
+    for i in range(0,4 * 256,8):
+        for j in range(np.n):
+            if (i // 256) % 2 == 0:
+                val = i & 0xff
+            else:
+                val = 255 - (i & 0xff)
+            np[j] = (val, val, 0)
+        np.write()
+
+#colorcycle, does start over, do only i actually care about that? probably
+def wheel(pos):
+    if pos < 85:
+        return(pos*3,255-pos*3,0)
+    elif pos <170:
+        pos-=85
+        return(255-pos*3,0,pos*3)
+    else:
+        pos -=170
+        return(0,pos*3,255-pos*3)
+
+def loop():
+    global position, brightness
+    
+    for i in range(np.n):
+        hue=int(i*(255/np.n)+position)%256
+        color=wheel(hue)
+        color=tuple(int(val*brightness) for val in color)
+        np[(i+position)%np.n]=color
+        np.write()
+        position=(position +1)% np.n
+        time.sleep_ms(66)
+
+def main():
+    try:
+        measure()
+        print(distance)
+        time.sleep_ms(25)
+    except Exception:
+        print("idk, something went wrong man")
+        pass
+""" 
+main loop, hell yeah! throw them built funcs here!
+"""
+
+while True:
+    
+    if btn.value()==0:
+        light.off()
+        fade()
+        clear()
+    else:
+        light.on()
+    
+    main()    
+    if distance<=250:
+        loop()
+        main()
+    elif distance>=251:
+        clear()
+        main()
+        
+        
+     
\ No newline at end of file
diff --git a/LEDstripbreathe.py b/LEDstripbreathe.py
new file mode 100644 (file)
index 0000000..7d62803
--- /dev/null
@@ -0,0 +1,76 @@
+import machine, neopixel, time
+np=neopixel.NeoPixel(machine.Pin(0), 96)
+
+n=np.n
+
+position=0
+brightness=0.5
+
+def fade(np):
+    for i in range(0, 4 * 256, 8):
+        for j in range(n):
+            if (i // 256) % 2 == 0:
+                val = i & 0xff
+            else:
+                val = 255 - (i & 0xff)
+            np[j] = (val, val, 0)
+        np.write()
+        
+def bounce(np):
+    for i in range(4 * n):
+        for j in range(n):
+            np[j] = (0, 0, 128)
+        if (i // n) % 2 == 0:
+            np[i % n] = (0, 128, 128)
+        else:
+            np[n - 1 - (i % n)] = (0, 128, 128)
+        np.write()
+        time.sleep_ms(60)
+
+def clear():
+    for i in range(n):
+        np[i] = (0, 0, 0)
+    np.write()
+    
+def wheel(pos):
+    if pos < 85:
+        return(pos*3,255-pos*3,0)
+    elif pos <170:
+        pos-=85
+        return(255-pos*3,0,pos*3)
+    else:
+        pos -=170
+        return(0,pos*3,255-pos*3)
+
+def loop():
+    global position, brightness
+    
+    for i in range(np.n):
+        hue=int(i*(255/np.n)+position)%256
+        color=wheel(hue)
+        color=tuple(int(val*brightness) for val in color)
+        np[(i+position)%np.n]=color
+    np.write()
+    position=(position +1)% np.n
+    #print(position)
+    time.sleep_ms(200)
+    
+def antiloop():
+    global position, brightness
+    
+    for i in range(np.n):
+        hue=int(-i*(255/np.n)-position)%256
+        color=wheel(hue)
+        color=tuple(int(val*brightness) for val in color)
+        np[(i-position)%np.n]=color
+    np.write()
+    position=(position +1)% np.n
+    #print(position,"anti")
+    time.sleep_ms(200)
+        
+    
+while True:
+    for i in range(np.n):
+        loop()
+    for i in range(np.n):
+        antiloop()
\ No newline at end of file
diff --git a/RGBledStrip.py b/RGBledStrip.py
new file mode 100644 (file)
index 0000000..cf8d300
--- /dev/null
@@ -0,0 +1,9 @@
+import machine, neopixel
+p=machine.Pin(0)
+n=neopixel.NeoPixel(p, 60)
+# needs 12v power supply
+while True:
+    for i in range(60):
+        n[i]=(i*8,0,0)
+    
+    n.write()
\ No newline at end of file
diff --git a/adafruit_soundboard.py b/adafruit_soundboard.py
new file mode 100644 (file)
index 0000000..c8e8e36
--- /dev/null
@@ -0,0 +1,575 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2017 Mike Mabey
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+"""
+A MicroPython library for the Adafruit Sound Boards in UART mode!
+
+This library has been adapted from the library written by Adafruit for Arduino,
+available at https://github.com/adafruit/Adafruit_Soundboard_library.
+
+* Author(s): Mike Mabey
+"""
+
+from machine import UART, Pin
+from sys import platform as BOARD
+
+__author__ = 'Mike Mabey'
+__license__ = 'MIT'
+__copyright_ = 'Copyright 2017, Mike Mabey'
+
+ESP8266 = 'esp8266'
+PYBOARD = 'pyboard'
+WIPY = 'wipy'
+
+try:
+    # Should be supported by all 3 supported boards
+    from utime import sleep_ms
+except ImportError:
+    _supported = ', '.join([ESP8266, PYBOARD, WIPY])
+    raise OSError('Unsupported board. Currently only works with {}.'.format(_supported))
+
+SB_BAUD = 9600  # Baud rate of the sound boards
+MIN_VOL = 0
+MAX_VOL = 204
+MAX_FILES = 25
+DEBUG = False
+
+
+class Soundboard:
+    """Control an Adafruit Sound Board via UART.
+
+    The :class:`Soundboard` class handles all communication with the sound
+    board via :ref:`UART <upy:machine.UART>`, making it easy to get
+    information about the sound files on the sound board and control playback.
+
+    If you need to reset the sound board from your MicroPython code, be
+    sure to provide the ``rst_pin`` parameter. The sound board sometimes gets
+    out of UART mode and reverts to the factory default of GPIO trigger
+    mode. When this happens, it will appear as if the sound board has
+    stoped working for no apparent reason. This library is designed to
+    automatically attempt resetting the board if a command fails, since
+    that is a common cause. So, it is a good idea to provide this
+    parameter.
+    """
+
+    def __init__(self, uart_id, rst_pin=None, vol=None, alt_get_files=False, debug=None, **uart_kwargs):
+        """
+        :param uart_id: ID for the :ref:`UART <upy:machine.UART>` bus to use.
+            Acceptable values vary by board. Check the documentation for your
+            board for more info.
+        :param rst_pin: Identifier for the pin (on the MicroPython board)
+            connected to the ``RST`` pin of the sound board. Valid identifiers
+            vary by board.
+        :param vol: Initial volume level to set. See :attr:`vol` for more info.
+        :type vol: int or float
+        :param bool alt_get_files: Uses an alternate method to get the list of
+            track file names. See :meth:`use_alt_get_files` method for more
+            info.
+        :param bool debug: When not None, will set the debug output flag to the
+            boolean value of this argument using the :meth:`toggle_debug`
+            method.
+        :param dict uart_kwargs: Additional values passed to the
+            :ref:`UART.init() <upy:machine.UART>` method of the UART bus object.
+            Acceptable values here also vary by board. It is not necessary to
+            include the baud rate among these keyword values, because it will
+            be set to ``SB_BAUD`` before the ``UART.init`` function is called.
+        """
+        if debug is not None:
+            self.toggle_debug(bool(debug))
+
+        self._uart = UART(uart_id, SB_BAUD)
+        uart_kwargs['baudrate'] = SB_BAUD
+        self._uart.init(**uart_kwargs)
+        self._files = None
+        self._sizes = None
+        self._lengths = None
+        self._track = {}
+
+        self._cur_vol = None
+        self._cur_track = None
+        self._reset_attempted = False
+
+        # Setup reset pin
+        if BOARD == PYBOARD:
+            self._sb_rst = None if rst_pin is None else Pin(rst_pin, mode=Pin.OPEN_DRAIN, value=1)
+        else:
+            self._sb_rst = None if rst_pin is None else Pin(rst_pin, mode=Pin.IN)
+
+        self.vol = vol
+
+        if alt_get_files:
+            self.use_alt_get_files()
+
+    def _flush_uart_input(self):
+        """Read any available data from the UART bus until none is left."""
+        while self._uart.any():
+            self._uart.read()
+
+    def _send_simple(self, cmd, check=None, strip=True):
+        """Send the command, optionally do a check on the output.
+
+        The sound board understands the following commands:
+
+        - ``L``: List files on the board
+        - ``#``: Play a file by number
+        - ``P``: Play a file by name
+        - ``+``: Volume up (range is 0-204, increments of 2)
+        - ``-``: Volume down
+        - ``=``: Pause playback
+        - ``>``: Un-pause playback
+        - ``q``: Stop playback
+        - ``t``: Give current position of playback and total time of track
+        - ``s``: Current track size and total size
+
+        :param cmd: Command to send over the UART bus. A newline character will
+            be appended to the command before sending it, so it's not necessary
+            to include one as part of the command.
+        :type cmd: str or bytes
+        :param check: Depending on the type of `check`, has three different
+            behaviors. When None (default), the return value will be whatever
+            the output from the command was. When a str or bytes, the return
+            value will be True/False, indicating whether the command output
+            starts with the value in `check`. When it otherwise evaluates to
+            True, return value will be True/False, indicating the output
+            started with the first character in `cmd`.
+        :type check: str or bytes or None or bool
+        :return: Varies depending on the value of `check`.
+        :rtype: bytes or bool
+        """
+        self._flush_uart_input()
+        cmd = cmd.strip()  # Make sure there's not more than one newline
+        self._uart.write('{}\n'.format(cmd))
+        if len(cmd) > 1:
+            # We need to gobble the return when there's more than one character in the command
+            self._uart.readline()
+        try:
+            msg = self._uart.readline()
+            if strip:
+                msg = msg.strip()
+            assert isinstance(msg, bytes)
+            printif(msg)
+        except (AttributeError, AssertionError):
+            if self._reset_attempted:
+                # Only try resetting once
+                return False  # TODO: Better way to handle failed commands? Too broad?
+            printif('Got back None from a command. Attempting to restart the board to put it in UART mode.')
+            self._reset_attempted = True
+            self.reset()
+            return self._send_simple(cmd, check)
+
+        if check is None:
+            return msg
+        else:
+            self._reset_attempted = True  # We already sent a command successfully
+
+        if isinstance(check, str):
+            return msg.startswith(check.encode())
+        elif isinstance(check, bytes):
+            return msg.startswith(check)
+        elif check:
+            return msg.startswith(cmd[0].encode())
+
+    @property
+    def files(self):
+        """Return a ``list`` of the files on the sound board.
+
+        :rtype: list
+        """
+        if self._files is None:
+            self._get_files()
+        return self._files
+
+    @property
+    def sizes(self):
+        """Return a ``list`` of the files' sizes on the sound board.
+
+        .. seealso:: :meth:`use_alt_get_files`
+
+        :rtype: list
+        """
+        if self._sizes is None:
+            self._get_files()
+        return self._sizes
+
+    def _get_files(self):
+        """Ask the board for the files and their sizes, store the results."""
+        self._flush_uart_input()
+
+        self._files = []
+        self._sizes = []
+        self._uart.write('L\n')
+        sleep_ms(10)
+        i = 0
+        while self._uart.any():
+            msg = self._uart.readline().strip()
+            printif(msg)
+            fname, fsize = msg.split(b'\t')
+            fname = fname.decode()
+            self._files.append(fname)
+            self._sizes.append(int(fsize))
+            self._track[fname] = i
+            i += 1
+
+    def _get_files_alt(self):
+        """Play every track, get info from feedback."""
+        vol = self.vol
+        self.vol = 0
+        self._files = []
+        self._lengths = []
+        self._sizes = []
+        for i in range(MAX_FILES):
+            self.stop()
+            msg = self._send_simple('#{}'.format(i))
+            if msg.startswith(b'NoFile'):
+                # Playing track i failed, it must not be a valid track number
+                break
+            play, track_num, fname = msg.split(b'\t')
+            self._files.append(fname)
+            self._track[fname] = i
+
+            sleep_ms(50)
+            sec = self.track_time()
+            if sec:
+                self._lengths.append(sec[1])
+            else:
+                self._lengths.append(0)
+            size = self.track_size()
+            if size:
+                self._sizes.append(size[1])
+            else:
+                self._sizes.append(0)
+
+        self.vol = vol
+
+    @property
+    def lengths(self):
+        """Return a ``list`` of the track lengths in seconds.
+
+        .. note::
+
+            In my own testing of this method, the board always returns a value
+            of zero seconds for the length for every track, no matter if it's a
+            WAV or OGG file, short or long track.
+
+        :rtype: list
+        """
+        if self._lengths is None:
+            self._get_lengths()
+        return self._lengths
+
+    def _get_lengths(self):
+        """Store the length of each track."""
+        self._get_files_alt()
+
+    def file_name(self, n):
+        """Return the name of track ``n``.
+
+        :param int n: Index of a file on the sound board or ``False`` if the
+            track number doesn't exist.
+        :return: Filename of track ``n``.
+        :rtype: str or bool
+        """
+        try:
+            return self.files[n]
+        except IndexError:
+            return False
+
+    def track_num(self, file_name):
+        """Return the track number of the given file name.
+
+        :param str file_name: File name of the track. Should be one of the
+            values from the :attr:`files` property.
+        :return: The track number of the file name or ``False`` if not found.
+        :rtype: int or bool
+        """
+        try:
+            return self._track[file_name]
+        except KeyError:
+            return False
+
+    def play(self, track=None):
+        """Play a track on the board.
+
+        :param track: The index (``int``) or filename (``str``) of the track to
+            play.
+        :type track: int or str
+        :return: If the command was successful.
+        :rtype: bool
+        """
+        if isinstance(track, int):
+            cmd = '#'
+            num = track
+        elif isinstance(track, str):
+            cmd = 'P'
+            num = self.track_num(track)
+        else:
+            raise TypeError('You must specify a track by its number (int) or its name (str)')
+
+        if self._send_simple('{}{}'.format(cmd, track), 'play'):
+            self._cur_track = num
+            return True
+        return False
+
+    def play_now(self, track):
+        """Play a track on the board now, stopping current track if necessary.
+
+        :param track: The index (``int``) or filename (``str``) of the track to
+            play.
+        :type track: int or str
+        :return: If the command was successful.
+        :rtype: bool
+        """
+        self.stop()
+        if not self.play(track):
+            # Playing the specified track failed, so just return False
+            return False
+        return True
+
+    @property
+    def vol(self):
+        """Current volume.
+
+        This is implemented as a class property, so you can get and set its
+        value directly. When setting a new volume, you can use an ``int`` or a
+        ``float`` (assuming your board supports floats). When setting to an
+        ``int``, it should be in the range of 0-204. When set to a ``float``,
+        the value will be interpreted as a percentage of :obj:`MAX_VOL`.
+
+        :rtype: int
+        """
+        if self._cur_vol is None:
+            self.vol_down()
+        return self._cur_vol
+
+    @vol.setter
+    def vol(self, new_vol):
+        if new_vol is None:
+            return
+        if isinstance(new_vol, float):
+            new_vol = int(new_vol * MAX_VOL)
+        if not isinstance(new_vol, int):
+            printif('Invalid volume level. Try giving an int.')
+            return
+        elif new_vol > self.vol:
+            self.vol_up(new_vol)
+        elif new_vol < self.vol:
+            self.vol_down(new_vol)
+
+    def vol_up(self, vol=None):
+        """Turn volume up by 2 points, return current volume level [0-204].
+
+        :param int vol: Target volume. When not ``None``, volume will be turned
+            up to be greater than or equal to this value.
+        :rtype: int
+        """
+        global DEBUG
+        printif('Turning volume up')
+        if vol is None:
+            self._cur_vol = int(self._send_simple('+'))
+            return self._cur_vol
+        if vol > MAX_VOL:
+            printif('{} is above maximum volume. Setting to {} instead.'.format(vol, MAX_VOL))
+            vol = MAX_VOL
+        self._cur_vol = MIN_VOL - 1
+        db = DEBUG
+        DEBUG = False
+        while vol > self._cur_vol:
+            self._cur_vol = int(self._send_simple('+'))
+        DEBUG = db
+        return self._cur_vol
+
+    def vol_down(self, vol=None):
+        """Turn volume down by 2 points, return current volume level [0-204].
+
+        :param int vol: Target volume. When not ``None``, volume will be turned
+            down to be less than or equal to this value.
+        :rtype: int
+        """
+        global DEBUG
+        printif('Turning volume down')
+        if vol is None:
+            self._cur_vol = int(self._send_simple('-'))
+            return self._cur_vol
+        self._cur_vol = MAX_VOL + 1
+        if vol < MIN_VOL:
+            printif('{} is below minimum volume. Setting to {} instead.'.format(vol, MIN_VOL))
+            vol = MIN_VOL
+        db = DEBUG
+        DEBUG = False
+        while vol < self._cur_vol:
+            self._cur_vol = int(self._send_simple('-'))
+        DEBUG = db
+        return self._cur_vol
+
+    def pause(self):
+        """Pause playback, return if the command was successful.
+
+        :rtype: bool
+        """
+        return self._send_simple('=', True)
+
+    def unpause(self):
+        """Continue playback, return if the command was successful.
+
+        :rtype: bool
+        """
+        return self._send_simple('>', True)
+
+    def stop(self):
+        """Stop playback, return if the command was successful.
+
+        :rtype: bool
+        """
+        return self._send_simple('q', True)
+
+    def track_time(self):
+        """Return the current position of playback and total time of track.
+
+        :rtype: tuple
+        """
+        msg = self._send_simple('t')
+        if not msg:
+            return -1, -1
+        printif(len(msg))
+        if len(msg) != 11:
+            return False
+        current, total = msg.decode('utf-8').split(':')
+        return int(current), int(total)
+
+    def track_size(self):
+        """Return the remaining size and total size.
+
+        It seems the remaining track size refers to the number of bytes left
+        for the sound board to process before the playing of the track will be
+        over.
+
+        :return: Remaining track size and total size
+        :rtype: tuple
+        """
+        msg = self._send_simple('s')
+        if not msg:
+            return -1, -1
+        printif(len(msg))
+        if len(msg) != 21:
+            return False
+        remaining, total = msg.decode('utf-8').split('/')
+        return int(remaining), int(total)
+
+    def reset(self):
+        """Reset the sound board.
+
+        Soft reset the board by bringing the ``RST`` pin low momentarily (10
+        ms). This only has effect if the reset pin has been initialized in the
+        constructor.
+
+        Doing a soft reset on the board before doing any other actions can help
+        ensure that it has been started in UART control mode, rather than GPIO
+        trigger mode.
+
+        .. seealso::
+
+            `Soundboard Pinout <https://learn.adafruit.com/adafruit-audio-fx-sound-board/pinouts#uart-pins>`_
+                Documentation on the sound boards' pinouts.
+
+
+        :return: Whether the reset was successful. If the reset pin was not
+            initialized in the constructor, this will always return ``False``.
+        :rtype: bool
+        """
+        if self._sb_rst is None:
+            # Don't attempt to restart the board if the reset pin wasn't initialized
+            return False
+
+        if BOARD == PYBOARD:
+            self._sb_rst(0)
+            sleep_ms(10)
+            self._sb_rst(1)
+        else:
+            # Pin should already be in IN mode. This allows us to set the value we want to send, then switch to OUT mode
+            # just long enough for the value to take effect, and finally switch back to IN mode.
+            # self._sb_rst.value(0)
+            self._sb_rst(0)
+            self._sb_rst.mode(Pin.OUT)
+            sleep_ms(10)
+            self._sb_rst.mode(Pin.IN)
+
+        sleep_ms(1000)  # Give the board some time to boot
+        msg = self._uart.readline().strip()
+        printif(msg)  # Blank line
+
+        msg = self._uart.readline().strip()
+        printif(msg)  # Date and name
+
+        if not msg.startswith('Adafruit FX Sound Board'):
+            return False
+
+        sleep_ms(250)
+
+        msg = self._uart.readline().strip()
+        printif(msg)  # FAT type
+
+        msg = self._uart.readline().strip()
+        printif(msg)  # Number of files
+
+        # Reset volume level and current track
+        self.vol = self._cur_vol
+        self._cur_track = None
+
+        return True
+
+    def use_alt_get_files(self, now=False):
+        """Get list of track files using an alternate method.
+
+        If the list of files is missing tracks you know are on the sound board,
+        try calling this method. It doesn't depend on the sound board's internal
+        command for returning a list of files. Instead, it plays each of the
+        tracks using their track numbers and gets the filename and size from
+        the output of the play command.
+
+        :param bool now: When set to ``True``, the alternate method of getting
+            the files list will be called immediately. Otherwise, the list of
+            files will be populated the next time the :attr:`files` property is
+            accessed (lazy loading).
+        :rtype: None
+        """
+        self._get_files = self._get_files_alt
+        if now:
+            self._get_files()
+
+    @staticmethod
+    def toggle_debug(debug=None):
+        """Turn on/off :obj:`DEBUG` flag.
+
+        :param debug: If None, the :obj:`DEBUG` flag will be toggled to have the
+            value opposite of its current value. Otherwise, :obj:`DEBUG` will be
+            set to the boolean value of ``debug``.
+        :rtype: None
+        """
+        global DEBUG
+        if debug is None:
+            DEBUG = not DEBUG
+        else:
+            DEBUG = bool(debug)
+
+
+def printif(*values, **kwargs):
+    """Print a message if :obj:`DEBUG` is set to ``True``."""
+    print(*values, **kwargs) if DEBUG else None
\ No newline at end of file
diff --git a/circuitPython/PDMmic.py b/circuitPython/PDMmic.py
new file mode 100644 (file)
index 0000000..df75402
--- /dev/null
@@ -0,0 +1,30 @@
+import audiobusio
+import math
+import board
+import array
+import simpleio
+import time
+
+def mean(values):
+    return sum(values)/len(values)
+
+def normalized_rms(values):
+    minbuf=int(mean(values))
+    samples_sum=sum(float(sample-minbuf)*(sample-minbuf)
+                    for sample in values)
+    
+    return math.sqrt(samples_sum/len(values))
+
+#mic setup
+mic=audiobusio.PDMIn(board.D8,board.D9,sample_rate=16000, bit_depth=16)
+samples=array.array('H',[0]*160)
+
+#last_input=0
+
+while True:
+    mic.record(samples,len(samples))
+    magnitude=normalized_rms(samples)
+    #print((magnitude,))
+    mapped_value=simpleio.map_range(magnitude, 125, 500, 0, 16)
+    input_val=int(mapped_value)
+    print(input_val)
\ No newline at end of file
diff --git a/circuitPython/audioLEDvis.py b/circuitPython/audioLEDvis.py
new file mode 100644 (file)
index 0000000..1b9e68d
--- /dev/null
@@ -0,0 +1,75 @@
+from array import array
+from math import log
+from time import monotonic
+from supervisor import reload
+import board
+from audiobusio import PDMIn
+from busio import I2C
+import adafruit_is31fl3741
+from adafruit_is31fl3741 import PREFER_BUFFER
+from adafruit_is31fl3741.adafruit_rgbmatrixqt import Adafruit_RGBMatrixQT
+from rainbowio import colorwheel
+from ulab import numpy as np
+from ulab.scipy.signal import spectrogram
+
+i2c=I2C(board.SCL,board.SDA,frequency=1000000)
+
+is31 = Adafruit_RGBMatrixQT(i2c, allocate=PREFER_BUFFER)
+
+is31.set_led_scaling(0x19)
+is31.global_current=0x03
+is31.enable=True
+
+heatmap=[0xb000ff,0xa600ff,0x9b00ff,0x8f00ff,0x8200ff,
+ 0x7400ff,0x6500ff,0x5200ff,0x3900ff,0x0003ff,
+ 0x00a6ff,0x00b7ff,0x0066ff,0x007eff,0x0093ff,
+ 0x00e0ff,0x00e6fd,0x00ecf6,0x00f2ea,0x00f6d7,
+ 0x00ff16,0xaaff00,0xb8ff00,0xc5ff00,0xffab00,
+ 0xedff00,0xf5eb00,0xfcd600,0xffc100,0xff0000,
+ 0xff9500,0xff7c00,0xff6100,0xff4100,0xff0000,
+ 0xff0000,0xff0000]
+
+fft_size=64
+mic=audiobusio.PDMIn(board.D8,board.D9,sample_rate=16000,bit_depth=16)
+
+samples_bit=array.array('H',[0]*(fft_size+3))
+
+def waves(data,y):
+    offset=max(0,(13-len(data))//2)
+    
+    for x in range(min(13, len(data))):
+        is31.pixel(x+offset,y,heatmap[int(data[x])])
+        
+def main():
+    max_all=10
+    scroll_offset=0
+    y=scroll_offset
+    
+    while True:
+        mic.record(samples_bit,len(samples_bit))
+        samples=np.array(samples_bit[3:])
+        
+        spectrogram1=spectrogram(samples)
+        spectrogram1=np.log(spectrogram1 + 1e-7)
+        spectrogram1=spectrogram1[1:(fft_size//2)-1]
+        
+        min_curr=np.min(spectrogram1)
+        max_curr=np.max(spectrogram1)
+        
+        if max_curr>max_all:
+            max_all=max_curr
+        else:
+            max_curr=max_curr-1
+        min_curr=max(min_curr,3)
+        
+        data=(spectrogram1-min_curr)*(51./(max_all-mi_curr))
+        
+        data=data*np.array((data>0))
+        
+        y=scroll_offset
+        
+        waves(data,y)
+        scroll_offset=(y+1)%9
+        is31.show()
+        
+main()
\ No newline at end of file
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/code.py b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/code.py
new file mode 100755 (executable)
index 0000000..aa6cc81
--- /dev/null
@@ -0,0 +1,186 @@
+# SPDX-FileCopyrightText: 2021 Phil Burgess for Adafruit Industries
+#
+# SPDX-License-Identifier: MIT
+
+"""
+AUDIO SPECTRUM LIGHT SHOW for Adafruit EyeLights (LED Glasses + Driver).
+Uses onboard microphone and a lot of math to react to music.
+"""
+
+from array import array
+from math import log
+from time import monotonic
+from supervisor import reload
+import board
+from audiobusio import PDMIn
+from busio import I2C
+import adafruit_is31fl3741
+from adafruit_is31fl3741.adafruit_rgbmatrixqt import Adafruit_RGBMatrixQT
+from rainbowio import colorwheel
+from ulab import numpy as np
+#  if using CP7 and below:
+from ulab.scipy.signal import spectrogram
+#  if using CP8 and above:
+#  from ulab.utils import spectrogram
+
+
+# FFT/SPECTRUM CONFIG ----
+
+fft_size = 256  # Sample size for Fourier transform, MUST be power of two
+spectrum_size = fft_size // 2  # Output spectrum is 1/2 of FFT result
+# Bottom of spectrum tends to be noisy, while top often exceeds musical
+# range and is just harmonics, so clip both ends off:
+low_bin = 10  # Lowest bin of spectrum that contributes to graph
+high_bin = 75  # Highest bin "
+
+
+# HARDWARE SETUP ---------
+
+# Manually declare I2C (not board.I2C() directly) to access 1 MHz speed...
+i2c = I2C(board.SCL, board.SDA, frequency=1000000)
+
+# Initialize the IS31 LED driver, buffered for smoother animation
+#glasses = LED_Glasses(i2c, allocate=adafruit_is31fl3741.MUST_BUFFER)
+glasses = Adafruit_RGBMatrixQT(i2c, allocate=adafruit_is31fl3741.MUST_BUFFER)
+
+glasses.show()  # Clear any residue on startup
+glasses.set_led_scaling(0xFF)
+glasses.global_current = 5  # Not too bright please
+glasses.enable = True
+
+# Initialize mic and allocate recording buffer (default rate is 16 MHz)
+mic = PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, bit_depth=16)
+rec_buf = array("H", [0] * fft_size)  # 16-bit audio samples
+
+
+# FFT/SPECTRUM SETUP -----
+
+# To keep the display lively, tables are precomputed where each column of
+# the matrix (of which there are few) is the sum value and weighting of
+# several bins from the FFT spectrum output (of which there are many).
+# The tables also help visually linearize the output so octaves are evenly
+# spaced, as on a piano keyboard, whereas the source spectrum data is
+# spaced by frequency in Hz.
+column_table = []
+
+spectrum_bits = log(spectrum_size, 2)  # e.g. 7 for 128-bin spectrum
+# Scale low_bin and high_bin to 0.0 to 1.0 equivalent range in spectrum
+low_frac = log(low_bin, 2) / spectrum_bits
+frac_range = log(high_bin, 2) / spectrum_bits - low_frac
+
+for column in range(glasses.width):
+    # Determine the lower and upper frequency range for this column, as
+    # fractions within the scaled 0.0 to 1.0 spectrum range. 0.95 below
+    # creates slight frequency overlap between columns, looks nicer.
+    lower = low_frac + frac_range * (column / glasses.width * 0.95)
+    upper = low_frac + frac_range * ((column + 1) / glasses.width)
+    mid = (lower + upper) * 0.5  # Center of lower-to-upper range
+    half_width = (upper - lower) * 0.5  # 1/2 of lower-to-upper range
+    # Map fractions back to spectrum bin indices that contribute to column
+    first_bin = int(2 ** (spectrum_bits * lower) + 1e-4)
+    last_bin = int(2 ** (spectrum_bits * upper) + 1e-4)
+    bin_weights = []  # Each spectrum bin's weighting will be added here
+    for bin_index in range(first_bin, last_bin + 1):
+        # Find distance from column's overall center to individual bin's
+        # center, expressed as 0.0 (bin at center) to 1.0 (bin at limit of
+        # lower-to-upper range).
+        bin_center = log(bin_index + 0.5, 2) / spectrum_bits
+        dist = abs(bin_center - mid) / half_width
+        if dist < 1.0:  # Filter out a few math stragglers at either end
+            # Bin weights have a cubic falloff curve within range:
+            dist = 1.0 - dist  # Invert dist so 1.0 is at center
+            bin_weights.append(((3.0 - (dist * 2.0)) * dist) * dist)
+    # Scale bin weights so total is 1.0 for each column, but then mute
+    # lower columns slightly and boost higher columns. It graphs better.
+    total = sum(bin_weights)
+    bin_weights = [
+        (weight / total) * (0.8 + idx / glasses.width * 1.4)
+        for idx, weight in enumerate(bin_weights)
+    ]
+    # List w/five elements is stored for each column:
+    # 0: Index of the first spectrum bin that impacts this column.
+    # 1: A list of bin weights, starting from index above, length varies.
+    # 2: Color for drawing this column on the LED matrix. The 225 is on
+    #    purpose, providing hues from red to purple, leaving out magenta.
+    # 3: Current height of the 'falling dot', updated each frame
+    # 4: Current velocity of the 'falling dot', updated each frame
+    column_table.append(
+        [
+            first_bin - low_bin,
+            bin_weights,
+            colorwheel(225 * column / glasses.width),
+            glasses.height,
+            0.0,
+        ]
+    )
+# print(column_table)
+
+
+# MAIN LOOP -------------
+
+dynamic_level = 10  # For responding to changing volume levels
+frames, start_time = 0, monotonic()  # For frames-per-second calc
+
+while True:
+    # The try/except here is because VERY INFREQUENTLY the I2C bus will
+    # encounter an error when accessing the LED driver, whether from bumping
+    # around the wires or sometimes an I2C device just gets wedged. To more
+    # robustly handle the latter, the code will restart if that happens.
+    try:
+        mic.record(rec_buf, fft_size)  # Record batch of 16-bit samples
+        samples = np.array(rec_buf)  # Convert to ndarray
+        # Compute spectrogram and trim results. Only the left half is
+        # normally needed (right half is mirrored), but we trim further as
+        # only the low_bin to high_bin elements are interesting to graph.
+        spectrum = spectrogram(samples)[low_bin : high_bin + 1]
+        # Linearize spectrum output. spectrogram() is always nonnegative,
+        # but add a tiny value to change any zeros to nonzero numbers
+        # (avoids rare 'inf' error)
+        spectrum = np.log(spectrum + 1e-7)
+        # Determine minimum & maximum across all spectrum bins, with limits
+        lower = max(np.min(spectrum), 4)
+        upper = min(max(np.max(spectrum), lower + 6), 20)
+
+        # Adjust dynamic level to current spectrum output, keeps the graph
+        # 'lively' as ambient volume changes. Sparkle but don't saturate.
+        if upper > dynamic_level:
+            # Got louder. Move level up quickly but allow initial "bump."
+            dynamic_level = upper * 0.7 + dynamic_level * 0.3
+        else:
+            # Got quieter. Ease level down, else too many bumps.
+            dynamic_level = dynamic_level * 0.5 + lower * 0.5
+
+        # Apply vertical scale to spectrum data. Results may exceed
+        # matrix height...that's OK, adds impact!
+        #data = (spectrum - lower) * (7 / (dynamic_level - lower))
+        data = (spectrum - lower) * ((glasses.height + 2) / (dynamic_level - lower))
+
+        for column, element in enumerate(column_table):
+            # Start BELOW matrix and accumulate bin weights UP, saves math
+            first_bin = element[0]
+            column_top = glasses.height + 1
+            for bin_offset, weight in enumerate(element[1]):
+                column_top -= data[first_bin + bin_offset] * weight
+
+            if column_top < element[3]:  #       Above current falling dot?
+                element[3] = column_top - 0.5  # Move dot up
+                element[4] = 0  #                and clear out velocity
+            else:
+                element[3] += element[4]  #      Move dot down
+                element[4] += 0.2  #             and accelerate
+
+            column_top = int(column_top)  #      Quantize to pixel space
+            for row in range(column_top):  #     Erase area above column
+                glasses.pixel(column, row, 0)
+            for row in range(column_top, glasses.height):  #  Draw column
+                glasses.pixel(column, row, element[2])
+            glasses.pixel(column, int(element[3]), 0xE08080)  # Draw peak dot
+
+        glasses.show()  # Buffered mode MUST use show() to refresh matrix
+
+        frames += 1
+        # print(frames / (monotonic() - start_time), "FPS")
+
+    except OSError:  # See "try" notes above regarding rare I2C errors.
+        print("Restarting")
+        reload()
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_bus_device/__init__.py b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_bus_device/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_bus_device/i2c_device.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_bus_device/i2c_device.mpy
new file mode 100644 (file)
index 0000000..3a36f31
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_bus_device/i2c_device.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_bus_device/spi_device.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_bus_device/spi_device.mpy
new file mode 100644 (file)
index 0000000..71ee6d0
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_bus_device/spi_device.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_framebuf.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_framebuf.mpy
new file mode 100644 (file)
index 0000000..6021a04
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_framebuf.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/__init__.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/__init__.mpy
new file mode 100644 (file)
index 0000000..5154ba0
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/__init__.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy
new file mode 100644 (file)
index 0000000..7909664
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy
new file mode 100644 (file)
index 0000000..3d91f76
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy
new file mode 100644 (file)
index 0000000..a629b91
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/issi_evb.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/issi_evb.mpy
new file mode 100644 (file)
index 0000000..6f1ae51
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/issi_evb.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/led_glasses_animation.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/led_glasses_animation.mpy
new file mode 100644 (file)
index 0000000..b033289
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/led_glasses_animation.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/led_glasses_map.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/led_glasses_map.mpy
new file mode 100644 (file)
index 0000000..312bc1a
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_is31fl3741/led_glasses_map.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/__init__.py b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_bcd_alarm.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_bcd_alarm.mpy
new file mode 100644 (file)
index 0000000..fdee032
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_bcd_alarm.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_bcd_datetime.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_bcd_datetime.mpy
new file mode 100644 (file)
index 0000000..cd0a27c
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_bcd_datetime.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_bit.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_bit.mpy
new file mode 100644 (file)
index 0000000..815733a
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_bit.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_bits.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_bits.mpy
new file mode 100644 (file)
index 0000000..f7398c2
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_bits.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_struct.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_struct.mpy
new file mode 100644 (file)
index 0000000..b018475
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_struct.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_struct_array.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_struct_array.mpy
new file mode 100644 (file)
index 0000000..62241c6
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 7.x/lib/adafruit_register/i2c_struct_array.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/code.py b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/code.py
new file mode 100755 (executable)
index 0000000..aa6cc81
--- /dev/null
@@ -0,0 +1,186 @@
+# SPDX-FileCopyrightText: 2021 Phil Burgess for Adafruit Industries
+#
+# SPDX-License-Identifier: MIT
+
+"""
+AUDIO SPECTRUM LIGHT SHOW for Adafruit EyeLights (LED Glasses + Driver).
+Uses onboard microphone and a lot of math to react to music.
+"""
+
+from array import array
+from math import log
+from time import monotonic
+from supervisor import reload
+import board
+from audiobusio import PDMIn
+from busio import I2C
+import adafruit_is31fl3741
+from adafruit_is31fl3741.adafruit_rgbmatrixqt import Adafruit_RGBMatrixQT
+from rainbowio import colorwheel
+from ulab import numpy as np
+#  if using CP7 and below:
+from ulab.scipy.signal import spectrogram
+#  if using CP8 and above:
+#  from ulab.utils import spectrogram
+
+
+# FFT/SPECTRUM CONFIG ----
+
+fft_size = 256  # Sample size for Fourier transform, MUST be power of two
+spectrum_size = fft_size // 2  # Output spectrum is 1/2 of FFT result
+# Bottom of spectrum tends to be noisy, while top often exceeds musical
+# range and is just harmonics, so clip both ends off:
+low_bin = 10  # Lowest bin of spectrum that contributes to graph
+high_bin = 75  # Highest bin "
+
+
+# HARDWARE SETUP ---------
+
+# Manually declare I2C (not board.I2C() directly) to access 1 MHz speed...
+i2c = I2C(board.SCL, board.SDA, frequency=1000000)
+
+# Initialize the IS31 LED driver, buffered for smoother animation
+#glasses = LED_Glasses(i2c, allocate=adafruit_is31fl3741.MUST_BUFFER)
+glasses = Adafruit_RGBMatrixQT(i2c, allocate=adafruit_is31fl3741.MUST_BUFFER)
+
+glasses.show()  # Clear any residue on startup
+glasses.set_led_scaling(0xFF)
+glasses.global_current = 5  # Not too bright please
+glasses.enable = True
+
+# Initialize mic and allocate recording buffer (default rate is 16 MHz)
+mic = PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, bit_depth=16)
+rec_buf = array("H", [0] * fft_size)  # 16-bit audio samples
+
+
+# FFT/SPECTRUM SETUP -----
+
+# To keep the display lively, tables are precomputed where each column of
+# the matrix (of which there are few) is the sum value and weighting of
+# several bins from the FFT spectrum output (of which there are many).
+# The tables also help visually linearize the output so octaves are evenly
+# spaced, as on a piano keyboard, whereas the source spectrum data is
+# spaced by frequency in Hz.
+column_table = []
+
+spectrum_bits = log(spectrum_size, 2)  # e.g. 7 for 128-bin spectrum
+# Scale low_bin and high_bin to 0.0 to 1.0 equivalent range in spectrum
+low_frac = log(low_bin, 2) / spectrum_bits
+frac_range = log(high_bin, 2) / spectrum_bits - low_frac
+
+for column in range(glasses.width):
+    # Determine the lower and upper frequency range for this column, as
+    # fractions within the scaled 0.0 to 1.0 spectrum range. 0.95 below
+    # creates slight frequency overlap between columns, looks nicer.
+    lower = low_frac + frac_range * (column / glasses.width * 0.95)
+    upper = low_frac + frac_range * ((column + 1) / glasses.width)
+    mid = (lower + upper) * 0.5  # Center of lower-to-upper range
+    half_width = (upper - lower) * 0.5  # 1/2 of lower-to-upper range
+    # Map fractions back to spectrum bin indices that contribute to column
+    first_bin = int(2 ** (spectrum_bits * lower) + 1e-4)
+    last_bin = int(2 ** (spectrum_bits * upper) + 1e-4)
+    bin_weights = []  # Each spectrum bin's weighting will be added here
+    for bin_index in range(first_bin, last_bin + 1):
+        # Find distance from column's overall center to individual bin's
+        # center, expressed as 0.0 (bin at center) to 1.0 (bin at limit of
+        # lower-to-upper range).
+        bin_center = log(bin_index + 0.5, 2) / spectrum_bits
+        dist = abs(bin_center - mid) / half_width
+        if dist < 1.0:  # Filter out a few math stragglers at either end
+            # Bin weights have a cubic falloff curve within range:
+            dist = 1.0 - dist  # Invert dist so 1.0 is at center
+            bin_weights.append(((3.0 - (dist * 2.0)) * dist) * dist)
+    # Scale bin weights so total is 1.0 for each column, but then mute
+    # lower columns slightly and boost higher columns. It graphs better.
+    total = sum(bin_weights)
+    bin_weights = [
+        (weight / total) * (0.8 + idx / glasses.width * 1.4)
+        for idx, weight in enumerate(bin_weights)
+    ]
+    # List w/five elements is stored for each column:
+    # 0: Index of the first spectrum bin that impacts this column.
+    # 1: A list of bin weights, starting from index above, length varies.
+    # 2: Color for drawing this column on the LED matrix. The 225 is on
+    #    purpose, providing hues from red to purple, leaving out magenta.
+    # 3: Current height of the 'falling dot', updated each frame
+    # 4: Current velocity of the 'falling dot', updated each frame
+    column_table.append(
+        [
+            first_bin - low_bin,
+            bin_weights,
+            colorwheel(225 * column / glasses.width),
+            glasses.height,
+            0.0,
+        ]
+    )
+# print(column_table)
+
+
+# MAIN LOOP -------------
+
+dynamic_level = 10  # For responding to changing volume levels
+frames, start_time = 0, monotonic()  # For frames-per-second calc
+
+while True:
+    # The try/except here is because VERY INFREQUENTLY the I2C bus will
+    # encounter an error when accessing the LED driver, whether from bumping
+    # around the wires or sometimes an I2C device just gets wedged. To more
+    # robustly handle the latter, the code will restart if that happens.
+    try:
+        mic.record(rec_buf, fft_size)  # Record batch of 16-bit samples
+        samples = np.array(rec_buf)  # Convert to ndarray
+        # Compute spectrogram and trim results. Only the left half is
+        # normally needed (right half is mirrored), but we trim further as
+        # only the low_bin to high_bin elements are interesting to graph.
+        spectrum = spectrogram(samples)[low_bin : high_bin + 1]
+        # Linearize spectrum output. spectrogram() is always nonnegative,
+        # but add a tiny value to change any zeros to nonzero numbers
+        # (avoids rare 'inf' error)
+        spectrum = np.log(spectrum + 1e-7)
+        # Determine minimum & maximum across all spectrum bins, with limits
+        lower = max(np.min(spectrum), 4)
+        upper = min(max(np.max(spectrum), lower + 6), 20)
+
+        # Adjust dynamic level to current spectrum output, keeps the graph
+        # 'lively' as ambient volume changes. Sparkle but don't saturate.
+        if upper > dynamic_level:
+            # Got louder. Move level up quickly but allow initial "bump."
+            dynamic_level = upper * 0.7 + dynamic_level * 0.3
+        else:
+            # Got quieter. Ease level down, else too many bumps.
+            dynamic_level = dynamic_level * 0.5 + lower * 0.5
+
+        # Apply vertical scale to spectrum data. Results may exceed
+        # matrix height...that's OK, adds impact!
+        #data = (spectrum - lower) * (7 / (dynamic_level - lower))
+        data = (spectrum - lower) * ((glasses.height + 2) / (dynamic_level - lower))
+
+        for column, element in enumerate(column_table):
+            # Start BELOW matrix and accumulate bin weights UP, saves math
+            first_bin = element[0]
+            column_top = glasses.height + 1
+            for bin_offset, weight in enumerate(element[1]):
+                column_top -= data[first_bin + bin_offset] * weight
+
+            if column_top < element[3]:  #       Above current falling dot?
+                element[3] = column_top - 0.5  # Move dot up
+                element[4] = 0  #                and clear out velocity
+            else:
+                element[3] += element[4]  #      Move dot down
+                element[4] += 0.2  #             and accelerate
+
+            column_top = int(column_top)  #      Quantize to pixel space
+            for row in range(column_top):  #     Erase area above column
+                glasses.pixel(column, row, 0)
+            for row in range(column_top, glasses.height):  #  Draw column
+                glasses.pixel(column, row, element[2])
+            glasses.pixel(column, int(element[3]), 0xE08080)  # Draw peak dot
+
+        glasses.show()  # Buffered mode MUST use show() to refresh matrix
+
+        frames += 1
+        # print(frames / (monotonic() - start_time), "FPS")
+
+    except OSError:  # See "try" notes above regarding rare I2C errors.
+        print("Restarting")
+        reload()
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_bus_device/__init__.py b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_bus_device/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_bus_device/i2c_device.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_bus_device/i2c_device.mpy
new file mode 100644 (file)
index 0000000..3a36f31
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_bus_device/i2c_device.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_bus_device/spi_device.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_bus_device/spi_device.mpy
new file mode 100644 (file)
index 0000000..71ee6d0
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_bus_device/spi_device.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_framebuf.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_framebuf.mpy
new file mode 100644 (file)
index 0000000..6021a04
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_framebuf.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/__init__.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/__init__.mpy
new file mode 100644 (file)
index 0000000..5154ba0
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/__init__.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy
new file mode 100644 (file)
index 0000000..7909664
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy
new file mode 100644 (file)
index 0000000..3d91f76
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy
new file mode 100644 (file)
index 0000000..a629b91
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/issi_evb.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/issi_evb.mpy
new file mode 100644 (file)
index 0000000..6f1ae51
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/issi_evb.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/led_glasses_animation.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/led_glasses_animation.mpy
new file mode 100644 (file)
index 0000000..b033289
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/led_glasses_animation.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/led_glasses_map.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/led_glasses_map.mpy
new file mode 100644 (file)
index 0000000..312bc1a
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_is31fl3741/led_glasses_map.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/__init__.py b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_bcd_alarm.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_bcd_alarm.mpy
new file mode 100644 (file)
index 0000000..fdee032
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_bcd_alarm.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_bcd_datetime.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_bcd_datetime.mpy
new file mode 100644 (file)
index 0000000..cd0a27c
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_bcd_datetime.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_bit.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_bit.mpy
new file mode 100644 (file)
index 0000000..815733a
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_bit.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_bits.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_bits.mpy
new file mode 100644 (file)
index 0000000..f7398c2
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_bits.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_struct.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_struct.mpy
new file mode 100644 (file)
index 0000000..b018475
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_struct.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_struct_array.mpy b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_struct_array.mpy
new file mode 100644 (file)
index 0000000..62241c6
Binary files /dev/null and b/circuitPython/audio_spectrum_lightshow/CircuitPython 8.x/lib/adafruit_register/i2c_struct_array.mpy differ
diff --git a/circuitPython/audio_spectrum_lightshow/README.txt b/circuitPython/audio_spectrum_lightshow/README.txt
new file mode 100644 (file)
index 0000000..85f51ee
--- /dev/null
@@ -0,0 +1,8 @@
+This bundle contains two folders, one each for CircuitPython 7.x and CircuitPython 8.x. You must use the files that match the version of CircuitPython you're using, e.g. if you are using CircuitPython 7, you will copy the files from the CircuitPython 7.x folder to your CIRCUITPY drive.
+To use this project bundle, simply copy the contents of the CircuitPython version folder you're using from the zip file to your CIRCUITPY drive.
+Contents in each version include:
+* the code.py file
+* the lib/ folder and all of its contents (including subfolders and .mpy or .py files)
+* any assets (such as images, sounds, etc.)
+NOTE: This will replace the current code.py, and the lib folder and its contents. Back up any desired code before copying these files!
+ This zip was downloaded from https://learn.adafruit.com/mini-led-matrix-audio-visualizer/code-the-audio-spectrum-light-show on June 25, 2023.
diff --git a/circuitPython/colorswirl.py b/circuitPython/colorswirl.py
new file mode 100644 (file)
index 0000000..80dcf11
--- /dev/null
@@ -0,0 +1,25 @@
+# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
+# SPDX-License-Identifier: MIT
+
+import board
+from rainbowio import colorwheel
+
+from adafruit_is31fl3741.adafruit_rgbmatrixqt import Adafruit_RGBMatrixQT
+import adafruit_is31fl3741
+
+i2c = board.I2C()  # uses board.SCL and board.SDA
+# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
+is31 = Adafruit_RGBMatrixQT(i2c, allocate=adafruit_is31fl3741.PREFER_BUFFER)
+is31.set_led_scaling(10)
+is31.global_current = 50
+# print("Global current is: ", is31.global_current)
+is31.enable = True
+# print("Enabled? ", is31.enable)
+
+wheeloffset = 0
+while True:
+    for y in range(9):
+        for x in range(13):
+            is31.pixel(x, y, colorwheel((y * 13 + x) * 2 + wheeloffset))
+    wheeloffset += 1
+    is31.show()
\ No newline at end of file
diff --git a/circuitPython/ledmatrixTest.py b/circuitPython/ledmatrixTest.py
new file mode 100644 (file)
index 0000000..0aa68ef
--- /dev/null
@@ -0,0 +1,21 @@
+# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
+# SPDX-License-Identifier: MIT
+
+import time
+import board
+import adafruit_is31fl3741
+
+i2c = board.I2C()  # uses board.SCL and board.SDA
+# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
+is31 = adafruit_is31fl3741.IS31FL3741(i2c)
+
+is31.set_led_scaling(0xFF)  # turn on LEDs all the way
+is31.global_current = 0xFF  # set current to max
+is31.enable = True  # enable!
+
+# light up every LED, one at a time
+while True:
+    for pixel in range(351):
+        is31[pixel] = 255
+        time.sleep(0.01)
+        is31[pixel] = 0
\ No newline at end of file
diff --git a/circuitPython/test2.py b/circuitPython/test2.py
new file mode 100644 (file)
index 0000000..c7922ec
--- /dev/null
@@ -0,0 +1,93 @@
+# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
+# SPDX-FileCopyrightText: 2023 Neradoc https://neradoc.me
+# SPDX-License-Identifier: MIT
+"""
+This example repeatedly displays all available animations
+on the IS31FL3741 13x9 RGB Matrix, at a five second interval.
+"""
+import board
+from adafruit_led_animation.animation.blink import Blink
+from adafruit_led_animation.animation.sparklepulse import SparklePulse
+from adafruit_led_animation.animation.comet import Comet
+from adafruit_led_animation.animation.chase import Chase
+from adafruit_led_animation.animation.pulse import Pulse
+from adafruit_led_animation.animation.sparkle import Sparkle
+from adafruit_led_animation.animation.rainbowchase import RainbowChase
+from adafruit_led_animation.animation.rainbowsparkle import RainbowSparkle
+from adafruit_led_animation.animation.rainbowcomet import RainbowComet
+from adafruit_led_animation.animation.solid import Solid
+from adafruit_led_animation.animation.colorcycle import ColorCycle
+from adafruit_led_animation.animation.rainbow import Rainbow
+from adafruit_led_animation.animation.customcolorchase import CustomColorChase
+from adafruit_led_animation.sequence import AnimationSequence
+from adafruit_led_animation.color import PURPLE, WHITE, AMBER, JADE, MAGENTA, ORANGE
+from adafruit_is31fl3741 import PREFER_BUFFER
+from adafruit_is31fl3741.adafruit_rgbmatrixqt import Adafruit_RGBMatrixQT
+from adafruit_is31fl3741.is31fl3741_pixelbuf import IS31FL3741_PixelBuf
+
+# i2c = board.I2C()
+i2c = board.STEMMA_I2C()
+
+########################################################################
+# Instantiate the nice IS31FL3741
+########################################################################
+
+is31 = Adafruit_RGBMatrixQT(i2c, allocate=PREFER_BUFFER)
+is31.set_led_scaling(0xFF)
+is31.global_current = 0xFF
+is31.enable = True
+
+########################################################################
+# Setup the mapping and PixelBuf instance
+########################################################################
+
+WIDTH = 13
+HEIGHT = 9
+LEDS_MAP = tuple(
+    (
+        address
+        for y in range(HEIGHT)
+        for x in range(WIDTH)
+        for address in Adafruit_RGBMatrixQT.pixel_addrs(x, y)
+    )
+)
+pixels = IS31FL3741_PixelBuf(is31, LEDS_MAP, init=False, auto_write=False)
+
+########################################################################
+# Run animations
+########################################################################
+
+blink = Blink(pixels, speed=0.5, color=JADE)
+colorcycle = ColorCycle(pixels, speed=0.4, colors=[MAGENTA, ORANGE])
+comet = Comet(pixels, speed=0.01, color=PURPLE, tail_length=10, bounce=True)
+chase = Chase(pixels, speed=0.1, size=3, spacing=6, color=WHITE)
+pulse = Pulse(pixels, speed=0.1, period=3, color=AMBER)
+sparkle = Sparkle(pixels, speed=0.1, color=PURPLE, num_sparkles=10)
+solid = Solid(pixels, color=JADE)
+rainbow = Rainbow(pixels, speed=0.1, period=2)
+sparkle_pulse = SparklePulse(pixels, speed=0.1, period=3, color=JADE)
+rainbow_comet = RainbowComet(pixels, speed=0.1, tail_length=7, bounce=True)
+rainbow_chase = RainbowChase(pixels, speed=0.1, size=3, spacing=2, step=8)
+rainbow_sparkle = RainbowSparkle(pixels, speed=0.1, num_sparkles=15)
+custom_color_chase = CustomColorChase(
+    pixels, speed=0.1, size=2, spacing=3, colors=[ORANGE, WHITE, JADE]
+)
+
+animations = AnimationSequence(
+    comet,
+    blink,
+    rainbow_sparkle,
+    chase,
+    pulse,
+    sparkle,
+    rainbow,
+    solid,
+    rainbow_comet,
+    sparkle_pulse,
+    rainbow_chase,
+    custom_color_chase,
+    advance_interval=5,
+    auto_clear=True,
+)
+while True:
+    animations.animate()
\ No newline at end of file
diff --git a/circuitPython/testline.py b/circuitPython/testline.py
new file mode 100644 (file)
index 0000000..5fa23a5
--- /dev/null
@@ -0,0 +1,70 @@
+# SPDX-FileCopyrightText: 2023 DJDevon3
+# SPDX-License-Identifier: MIT
+# Chaining 4 13x9 Matrix's to run sequentially (not simultaneously)
+
+import board
+from adafruit_led_animation.sequence import AnimationSequence
+from adafruit_led_animation.animation.rainbowchase import RainbowChase
+from adafruit_is31fl3741 import PREFER_BUFFER
+from adafruit_is31fl3741.adafruit_rgbmatrixqt import Adafruit_RGBMatrixQT
+from adafruit_is31fl3741.is31fl3741_pixelbuf import IS31FL3741_PixelBuf
+
+# Initialize I2C Bus
+i2c = board.STEMMA_I2C()
+# i2c = board.I2C()  # uses board.SCL and board.SDA
+
+# Initialize each 13x9 Matrix
+Matrix30 = Adafruit_RGBMatrixQT(i2c, address=0x30, allocate=PREFER_BUFFER)
+Matrix30.set_led_scaling(0xFF)
+Matrix30.global_current = 0x01
+Matrix30.enable = True
+
+Matrix31 = Adafruit_RGBMatrixQT(i2c, address=0x31, allocate=PREFER_BUFFER)
+Matrix31.set_led_scaling(0xFF)
+Matrix31.global_current = 0x01
+Matrix31.enable = True
+
+Matrix32 = Adafruit_RGBMatrixQT(i2c, address=0x32, allocate=PREFER_BUFFER)
+Matrix32.set_led_scaling(0xFF)
+Matrix32.global_current = 0x01
+Matrix32.enable = True
+
+Matrix33 = Adafruit_RGBMatrixQT(i2c, address=0x33, allocate=PREFER_BUFFER)
+Matrix33.set_led_scaling(0xFF)
+Matrix33.global_current = 0x01
+Matrix33.enable = True
+
+# Demo scrolling pixels
+WIDTH = 13
+HEIGHT = 9
+LEDS_MAP = tuple(
+    (
+        address
+        for y in range(HEIGHT)
+        for x in range(WIDTH)
+        for address in Adafruit_RGBMatrixQT.pixel_addrs(x, y)
+    )
+)
+Matrix30_pixels = IS31FL3741_PixelBuf(Matrix30, LEDS_MAP, init=False, auto_write=False)
+Matrix30_chase = RainbowChase(Matrix30_pixels, speed=0.1, size=1, spacing=3, step=8)
+
+Matrix31_pixels = IS31FL3741_PixelBuf(Matrix31, LEDS_MAP, init=False, auto_write=False)
+Matrix31_chase = RainbowChase(Matrix31_pixels, speed=0.1, size=1, spacing=3, step=8)
+
+Matrix32_pixels = IS31FL3741_PixelBuf(Matrix32, LEDS_MAP, init=False, auto_write=False)
+Matrix32_chase = RainbowChase(Matrix32_pixels, speed=0.1, size=1, spacing=3, step=8)
+
+Matrix33_pixels = IS31FL3741_PixelBuf(Matrix33, LEDS_MAP, init=False, auto_write=False)
+Matrix33_chase = RainbowChase(Matrix33_pixels, speed=0.1, size=1, spacing=3, step=8)
+
+# Run animation on each 13x9 matrix sequentially
+animations = AnimationSequence(
+    Matrix30_chase,
+    Matrix31_chase,
+    Matrix32_chase,
+    Matrix33_chase,
+    advance_interval=1,
+    auto_clear=False,
+)
+while True:
+    animations.animate()
\ No newline at end of file
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/__init__.mpy b/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/__init__.mpy
new file mode 100644 (file)
index 0000000..5154ba0
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/__init__.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy b/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy
new file mode 100644 (file)
index 0000000..7909664
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy b/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy
new file mode 100644 (file)
index 0000000..3d91f76
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy b/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy
new file mode 100644 (file)
index 0000000..a629b91
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/issi_evb.mpy b/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/issi_evb.mpy
new file mode 100644 (file)
index 0000000..6f1ae51
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/issi_evb.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/led_glasses_animation.mpy b/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/led_glasses_animation.mpy
new file mode 100644 (file)
index 0000000..b033289
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/led_glasses_animation.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/led_glasses_map.mpy b/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/led_glasses_map.mpy
new file mode 100644 (file)
index 0000000..312bc1a
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_is31fl3741/led_glasses_map.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/__init__.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/__init__.mpy
new file mode 100644 (file)
index 0000000..9ec55be
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/__init__.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/__init__.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/__init__.mpy
new file mode 100644 (file)
index 0000000..037ca05
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/__init__.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/blink.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/blink.mpy
new file mode 100644 (file)
index 0000000..b0cd095
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/blink.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/chase.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/chase.mpy
new file mode 100644 (file)
index 0000000..2e5ee2a
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/chase.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/colorcycle.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/colorcycle.mpy
new file mode 100644 (file)
index 0000000..3132ac9
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/colorcycle.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/comet.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/comet.mpy
new file mode 100644 (file)
index 0000000..3578e95
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/comet.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/customcolorchase.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/customcolorchase.mpy
new file mode 100644 (file)
index 0000000..65263c3
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/customcolorchase.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/grid_rain.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/grid_rain.mpy
new file mode 100644 (file)
index 0000000..453ada5
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/grid_rain.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/pulse.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/pulse.mpy
new file mode 100644 (file)
index 0000000..c4d9505
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/pulse.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/rainbow.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/rainbow.mpy
new file mode 100644 (file)
index 0000000..05c8d49
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/rainbow.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/rainbowchase.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/rainbowchase.mpy
new file mode 100644 (file)
index 0000000..4d14733
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/rainbowchase.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/rainbowcomet.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/rainbowcomet.mpy
new file mode 100644 (file)
index 0000000..8f16956
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/rainbowcomet.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/rainbowsparkle.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/rainbowsparkle.mpy
new file mode 100644 (file)
index 0000000..cef9b76
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/rainbowsparkle.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/solid.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/solid.mpy
new file mode 100644 (file)
index 0000000..f95d430
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/solid.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/sparkle.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/sparkle.mpy
new file mode 100644 (file)
index 0000000..5264330
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/sparkle.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/sparklepulse.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/sparklepulse.mpy
new file mode 100644 (file)
index 0000000..9d59cd1
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/animation/sparklepulse.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/color.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/color.mpy
new file mode 100644 (file)
index 0000000..37305cf
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/color.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/grid.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/grid.mpy
new file mode 100644 (file)
index 0000000..f7b4637
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/grid.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/group.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/group.mpy
new file mode 100644 (file)
index 0000000..a0b9957
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/group.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/helper.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/helper.mpy
new file mode 100644 (file)
index 0000000..01553d6
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/helper.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_led_animation/sequence.mpy b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/sequence.mpy
new file mode 100644 (file)
index 0000000..03e1d71
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_led_animation/sequence.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_register/__init__.py b/circuitPython/uploadFromMCU/lib/adafruit_register/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_register/i2c_bcd_alarm.mpy b/circuitPython/uploadFromMCU/lib/adafruit_register/i2c_bcd_alarm.mpy
new file mode 100644 (file)
index 0000000..833e909
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_register/i2c_bcd_alarm.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_register/i2c_bcd_datetime.mpy b/circuitPython/uploadFromMCU/lib/adafruit_register/i2c_bcd_datetime.mpy
new file mode 100644 (file)
index 0000000..161a81b
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_register/i2c_bcd_datetime.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_register/i2c_bit.mpy b/circuitPython/uploadFromMCU/lib/adafruit_register/i2c_bit.mpy
new file mode 100644 (file)
index 0000000..d097614
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_register/i2c_bit.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_register/i2c_bits.mpy b/circuitPython/uploadFromMCU/lib/adafruit_register/i2c_bits.mpy
new file mode 100644 (file)
index 0000000..1d865a8
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_register/i2c_bits.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_register/i2c_struct.mpy b/circuitPython/uploadFromMCU/lib/adafruit_register/i2c_struct.mpy
new file mode 100644 (file)
index 0000000..c9bc877
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_register/i2c_struct.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/adafruit_register/i2c_struct_array.mpy b/circuitPython/uploadFromMCU/lib/adafruit_register/i2c_struct_array.mpy
new file mode 100644 (file)
index 0000000..0df98b3
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/adafruit_register/i2c_struct_array.mpy differ
diff --git a/circuitPython/uploadFromMCU/lib/simpleio.mpy b/circuitPython/uploadFromMCU/lib/simpleio.mpy
new file mode 100644 (file)
index 0000000..5e18da5
Binary files /dev/null and b/circuitPython/uploadFromMCU/lib/simpleio.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 7.x/code.py b/circuitPython/waterfall_visualizer/CircuitPython 7.x/code.py
new file mode 100644 (file)
index 0000000..afa5110
--- /dev/null
@@ -0,0 +1,104 @@
+# SPDX-FileCopyrightText: 2021 Liz Clark for Adafruit Industries
+#
+# SPDX-License-Identifier: MIT
+
+'''Adapted from the FFT Example: Waterfall Spectrum Analyzer
+by Jeff Epler
+https://learn.adafruit.com/ulab-crunch-numbers-fast-with-circuitpython/overview '''
+
+import array
+import board
+import audiobusio
+import busio
+from ulab import numpy as np
+from ulab.scipy.signal import spectrogram
+import adafruit_is31fl3741
+from adafruit_is31fl3741.adafruit_rgbmatrixqt import Adafruit_RGBMatrixQT
+
+#  Manually declare I2c (not board.I2C()) to access 1 MHz speed for
+i2c = busio.I2C(board.SCL, board.SDA, frequency=1000000)
+#  Declare is31 w/buffering preferred (low RAM will fall back on unbuffered)
+is31 = Adafruit_RGBMatrixQT(i2c, allocate=adafruit_is31fl3741.PREFER_BUFFER)
+#  In buffered mode, MUST use show() to refresh matrix (see line 94)
+
+#  brightness for the RGBMatrixQT
+#  set to about 20%
+is31.set_led_scaling(0x19)
+is31.global_current = 0x03
+is31.enable = True
+
+#  array of colors for the LEDs
+#  goes from purple to red
+#  gradient generated using https://colordesigner.io/gradient-generator
+heatmap = [0xb000ff,0xa600ff,0x9b00ff,0x8f00ff,0x8200ff,
+           0x7400ff,0x6500ff,0x5200ff,0x3900ff,0x0003ff,
+           0x0003ff,0x0047ff,0x0066ff,0x007eff,0x0093ff,
+           0x00a6ff,0x00b7ff,0x00c8ff,0x00d7ff,0x00e5ff,
+           0x00e0ff,0x00e6fd,0x00ecf6,0x00f2ea,0x00f6d7,
+           0x00fac0,0x00fca3,0x00fe81,0x00ff59,0x00ff16,
+           0x00ff16,0x45ff08,0x62ff00,0x78ff00,0x8bff00,
+           0x9bff00,0xaaff00,0xb8ff00,0xc5ff00,0xd1ff00,
+           0xedff00,0xf5eb00,0xfcd600,0xffc100,0xffab00,
+           0xff9500,0xff7c00,0xff6100,0xff4100,0xff0000,
+           0xff0000,0xff0000]
+
+#  size of the FFT data sample
+fft_size = 64
+
+#  setup for onboard mic
+mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA,
+                       sample_rate=16000, bit_depth=16)
+
+#  use some extra sample to account for the mic startup
+samples_bit = array.array('H', [0] * (fft_size+3))
+
+#  sends visualized data to the RGB matrix with colors
+def waves(data, y):
+    offset = max(0, (13-len(data))//2)
+
+    for x in range(min(13, len(data))):
+        is31.pixel(x+offset, y, heatmap[int(data[x])])
+
+# main loop
+def main():
+    #  value for audio samples
+    max_all = 10
+    #  variable to move data along the matrix
+    scroll_offset = 0
+    #  setting the y axis value to equal the scroll_offset
+    y = scroll_offset
+
+    while True:
+        #  record the audio sample
+        mic.record(samples_bit, len(samples_bit))
+        #  send the sample to the ulab array
+        samples = np.array(samples_bit[3:])
+        #  creates a spectogram of the data
+        spectrogram1 = spectrogram(samples)
+        # spectrum() is always nonnegative, but add a tiny value
+        # to change any zeros to nonzero numbers
+        spectrogram1 = np.log(spectrogram1 + 1e-7)
+        spectrogram1 = spectrogram1[1:(fft_size//2)-1]
+        #  sets range of the spectrogram
+        min_curr = np.min(spectrogram1)
+        max_curr = np.max(spectrogram1)
+        #  resets values
+        if max_curr > max_all:
+            max_all = max_curr
+        else:
+            max_curr = max_curr-1
+        min_curr = max(min_curr, 3)
+        # stores spectrogram in data
+        data = (spectrogram1 - min_curr) * (51. / (max_all - min_curr))
+        # sets negative numbers to zero
+        data = data * np.array((data > 0))
+        #  resets y
+        y = scroll_offset
+        #  runs waves to write data to the LED's
+        waves(data, y)
+        #  updates scroll_offset to move data along matrix
+        scroll_offset = (y + 1) % 9
+        #  writes data to the RGB matrix
+        is31.show()
+
+main()
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_bus_device/__init__.py b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_bus_device/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_bus_device/i2c_device.mpy b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_bus_device/i2c_device.mpy
new file mode 100644 (file)
index 0000000..3a36f31
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_bus_device/i2c_device.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_bus_device/spi_device.mpy b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_bus_device/spi_device.mpy
new file mode 100644 (file)
index 0000000..71ee6d0
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_bus_device/spi_device.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_framebuf.mpy b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_framebuf.mpy
new file mode 100644 (file)
index 0000000..6021a04
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_framebuf.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/__init__.mpy b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/__init__.mpy
new file mode 100644 (file)
index 0000000..5154ba0
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/__init__.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy
new file mode 100644 (file)
index 0000000..7909664
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy
new file mode 100644 (file)
index 0000000..3d91f76
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy
new file mode 100644 (file)
index 0000000..a629b91
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/issi_evb.mpy b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/issi_evb.mpy
new file mode 100644 (file)
index 0000000..6f1ae51
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/issi_evb.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/led_glasses_animation.mpy b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/led_glasses_animation.mpy
new file mode 100644 (file)
index 0000000..b033289
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/led_glasses_animation.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/led_glasses_map.mpy b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/led_glasses_map.mpy
new file mode 100644 (file)
index 0000000..312bc1a
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_is31fl3741/led_glasses_map.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/__init__.py b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_bcd_alarm.mpy b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_bcd_alarm.mpy
new file mode 100644 (file)
index 0000000..fdee032
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_bcd_alarm.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_bcd_datetime.mpy b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_bcd_datetime.mpy
new file mode 100644 (file)
index 0000000..cd0a27c
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_bcd_datetime.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_bit.mpy b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_bit.mpy
new file mode 100644 (file)
index 0000000..815733a
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_bit.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_bits.mpy b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_bits.mpy
new file mode 100644 (file)
index 0000000..f7398c2
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_bits.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_struct.mpy b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_struct.mpy
new file mode 100644 (file)
index 0000000..b018475
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_struct.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_struct_array.mpy b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_struct_array.mpy
new file mode 100644 (file)
index 0000000..62241c6
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 7.x/lib/adafruit_register/i2c_struct_array.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 8.x/code.py b/circuitPython/waterfall_visualizer/CircuitPython 8.x/code.py
new file mode 100644 (file)
index 0000000..afa5110
--- /dev/null
@@ -0,0 +1,104 @@
+# SPDX-FileCopyrightText: 2021 Liz Clark for Adafruit Industries
+#
+# SPDX-License-Identifier: MIT
+
+'''Adapted from the FFT Example: Waterfall Spectrum Analyzer
+by Jeff Epler
+https://learn.adafruit.com/ulab-crunch-numbers-fast-with-circuitpython/overview '''
+
+import array
+import board
+import audiobusio
+import busio
+from ulab import numpy as np
+from ulab.scipy.signal import spectrogram
+import adafruit_is31fl3741
+from adafruit_is31fl3741.adafruit_rgbmatrixqt import Adafruit_RGBMatrixQT
+
+#  Manually declare I2c (not board.I2C()) to access 1 MHz speed for
+i2c = busio.I2C(board.SCL, board.SDA, frequency=1000000)
+#  Declare is31 w/buffering preferred (low RAM will fall back on unbuffered)
+is31 = Adafruit_RGBMatrixQT(i2c, allocate=adafruit_is31fl3741.PREFER_BUFFER)
+#  In buffered mode, MUST use show() to refresh matrix (see line 94)
+
+#  brightness for the RGBMatrixQT
+#  set to about 20%
+is31.set_led_scaling(0x19)
+is31.global_current = 0x03
+is31.enable = True
+
+#  array of colors for the LEDs
+#  goes from purple to red
+#  gradient generated using https://colordesigner.io/gradient-generator
+heatmap = [0xb000ff,0xa600ff,0x9b00ff,0x8f00ff,0x8200ff,
+           0x7400ff,0x6500ff,0x5200ff,0x3900ff,0x0003ff,
+           0x0003ff,0x0047ff,0x0066ff,0x007eff,0x0093ff,
+           0x00a6ff,0x00b7ff,0x00c8ff,0x00d7ff,0x00e5ff,
+           0x00e0ff,0x00e6fd,0x00ecf6,0x00f2ea,0x00f6d7,
+           0x00fac0,0x00fca3,0x00fe81,0x00ff59,0x00ff16,
+           0x00ff16,0x45ff08,0x62ff00,0x78ff00,0x8bff00,
+           0x9bff00,0xaaff00,0xb8ff00,0xc5ff00,0xd1ff00,
+           0xedff00,0xf5eb00,0xfcd600,0xffc100,0xffab00,
+           0xff9500,0xff7c00,0xff6100,0xff4100,0xff0000,
+           0xff0000,0xff0000]
+
+#  size of the FFT data sample
+fft_size = 64
+
+#  setup for onboard mic
+mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA,
+                       sample_rate=16000, bit_depth=16)
+
+#  use some extra sample to account for the mic startup
+samples_bit = array.array('H', [0] * (fft_size+3))
+
+#  sends visualized data to the RGB matrix with colors
+def waves(data, y):
+    offset = max(0, (13-len(data))//2)
+
+    for x in range(min(13, len(data))):
+        is31.pixel(x+offset, y, heatmap[int(data[x])])
+
+# main loop
+def main():
+    #  value for audio samples
+    max_all = 10
+    #  variable to move data along the matrix
+    scroll_offset = 0
+    #  setting the y axis value to equal the scroll_offset
+    y = scroll_offset
+
+    while True:
+        #  record the audio sample
+        mic.record(samples_bit, len(samples_bit))
+        #  send the sample to the ulab array
+        samples = np.array(samples_bit[3:])
+        #  creates a spectogram of the data
+        spectrogram1 = spectrogram(samples)
+        # spectrum() is always nonnegative, but add a tiny value
+        # to change any zeros to nonzero numbers
+        spectrogram1 = np.log(spectrogram1 + 1e-7)
+        spectrogram1 = spectrogram1[1:(fft_size//2)-1]
+        #  sets range of the spectrogram
+        min_curr = np.min(spectrogram1)
+        max_curr = np.max(spectrogram1)
+        #  resets values
+        if max_curr > max_all:
+            max_all = max_curr
+        else:
+            max_curr = max_curr-1
+        min_curr = max(min_curr, 3)
+        # stores spectrogram in data
+        data = (spectrogram1 - min_curr) * (51. / (max_all - min_curr))
+        # sets negative numbers to zero
+        data = data * np.array((data > 0))
+        #  resets y
+        y = scroll_offset
+        #  runs waves to write data to the LED's
+        waves(data, y)
+        #  updates scroll_offset to move data along matrix
+        scroll_offset = (y + 1) % 9
+        #  writes data to the RGB matrix
+        is31.show()
+
+main()
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_bus_device/__init__.py b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_bus_device/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_bus_device/i2c_device.mpy b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_bus_device/i2c_device.mpy
new file mode 100644 (file)
index 0000000..3a36f31
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_bus_device/i2c_device.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_bus_device/spi_device.mpy b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_bus_device/spi_device.mpy
new file mode 100644 (file)
index 0000000..71ee6d0
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_bus_device/spi_device.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_framebuf.mpy b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_framebuf.mpy
new file mode 100644 (file)
index 0000000..6021a04
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_framebuf.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/__init__.mpy b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/__init__.mpy
new file mode 100644 (file)
index 0000000..5154ba0
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/__init__.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy
new file mode 100644 (file)
index 0000000..7909664
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/adafruit_ledglasses.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy
new file mode 100644 (file)
index 0000000..3d91f76
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/adafruit_rgbmatrixqt.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy
new file mode 100644 (file)
index 0000000..a629b91
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/is31fl3741_pixelbuf.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/issi_evb.mpy b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/issi_evb.mpy
new file mode 100644 (file)
index 0000000..6f1ae51
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/issi_evb.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/led_glasses_animation.mpy b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/led_glasses_animation.mpy
new file mode 100644 (file)
index 0000000..b033289
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/led_glasses_animation.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/led_glasses_map.mpy b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/led_glasses_map.mpy
new file mode 100644 (file)
index 0000000..312bc1a
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_is31fl3741/led_glasses_map.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/__init__.py b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_bcd_alarm.mpy b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_bcd_alarm.mpy
new file mode 100644 (file)
index 0000000..fdee032
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_bcd_alarm.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_bcd_datetime.mpy b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_bcd_datetime.mpy
new file mode 100644 (file)
index 0000000..cd0a27c
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_bcd_datetime.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_bit.mpy b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_bit.mpy
new file mode 100644 (file)
index 0000000..815733a
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_bit.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_bits.mpy b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_bits.mpy
new file mode 100644 (file)
index 0000000..f7398c2
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_bits.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_struct.mpy b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_struct.mpy
new file mode 100644 (file)
index 0000000..b018475
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_struct.mpy differ
diff --git a/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_struct_array.mpy b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_struct_array.mpy
new file mode 100644 (file)
index 0000000..62241c6
Binary files /dev/null and b/circuitPython/waterfall_visualizer/CircuitPython 8.x/lib/adafruit_register/i2c_struct_array.mpy differ
diff --git a/circuitPython/waterfall_visualizer/README.txt b/circuitPython/waterfall_visualizer/README.txt
new file mode 100644 (file)
index 0000000..9512350
--- /dev/null
@@ -0,0 +1,8 @@
+This bundle contains two folders, one each for CircuitPython 7.x and CircuitPython 8.x. You must use the files that match the version of CircuitPython you're using, e.g. if you are using CircuitPython 7, you will copy the files from the CircuitPython 7.x folder to your CIRCUITPY drive.
+To use this project bundle, simply copy the contents of the CircuitPython version folder you're using from the zip file to your CIRCUITPY drive.
+Contents in each version include:
+* the code.py file
+* the lib/ folder and all of its contents (including subfolders and .mpy or .py files)
+* any assets (such as images, sounds, etc.)
+NOTE: This will replace the current code.py, and the lib folder and its contents. Back up any desired code before copying these files!
+ This zip was downloaded from https://learn.adafruit.com/mini-led-matrix-audio-visualizer/code-the-mini-led-matrix-audio-visualizer on June 25, 2023.
diff --git a/cpxtest.py b/cpxtest.py
new file mode 100644 (file)
index 0000000..07ac373
--- /dev/null
@@ -0,0 +1,133 @@
+# SPDX-FileCopyrightText: 2017 Dan Halbert for Adafruit Industries
+# SPDX-FileCopyrightText: 2017 Tony DiCola for Adafruit Industries
+# SPDX-FileCopyrightText: 2017 Kattni Rembor for Adafruit Industries
+#
+# SPDX-License-Identifier: MIT
+
+# The MIT License (MIT)
+#
+# Copyright (c) 2017 Dan Halbert for Adafruit Industries
+# Copyright (c) 2017 Kattni Rembor, Tony DiCola for Adafruit Industries
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+# Circuit Playground Sound Meter
+
+import array
+import math
+import audiobusio
+import board
+import neopixel
+
+# Color of the peak pixel.
+PEAK_COLOR = (100, 0, 255)
+# Number of total pixels - 10 build into Circuit Playground
+NUM_PIXELS = 10
+
+# Exponential scaling factor.
+# Should probably be in range -10 .. 10 to be reasonable.
+CURVE =4 
+SCALE_EXPONENT = math.pow(10, CURVE * -0.1)
+
+# Number of samples to read at once.
+NUM_SAMPLES = 160
+
+
+# Restrict value to be between floor and ceiling.
+def constrain(value, floor, ceiling):
+    return max(floor, min(value, ceiling))
+
+
+# Scale input_value between output_min and output_max, exponentially.
+def log_scale(input_value, input_min, input_max, output_min, output_max):
+    normalized_input_value = (input_value - input_min) / \
+                             (input_max - input_min)
+    return output_min + \
+        math.pow(normalized_input_value, SCALE_EXPONENT) \
+        * (output_max - output_min)
+
+
+# Remove DC bias before computing RMS.
+def normalized_rms(values):
+    minbuf = int(mean(values))
+    samples_sum = sum(
+        float(sample - minbuf) * (sample - minbuf)
+        for sample in values
+    )
+
+    return math.sqrt(samples_sum / len(values))
+
+
+def mean(values):
+    return sum(values) / len(values)
+
+
+def volume_color(volume):
+    return 200, volume * (255 // NUM_PIXELS), 0
+
+
+# Main program
+
+# Set up NeoPixels and turn them all off.
+pixels = neopixel.NeoPixel(board.NEOPIXEL, NUM_PIXELS, brightness=0.1, auto_write=False)
+pixels.fill(0)
+pixels.show()
+
+mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA,
+                       sample_rate=16000, bit_depth=16)
+
+# Record an initial sample to calibrate. Assume it's quiet when we start.
+samples = array.array('H', [0] * NUM_SAMPLES)
+mic.record(samples, len(samples))
+# Set lowest level to expect, plus a little.
+input_floor = normalized_rms(samples) + 10
+# OR: used a fixed floor
+# input_floor = 50
+
+# You might want to print the input_floor to help adjust other values.
+# print(input_floor)
+
+# Corresponds to sensitivity: lower means more pixels light up with lower sound
+# Adjust this as you see fit.
+input_ceiling = input_floor + 500
+
+peak = 0
+while True:
+    mic.record(samples, len(samples))
+    magnitude = normalized_rms(samples)
+    # You might want to print this to see the values.
+    # print(magnitude)
+
+    # Compute scaled logarithmic reading in the range 0 to NUM_PIXELS
+    c = log_scale(constrain(magnitude, input_floor, input_ceiling),
+                  input_floor, input_ceiling, 0, NUM_PIXELS)
+
+    # Light up pixels that are below the scaled and interpolated magnitude.
+    pixels.fill(0)
+    for i in range(NUM_PIXELS):
+        if i < c:
+            pixels[i] = volume_color(i)
+        # Light up the peak pixel and animate it slowly dropping.
+        if c >= peak:
+            peak = min(c, NUM_PIXELS - 1)
+        elif peak > 0:
+            peak = peak - 1
+        if peak > 0:
+            pixels[int(peak)] = PEAK_COLOR
+    pixels.show()
diff --git a/demoRGB.py b/demoRGB.py
new file mode 100644 (file)
index 0000000..5776bed
--- /dev/null
@@ -0,0 +1,43 @@
+import machine, neopixel, time
+np=neopixel.NeoPixel(machine.Pin(0), 96)
+
+def demo(np):
+    n = np.n
+
+    # cycle
+    for i in range(4 * n):
+        for j in range(n):
+            np[j] = (0, 0, 0)
+        np[i % n] = (255, 255, 255)
+        np.write()
+        time.sleep_ms(25)
+
+    # bounce
+    for i in range(4 * n):
+        for j in range(n):
+            np[j] = (0, 128, 128)
+        if (i // n) % 2 == 0:
+            np[i % n] = (0, 0, 0)
+        else:
+            np[n - 1 - (i % n)] = (0, 0, 0)
+        np.write()
+        time.sleep_ms(60)
+
+    # fade in/out
+    for i in range(0, 4 * 256, 8):
+        for j in range(n):
+            if (i // 256) % 2 == 0:
+                val = i & 0xff
+            else:
+                val = 255 - (i & 0xff)
+            np[j] = (val, 0, 0)
+        np.write()
+
+    # clear
+    for i in range(n):
+        np[i] = (0, 0, 0)
+    np.write()
+
+
+while True:
+    demo(np)
\ No newline at end of file
index 789e50d0dd7645f476c335706032efc00a061836..44d80fe845e39a34dda087d790e86e263188329b 100644 (file)
--- a/diary.txt
+++ b/diary.txt
@@ -8,3 +8,43 @@ downloaded into /home/pi/Desktop/microPythonProjects/sensorLib
 created directory inside microPythonProjects>sensoryWall
 have us100 test script to print distance and verify it works. IT DOES!!
 
 created directory inside microPythonProjects>sensoryWall
 have us100 test script to print distance and verify it works. IT DOES!!
 
+<<<<<<< HEAD
+=======
+fancy LEDs
+--short pin is ground, long needs power and resistor
+
+will test distance sensor sensing distance>turning on LED
+----see distanceTest.py
+
+!!need to clearly define operating distance!!
+
+6/25/23
+decided to test code for PDM mic and is31fl3741 LED board, separately
+will most likely have to run circuitpython for this feature, currently 
+testing on KB2040 (got 1 free in order) hoping to reduce total number of
+wires
+can animate LEDs
+using Adafruit guides, set up/tested mic and got values (but no sound.file).
+also, have set up NFS mount to allow for easier backup/access to backuped file
+
+6/27/23
+got the LED matrix animation working, using a project pack from Adafruit.
+brougth to work, along with breadboarded us100 and LEDs. Individuals really 
+liked. Did enjoy toggling matrix on/off, and playing with distance sensor
+to light up LEDs. Put toggle switch on clock line of PDM mic, allowing 
+on/off toggle
+
+8/5/23
+fully built 5v led strip controller (animated LED strip, us-100, arcade 
+button), coded so that light is off unless close enough to activate, or 
+button pressed. Did build n00ds web, using randomint for time on/off on 
+strands. got 12v tower light running, burned pico out with 12v short into 
+it from light/hair bridging pins. NEED TO USE KAPTON TAPE!!!!! 
+may throw 2 pico's in, 1 to replace the one i killed, 1 to make another 
+12v controller. 
+
+sound board was replaced, is working at this time. Can control via GPIO 
+by pulling pins low. no need to add mcu to control this device, but if 
+tying lines, need common ground. then just set that pin as output, pull
+high/low as needed, control via button press/trigger event
+>>>>>>> 2af4f5c (more sensory wall projects)
index 1a3909fa79a624a132476bdcbb9c35115129bf3d..dcda41a5b765b03a994398a992c488ebbfc01bd5 100644 (file)
@@ -2,6 +2,7 @@ import machine
 import utime
 import us100
 
 import utime
 import us100
 
+<<<<<<< HEAD
 uart = machine.UART(0)
 sensor = us100.US100UART(uart)
 
 uart = machine.UART(0)
 sensor = us100.US100UART(uart)
 
@@ -9,3 +10,58 @@ Ygem=machine.Pin(10,machine.Pin.OUT)
 Bgem=machine.Pin(16,machine.Pin.OUT)
 plant=machine.Pin(18,machne.Pin.OUT)
 
 Bgem=machine.Pin(16,machine.Pin.OUT)
 plant=machine.Pin(18,machne.Pin.OUT)
 
+=======
+uart = machine.UART(1)
+sensor = us100.US100UART(uart)
+
+distance=0
+
+Ygem=machine.Pin(10,machine.Pin.OUT)
+Bgem=machine.Pin(16,machine.Pin.OUT)
+plant=machine.Pin(18,machine.Pin.OUT)
+
+Ygem.off();Bgem.off();plant.off()
+
+def measure():
+    global distance
+    distance=sensor.distance()
+    return distance
+    
+def analyze():
+    if distance <=500 and distance>=350:
+        Ygem.on()
+        Bgem.off()
+        plant.off()
+        return
+    elif distance <=350 and distance >=150:
+        plant.on()
+        Ygem.off()
+        return
+    elif distance <=150 and distance >75:
+        Bgem.on()
+        plant.off()
+        Ygem.on()
+        return
+    elif distance <=75:
+        Bgem.off()
+        plant.on()
+        Ygem.on()
+        return
+    else:
+        Bgem.off()
+        plant.off()
+        Ygem.off()
+        return
+
+while True:
+    try:
+        measure()
+        print(distance)
+        analyze()
+        utime.sleep_ms(50)
+    except Exception: #catches error if sensor is covered, simply passes that cycle
+        print("HEY BOSS")
+        pass
+if KeyboardInterrupt: 
+    pass
+>>>>>>> 2af4f5c (more sensory wall projects)
diff --git a/main.py b/main.py
new file mode 100644 (file)
index 0000000..4bf5d26
--- /dev/null
+++ b/main.py
@@ -0,0 +1,9 @@
+import machine, neopixel
+p=machine.Pin(0)
+n=neopixel.NeoPixel(p, 20)
+# needs 12v power supply
+while True:
+    for i in range(20):
+        n[i]=(i*8,0,0)
+    
+    n.write()
\ No newline at end of file
diff --git a/pico_soundboard.py b/pico_soundboard.py
new file mode 100644 (file)
index 0000000..968ee4f
--- /dev/null
@@ -0,0 +1,43 @@
+import time
+import us100
+from machine import Pin
+
+uart = machine.UART(0)
+sensor = us100.US100UART(uart)
+
+distance=0
+
+def measure():
+    global distance
+    distance=sensor.distance()
+    return distance
+    
+
+
+"""
+PINS Set pins like below  (MUST SHARE A GROUND)
+p0=Pin(0,Pin.OUT,Pin.PULL_UP) CAN'T USE PIN 0, already being used by LED strip
+p0.high()
+p1
+p2
+p3
+p4
+p5
+p6
+p7
+p8
+p9
+p10
+
+volU (connect to V+)
+volD (connect to V_)
+
+R    (connect to RST)
+"""
+
+#TODO create func to grab correct Pin and pass to trig(p) i.e. trig(p0)
+def trig(p):
+    p.low()
+    time.sleep_ms(125)
+    p.high()
+    
\ No newline at end of file
diff --git a/redlight.py b/redlight.py
new file mode 100644 (file)
index 0000000..427b354
--- /dev/null
@@ -0,0 +1,47 @@
+from machine import Pin
+import time, random
+
+green=Pin(17,Pin.OUT)
+yellow=Pin(14,Pin.OUT)
+red=Pin(15,Pin.OUT)
+
+leds=[green,yellow,red]
+global count
+count=0
+
+manPin=Pin(18,Pin.IN,Pin.PULL_UP)
+button=Pin(16,Pin.IN,Pin.PULL_UP) 
+
+green.on()
+yellow.off()
+red.off()
+
+def button_handler():
+    if button.value()==0:
+        global count
+        leds[count].off()
+        print(count)
+        count=count+1
+        if count==3:
+            count=0
+        leds[count].on()
+        return count
+    
+def rand_handler():
+    global count
+    leds[count].off()
+    print(count)
+    count=count+1
+    if count==3:
+        count=0
+    leds[count].on()
+    return count
+    
+while True:
+    if manPin.value()==1:
+        button_handler()
+        time.sleep(0.5)
+    else:
+        rand_handler()
+        time.sleep(random.randint(3,15))
+    
\ No newline at end of file
diff --git a/sampleTracks/T00.ogg b/sampleTracks/T00.ogg
new file mode 100644 (file)
index 0000000..2bc691f
Binary files /dev/null and b/sampleTracks/T00.ogg differ
diff --git a/sampleTracks/T01RAND0.wav b/sampleTracks/T01RAND0.wav
new file mode 100644 (file)
index 0000000..3827ded
Binary files /dev/null and b/sampleTracks/T01RAND0.wav differ
diff --git a/sampleTracks/T01RAND1.wav b/sampleTracks/T01RAND1.wav
new file mode 100644 (file)
index 0000000..ad4c92e
Binary files /dev/null and b/sampleTracks/T01RAND1.wav differ
diff --git a/sampleTracks/T01RAND2.wav b/sampleTracks/T01RAND2.wav
new file mode 100644 (file)
index 0000000..304ecb6
Binary files /dev/null and b/sampleTracks/T01RAND2.wav differ
diff --git a/sampleTracks/T01RAND3.wav b/sampleTracks/T01RAND3.wav
new file mode 100644 (file)
index 0000000..ed6ce5a
Binary files /dev/null and b/sampleTracks/T01RAND3.wav differ
diff --git a/sampleTracks/T01RAND4.wav b/sampleTracks/T01RAND4.wav
new file mode 100644 (file)
index 0000000..f074d1d
Binary files /dev/null and b/sampleTracks/T01RAND4.wav differ
diff --git a/sampleTracks/T02.wav b/sampleTracks/T02.wav
new file mode 100644 (file)
index 0000000..9d1fdb9
Binary files /dev/null and b/sampleTracks/T02.wav differ
diff --git a/sampleTracks/T03.wav b/sampleTracks/T03.wav
new file mode 100644 (file)
index 0000000..6676d5e
Binary files /dev/null and b/sampleTracks/T03.wav differ
diff --git a/sampleTracks/T04HOLDL.wav b/sampleTracks/T04HOLDL.wav
new file mode 100644 (file)
index 0000000..8874db7
Binary files /dev/null and b/sampleTracks/T04HOLDL.wav differ
diff --git a/sampleTracks/T05NEXT0.wav b/sampleTracks/T05NEXT0.wav
new file mode 100644 (file)
index 0000000..2881e7a
Binary files /dev/null and b/sampleTracks/T05NEXT0.wav differ
diff --git a/sampleTracks/T05NEXT1.wav b/sampleTracks/T05NEXT1.wav
new file mode 100644 (file)
index 0000000..a467cfa
Binary files /dev/null and b/sampleTracks/T05NEXT1.wav differ
diff --git a/sampleTracks/T05NEXT2.wav b/sampleTracks/T05NEXT2.wav
new file mode 100644 (file)
index 0000000..5e2a427
Binary files /dev/null and b/sampleTracks/T05NEXT2.wav differ
diff --git a/sampleTracks/T06LATCH.wav b/sampleTracks/T06LATCH.wav
new file mode 100644 (file)
index 0000000..50044f4
Binary files /dev/null and b/sampleTracks/T06LATCH.wav differ
diff --git a/sampleTracks/T07.wav b/sampleTracks/T07.wav
new file mode 100644 (file)
index 0000000..0ac585e
Binary files /dev/null and b/sampleTracks/T07.wav differ
diff --git a/sampleTracks/T08.wav b/sampleTracks/T08.wav
new file mode 100644 (file)
index 0000000..6ca9c86
Binary files /dev/null and b/sampleTracks/T08.wav differ
diff --git a/sampleTracks/T09.wav b/sampleTracks/T09.wav
new file mode 100644 (file)
index 0000000..7d75be3
Binary files /dev/null and b/sampleTracks/T09.wav differ
diff --git a/sampleTracks/T10.wav b/sampleTracks/T10.wav
new file mode 100644 (file)
index 0000000..05815af
Binary files /dev/null and b/sampleTracks/T10.wav differ
diff --git a/towertest.py b/towertest.py
new file mode 100644 (file)
index 0000000..321c981
--- /dev/null
@@ -0,0 +1,21 @@
+from machine import Pin
+import time
+
+green=Pin(17,Pin.OUT)
+yellow=Pin(14,Pin.OUT)
+red=Pin(15,Pin.OUT)
+
+green.off()
+yellow.off()
+red.off()
+
+while True:
+    red.off()
+    green.on()
+    time.sleep(10)
+    green.off()
+    yellow.on()
+    time.sleep(10)
+    yellow.off()
+    red.on()
+    time.sleep(10)
\ No newline at end of file
diff --git a/trafficLight.py b/trafficLight.py
new file mode 100644 (file)
index 0000000..5b5b5aa
--- /dev/null
@@ -0,0 +1,53 @@
+from machine import Pin
+import time
+from random import randint
+
+btn=Pin(12,Pin.IN,Pin.PULL_UP)
+
+
+#LEDs
+green=Pin(17,Pin.OUT)
+yellow=Pin(14,Pin.OUT)
+red=Pin(15,Pin.OUT)
+
+#start with lights off
+green.off()
+yellow.off()
+red.off()
+
+#2 modes, manual and random
+# TODO set up selector between manual (button op) and random time (randint)
+toggle=Pin(pin,Pin.IN,Pin.PULL_UP)
+
+def measure_tog():
+    tVal=toggle.value()
+    time.sleep(1)
+    return tVal
+if tVal=1:
+    #run automatically, random.randint(?,?), 1 LED color at a time
+    
+if tVal=0:
+    #use button to change LED
+    green.on()
+    yellow.off()
+    red.off()
+
+###CREATE MAIN LOOP###
+""" use toggle to determine which control to give (auto or manual)
+probably check toggle status before running any subroutines, need to check status of this item first,
+and detect fresh changes on Pin as they come in, IRQ
+if auto, use random times to switch between lights, turning on new light, off old light
+if manual, need to read for button presses and use that to move through lights
+need to set up cases, OFF(no LED), RED(red only), YELLOW(yellow only), GREEN(green only)
+"""
+
+while tval=0:
+    red.off()
+    green.on()
+    time.sleep(random.randint(5,60))
+    green.off()
+    yellow.on()
+    time.sleep(random.randint(5,60))
+    yellow.off()
+    red.on()
+    time.sleep(random.randint(5,60))
\ No newline at end of file
diff --git a/us100Demo.py b/us100Demo.py
new file mode 100644 (file)
index 0000000..11f8033
--- /dev/null
@@ -0,0 +1,58 @@
+import machine
+import utime
+import us100
+
+uart = machine.UART(0)
+sensor = us100.US100UART(uart)
+
+distance=0
+
+Ygem=machine.Pin(10,machine.Pin.OUT)
+Bgem=machine.Pin(16,machine.Pin.OUT)
+plant=machine.Pin(18,machine.Pin.OUT)
+
+Ygem.off();Bgem.off();plant.off()
+
+def measure():
+    global distance
+    distance=sensor.distance()
+    return distance
+    
+def analyze():
+    if distance <=500 and distance>=350:
+        Ygem.on()
+        Bgem.off()
+        plant.off()
+        return
+    elif distance <=350 and distance >=150:
+        plant.on()
+        Ygem.off()
+        return
+    elif distance <=150 and distance >75:
+        Bgem.on()
+        plant.off()
+        Ygem.on()
+        return
+    elif distance <=75:
+        Bgem.off()
+        plant.on()
+        Ygem.on()
+        return
+    elif distance >500:
+        Bgem.off()
+        plant.off()
+        Ygem.off()
+        return
+
+while True:
+    try:
+        measure()
+        print(distance)
+        analyze()
+        utime.sleep_ms(50)
+    except Exception: #catches error if sensor is covered, simply passes that cycle
+        print("HEY BOSS, SOMETHING'S WRONG") #show that error happened
+        pass
+"""if KeyboardInterrupt: 
+    pass
+"""
\ No newline at end of file