This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```# text-and-displayio.py | |
import board, busio, time, displayio, pwmio, terminalio, fourwire | |
from adafruit_display_text.label import Label | |
from adafruit_display_text.bitmap_label import Label as BitmapLabel | |
from adafruit_bitmap_font import bitmap_font | |
import adafruit_ili9341 | |
# --- Display Setup --- | |
displayio.release_displays() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# roy-g-biv-pico-flash-with-each-color-off.py | |
import board, time, neopixel | |
# define colors: | |
RED = (255, 0, 0) | |
ORANGE = (255, 40, 0) | |
YELLOW = (255, 150, 0) | |
GREEN = (0, 255, 0) | |
BLUE = (0, 0, 255) | |
INDIGO = (75, 0, 130) # no official INDIGO from CircuitPython |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func playSound(soundName: String) { | |
guard let soundFile = NSDataAsset(name: soundName) else { | |
print("😡 ERROR: Could not read file named \(soundName).") | |
return | |
} | |
do { | |
audioPlayer = try AVAudioPlayer(data: soundFile.data) | |
audioPlayer.play() | |
} catch { | |
print("😡 ERROR: \(error.localizedDescription) when trying to create audioPlayer.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# EYESPI & ssd1681 connected to a Pico | |
import time, board, displayio, adafruit_ssd1681 | |
from displayio import FourWire # ← FIXED: Changed from "fourwire import FourWire" | |
displayio.release_displays() | |
# This pinout works on a Feather M4 and may need to be altered for other boards. | |
spi = board.SPI() # Uses SCK and MOSI | |
epd_cs = board.GP17 | |
epd_dc = board.GP21 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Creates a pusing set of rings under text. | |
import time | |
import math | |
import board | |
import displayio | |
import busdisplay | |
import i2cdisplaybus | |
import terminalio | |
from adafruit_display_text import label | |
import adafruit_ssd1327 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you comment out either the audio block or display block, code runs fine. | |
# But if you try to run both, as is shown below, the error is: | |
# File "code.py", line 57, in <module> | |
# ValueError: SPI peripheral in use | |
import board, busio, sdcardio, storage, os, time, digitalio | |
import displayio, pwmio, terminalio, adafruit_st7735r | |
from adafruit_display_text import label | |
from audiomp3 import MP3Decoder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# st7735r_display_160x128.py | |
import board | |
import displayio | |
import busio | |
import pwmio | |
import terminalio | |
from adafruit_display_text import label | |
import adafruit_st7735r | |
displayio.release_displays() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import board, busio, sdcardio, storage, os, time, digitalio | |
from audiomp3 import MP3Decoder | |
try: | |
from audioio import AudioOut | |
except ImportError: | |
try: | |
from audiopwmio import PWMAudioOut as AudioOut | |
except ImportError: | |
print("This board does not support audio") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import board | |
import busio | |
import sdcardio | |
import storage | |
import os | |
import time, digitalio | |
from audiomp3 import MP3Decoder | |
# st7735r_display_160x128.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sasa-chairs | |
# Note: This was demo code set up to show students how the debounced button press doesn't register until | |
# after the song plays. However for some reason I notice when run on a CPB using CircuitPython 9.2.4 | |
# that the song runs a second time, even after the update() has run, the button_B is pressed, and | |
# button_A: False, button_B: False prints <- not expected because my finger remains on button_B. | |
# Here is some sample output. I'm seeing that even after False / False, the sound play restarts & am unsure why. | |
# If I continue holding button_B through one more play, the sound stops, as expected, and button_B.value is True | |
# but I had expected this to occur earlier when I held B through the first complete sound play. | |
# If you'd like to test with my sound, it's in the sasa-chairs folder at: | |
# http://bit.ly/circuitpython-school-files |
NewerOlder