-
Notifications
You must be signed in to change notification settings - Fork 2
/
code.py
157 lines (124 loc) · 4.98 KB
/
code.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# SPDX-FileCopyrightText: 2020 Jeff Epler for Adafruit Industries
#
# SPDX-License-Identifier: MIT
# This example implements a simple two line scroller using
# Adafruit_CircuitPython_Display_Text. Each line has its own color
# and it is possible to modify the example to use other fonts and non-standard
# characters.
import adafruit_display_text.label
import board
import displayio
import framebufferio
import rgbmatrix
import terminalio
from adafruit_bitmap_font import bitmap_font
from adafruit_display_text import label
from time import sleep
from rainbowio import colorwheel
# If there was a display before (protomatter, LCD, or E-paper), release it so
# we can create ours
displayio.release_displays()
# This next call creates the RGB Matrix object itself. It has the given width
# and height. bit_depth can range from 1 to 6; higher numbers allow more color
# shades to be displayed, but increase memory usage and slow down your Python
# code. If you just want to show primary colors plus black and white, use 1.
# Otherwise, try 3, 4 and 5 to see which effect you like best.
#
# These lines are for the Feather M4 Express. If you're using a different board,
# check the guide to find the pins and wiring diagrams for your board.
# If you have a matrix with a different width or height, change that too.
# If you have a 16x32 display, try with just a single line of text.
matrix = rgbmatrix.RGBMatrix(
width=64, height=32, bit_depth=1,
rgb_pins=[board.D6, board.A5, board.A1, board.A0, board.A4, board.D11],
addr_pins=[board.D10, board.D5, board.D13, board.D9],
clock_pin=board.D12, latch_pin=board.RX, output_enable_pin=board.TX)
# Associate the RGB matrix with a Display so that we can use displayio features
display = framebufferio.FramebufferDisplay(matrix, auto_refresh=False)
# Put each line of text into a Group, then show that group.
f = displayio.Group()
display.show(f)
bitWidth = 64
bitLength = 32
bitmap1 = displayio.Bitmap(bitWidth, bitLength, 6)
"""cornerLength = 2
c = 0
#Working Corner stuff (only for corner length 2) Only use if the left and right borders are also being used
#Might have to fix top and bottom border (borderLength) logic if using this
while c<cornerLength:
bitmap1[0, c] = (c%cornerLength)+1
bitmap1[1, c] = (c%cornerLength+1)+1
bitmap1[0, bitLength - cornerLength + c] = (c%cornerLength)+1
bitmap1[1, bitLength - cornerLength + c] = (c%cornerLength+1)+1
bitmap1[bitWidth-2, c] = (c%cornerLength)+1
bitmap1[bitWidth-1, c] = (c%cornerLength+1)+1
bitmap1[bitWidth-2, bitLength - cornerLength + c] = (c%cornerLength)+1
bitmap1[bitWidth-1, bitLength - cornerLength + c] = (c%cornerLength+1)+1
c=c+1
#testing better corner logic
while c<cornerLength:
bitmap1[c, c] = (c%cornerLength)
c=c+1"""
# Working border
i = 0
while i < bitWidth:
bitmap1[i, 0] = (i % 4)+1
bitmap1[i, 1] = (i % 4)+1
bitmap1[i, 31] = (i % 4)+1
bitmap1[i, 30] = (i % 4)+1
i = i+1
h = 0
"""while h<bitLength-4:
bitmap1[0, h+2] = (h%2)+1
bitmap1[1, h+2] = (h%2)+1
bitmap1[63, h+2] = (h%2)+2
bitmap1[62, h+2] = (h%2)+2
h=h+1"""
palette1 = displayio.Palette(color_count=7)
palette1[0] = 0x000000 # black
palette1[1] = 0xFFFF00 # yellow
palette1[2] = 0xFFFF00 # yellow again
palette1[3] = 0x326fa8 # blue
palette1[4] = 0x326fa8 # blue
palette1[5] = 0xFFFF00 # yellow again
palette1[6] = 0xFFFF00 # yellow again
tilegrid1 = displayio.TileGrid(
bitmap=bitmap1, pixel_shader=palette1, width=64, height=32, default_tile=0)
line1 = adafruit_display_text.label.Label(
font=terminalio.FONT,
color=0x0066FF,
text="6328 Mechanical Advantage Littleton Robotics")
line1.x = display.width
line1.y = 7
line2 = adafruit_display_text.label.Label(
font=terminalio.FONT,
color=0xFBFF00,
text="Patriot Beverages, MA Dept of Elementary and Secondary Education, Rep. Jim Arciero/Sen. Jamie Eldridge, Bruce & Sue Bonner, Deployed Resources, MITRE, Symbotic, Gene Haas Foundation, UMass Lowell Research Institute, Amazon, Raytheon, ZOLL Medical, Boston Scientific, TE Connectivity, Formlabs, Workers Credit Union, Tuck & Tuck Architects, Earle Industries, Brian & Trina Miller, EMD Millipore, ETM Manufacturing, PTC/OnShape, Tari Radin")
line2.x = display.width
line2.y = 22
f.append(tilegrid1)
f.append(line1)
f.append(line2)
def scroll(line):
line.x = line.x - 1
line_width = line.bounding_box[2]
if line.x < -line_width:
line.x = display.width
def PaletteSwap(palette):
oldPalette1 = palette[1]
# oldPalette2 = palette[2]
# oldPalette3 = palette[3]
# oldPalette4 = palette[4]
# palette[1] = oldPalette3
# palette[2] = oldPalette4
# palette[3] = oldPalette1
# palette[4] = oldPalette2
# display.refresh()
# You can add more effects in this loop. For instance, maybe you want to set the
# color of each label to a different value.
while True:
PaletteSwap(palette1)
scroll(line1)
scroll(line2)
sleep(0.0001)
display.refresh(minimum_frames_per_second=32) # Write your code here :-)