Skip to content

Commit 23f80ff

Browse files
committed
2 parents 5b42670 + 4f8337c commit 23f80ff

34 files changed

+99245
-2
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import time
2+
import board
3+
import digitalio
4+
5+
relay = digitalio.DigitalInOut(board.A1)
6+
relay.direction = digitalio.Direction.OUTPUT
7+
8+
while True:
9+
relay.value = True
10+
time.sleep(1)
11+
relay.value = False
12+
time.sleep(1)

CircuitPython_Scrolling_Clouds/code.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ def slide_tiles():
105105
"""Move the tilegrid to the left, one pixel at a time, a full time width"""
106106
for _ in range(16):
107107
tilegrid.x -= 1
108-
display.refresh_soon()
109-
display.wait_for_frame()
110108

111109
def shift_tiles():
112110
"""Move tiles one spot to the left, and reset the tilegrid's position"""
Binary file not shown.

Circuit_Playground_Bluefruit_Pumpkin/CAD/CP_Bluefruit_Pumpkin.step

Lines changed: 97826 additions & 0 deletions
Large diffs are not rendered by default.
104 KB
Binary file not shown.
116 KB
Binary file not shown.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Code written by Prof. John Gallaugher, modified by Noe Ruiz for Adafruit Industries
2+
# Adafruit Circuit Playground Express Bluefruit
3+
4+
import time
5+
import board
6+
import neopixel
7+
from adafruit_ble.uart_server import UARTServer
8+
from audiopwmio import PWMAudioOut as AudioOut
9+
from audiocore import WaveFile
10+
11+
from adafruit_bluefruit_connect.packet import Packet
12+
from adafruit_bluefruit_connect.color_packet import ColorPacket
13+
from adafruit_bluefruit_connect.button_packet import ButtonPacket
14+
15+
# setup pixels
16+
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=1, auto_write=True)
17+
18+
# name colors so you don't need to refer to numbers
19+
RED = (255, 0, 0)
20+
ORANGE = (255, 50, 0)
21+
BLACK = (0, 0, 0)
22+
GREEN = (0, 255, 0)
23+
PURPLE = (100, 0, 255)
24+
YELLOW = (255,230, 0)
25+
BLUE = (0, 0, 255)
26+
# setup bluetooth
27+
uart_server = UARTServer()
28+
29+
# External Audio Stuff
30+
audio = AudioOut(board.SPEAKER) # Speaker
31+
wave_file = None
32+
33+
def play_wav(name, loop=False):
34+
"""
35+
Play a WAV file in the 'sounds' directory.
36+
:param name: partial file name string, complete name will be built around
37+
this, e.g. passing 'foo' will play file 'sounds/foo.wav'.
38+
:param loop: if True, sound will repeat indefinitely (until interrupted
39+
by another sound).
40+
"""
41+
global wave_file # pylint: disable=global-statement
42+
print("playing", name)
43+
if wave_file:
44+
wave_file.close()
45+
try:
46+
wave_file = open('sounds/' + name + '.wav', 'rb') # using wave files from sounds folder
47+
wave = WaveFile(wave_file)
48+
audio.play(wave, loop=loop)
49+
except OSError:
50+
pass # we'll just skip playing then
51+
52+
while True:
53+
# set CPXb up so that it can be discovered by the app
54+
uart_server.start_advertising()
55+
while not uart_server.connected:
56+
pass
57+
58+
# Now we're connected
59+
60+
while uart_server.connected:
61+
62+
if uart_server.in_waiting:
63+
try:
64+
packet = Packet.from_stream(uart_server)
65+
except ValueError:
66+
continue # or pass.
67+
68+
if isinstance(packet, ColorPacket): # check if a color was sent from color picker
69+
pixels.fill(packet.color)
70+
if isinstance(packet, ButtonPacket): # check if a button was pressed from control pad
71+
if packet.pressed:
72+
if packet.button == ButtonPacket.BUTTON_1: # if button #1
73+
pixels.fill(BLUE)
74+
play_wav("bluefruit")
75+
time.sleep(3)
76+
pixels.fill(BLACK)
77+
if packet.button == ButtonPacket.BUTTON_2: # if button #2
78+
pixels.fill(ORANGE)
79+
play_wav("halloween")
80+
time.sleep(3)
81+
pixels.fill(BLACK)
82+
if packet.button == ButtonPacket.BUTTON_3: # if button #2
83+
pixels.fill(PURPLE)
84+
play_wav("muhaha")
85+
time.sleep(2)
86+
pixels.fill(BLACK)
87+
if packet.button == ButtonPacket.BUTTON_4: # if button #2
88+
pixels.fill(GREEN)
89+
play_wav("neopixels")
90+
time.sleep(3)
91+
pixels.fill(BLACK)
92+
if packet.button == ButtonPacket.UP: # if button #2
93+
pixels.fill(YELLOW)
94+
play_wav("organic")
95+
time.sleep(2.6)
96+
pixels.fill(BLACK)
97+
if packet.button == ButtonPacket.DOWN: # if button #2
98+
pixels.fill(PURPLE)
99+
play_wav("python")
100+
time.sleep(2)
101+
pixels.fill(BLACK)
102+
if packet.button == ButtonPacket.LEFT: # if button #2
103+
pixels.fill(GREEN)
104+
play_wav("smell")
105+
time.sleep(2.5)
106+
pixels.fill(BLACK)
107+
if packet.button == ButtonPacket.RIGHT: # if button #2
108+
pixels.fill(ORANGE)
109+
play_wav("who")
110+
time.sleep(2)
111+
pixels.fill(BLACK)
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
"""
2+
Simple badge script for Adafruit 2.13" 212x104 tri-color display
3+
Supported products:
4+
* Adafruit 2.13" Tri-Color Display Breakout
5+
* https://www.adafruit.com/product/4086 (breakout) or
6+
* https://www.adafruit.com/product/4128 (FeatherWing)
7+
8+
This program requires the adafruit_il0373 library and the
9+
adafruit_display_text library in the CIRCUITPY /lib folder
10+
for CircuitPython 5.0 and above which has displayio support.
11+
"""
12+
13+
import time
14+
import board
15+
import displayio
16+
import adafruit_il0373
17+
import terminalio
18+
from adafruit_display_text import label
19+
20+
BLACK = 0x000000
21+
WHITE = 0xFFFFFF
22+
RED = 0xFF0000
23+
24+
# Change text colors, choose from the following values:
25+
# BLACK, RED, WHITE
26+
27+
TEXT_COLOR = BLACK
28+
BACKGROUND_COLOR = WHITE
29+
30+
# Used to ensure the display is free in CircuitPython
31+
displayio.release_displays()
32+
33+
# Define the pins needed for display use
34+
# This pinout is for a Feather M4 and may be different for other boards
35+
spi = board.SPI() # Uses SCK and MOSI
36+
epd_cs = board.D9
37+
epd_dc = board.D10
38+
epd_reset = board.D5
39+
epd_busy = board.D6
40+
41+
# Create the displayio connection to the display pins
42+
display_bus = displayio.FourWire(spi, command=epd_dc, chip_select=epd_cs,
43+
reset=epd_reset, baudrate=1000000)
44+
time.sleep(1) # Wait a bit
45+
46+
DISPLAY_WIDTH = 212
47+
DISPLAY_HEIGHT = 104
48+
# Create the display object - the third color is red (0xff0000)
49+
display = adafruit_il0373.IL0373(display_bus, width=DISPLAY_WIDTH,
50+
height=DISPLAY_HEIGHT,
51+
rotation=90, busy_pin=epd_busy,
52+
highlight_color=0xff0000)
53+
54+
# Create a display group for our screen objects
55+
g = displayio.Group()
56+
57+
# Set a background
58+
background_bitmap = displayio.Bitmap(DISPLAY_WIDTH, DISPLAY_HEIGHT, 1)
59+
# Map colors in a palette
60+
palette = displayio.Palette(1)
61+
palette[0] = BACKGROUND_COLOR
62+
63+
# Put the background into the display group
64+
bg_sprite = displayio.TileGrid(background_bitmap,
65+
pixel_shader=palette,
66+
x=0, y=0)
67+
g.append(bg_sprite)
68+
69+
# Display a picture from the root directory of the CIRCUITPY drive
70+
# Picture should be HEIGHTxHEIGHT square idealy for a portrait
71+
# But could be the entire WIDTHxHEIGHT for a non-portrait
72+
f = open("/picture.bmp", "rb")
73+
74+
pic = displayio.OnDiskBitmap(f)
75+
# Create a Tilegrid with the bitmap and put in the displayio group
76+
t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter())
77+
g.append(t)
78+
79+
# Draw simple text using the built-in font into a displayio group
80+
# For smaller text, change scale=2 to scale=1
81+
text_group = displayio.Group(max_size=10, scale=2,
82+
x=DISPLAY_HEIGHT + 10,
83+
y=int(DISPLAY_HEIGHT/2) - 13)
84+
first_name = "Limor"
85+
text_area = label.Label(terminalio.FONT, text=first_name,
86+
color=TEXT_COLOR)
87+
text_group.append(text_area) # Add this text to the text group
88+
g.append(text_group)
89+
90+
# Draw simple text using the built-in font into a displayio group
91+
text_group = displayio.Group(max_size=10, scale=2,
92+
x=DISPLAY_HEIGHT + 10,
93+
y=int(DISPLAY_HEIGHT/2) + 13)
94+
last_name = "Ladyada"
95+
text_area = label.Label(terminalio.FONT, text=last_name,
96+
color=TEXT_COLOR)
97+
text_group.append(text_area) # Add this text to the text group
98+
g.append(text_group)
99+
100+
# Place the display group on the screen
101+
display.show(g)
102+
103+
# Refresh the display to have it actually show
104+
# NOTE: Do not refresh eInk displays more often than 180 seconds!
105+
display.refresh()
106+
107+
# Wait the minimum 3 minutes between refreshes. Then loop to freeze.
108+
time.sleep(180)
109+
while True:
110+
pass
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
"""
2+
Simple text script for Adafruit 2.13" 212x104 tri-color display
3+
Supported products:
4+
* Adafruit 2.13" Tri-Color Display Breakout
5+
* Adafruit 2.13" Tri-Color Display FeatherWing
6+
https://www.adafruit.com/product/4086 (breakout) or
7+
https://www.adafruit.com/product/4128 (FeatherWing)
8+
9+
This program requires the adafruit_il0373 library and the
10+
adafruit_display_text library in the CIRCUITPY /lib folder
11+
for CircuitPython 5.0 and above which has displayio support.
12+
"""
13+
14+
import time
15+
import board
16+
import displayio
17+
import adafruit_il0373
18+
import terminalio
19+
from adafruit_display_text import label
20+
21+
BLACK = 0x000000
22+
WHITE = 0xFFFFFF
23+
RED = 0xFF0000
24+
25+
# Change text colors, choose from the following values:
26+
# BLACK, RED, WHITE
27+
28+
FOREGROUND_COLOR = RED
29+
BACKGROUND_COLOR = WHITE
30+
31+
# Used to ensure the display is free in CircuitPython
32+
displayio.release_displays()
33+
34+
# Define the pins needed for display use
35+
# This pinout is for a Feather M4 and may be different for other boards
36+
spi = board.SPI() # Uses SCK and MOSI
37+
epd_cs = board.D9
38+
epd_dc = board.D10
39+
epd_reset = board.D5
40+
epd_busy = board.D6
41+
42+
# Create the displayio connection to the display pins
43+
display_bus = displayio.FourWire(spi, command=epd_dc, chip_select=epd_cs,
44+
reset=epd_reset, baudrate=1000000)
45+
time.sleep(1) # Wait a bit
46+
47+
# Create the display object - the third color is red (0xff0000)
48+
DISPLAY_WIDTH = 212
49+
DISPLAY_HEIGHT = 104
50+
51+
display = adafruit_il0373.IL0373(display_bus, width=DISPLAY_WIDTH,
52+
height=DISPLAY_HEIGHT,
53+
rotation=90, busy_pin=epd_busy,
54+
highlight_color=0xff0000)
55+
56+
# Create a display group for our screen objects
57+
g = displayio.Group(max_size=10)
58+
59+
# Set a background
60+
background_bitmap = displayio.Bitmap(DISPLAY_WIDTH, DISPLAY_HEIGHT, 1)
61+
# Map colors in a palette
62+
palette = displayio.Palette(1)
63+
palette[0] = BACKGROUND_COLOR
64+
65+
# Create a Tilegrid with the background and put in the displayio group
66+
t = displayio.TileGrid(background_bitmap, pixel_shader=palette)
67+
g.append(t)
68+
69+
# Draw simple text using the built-in font into a displayio group
70+
text_group = displayio.Group(max_size=10, scale=2, x=20, y=40)
71+
text = "Hello World!"
72+
text_area = label.Label(terminalio.FONT, text=text, color=FOREGROUND_COLOR)
73+
text_group.append(text_area) # Add this text to the text group
74+
g.append(text_group)
75+
76+
# Place the display group on the screen
77+
display.show(g)
78+
79+
# Refresh the display to have everything show on the display
80+
# NOTE: Do not refresh eInk displays more often than 180 seconds!
81+
display.refresh()
82+
83+
time.sleep(120)
84+
85+
while True:
86+
pass

0 commit comments

Comments
 (0)