Skip to content

Commit 38634c5

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents fb3f3a0 + 6e437cd commit 38634c5

File tree

3 files changed

+77
-5
lines changed

3 files changed

+77
-5
lines changed

Matrix_Portal_Moon_Clock/code.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ def next_moon_data(datetime, utc_offset):
172172
DISPLAY = MATRIX.display
173173
ACCEL = adafruit_lis3dh.LIS3DH_I2C(busio.I2C(board.SCL, board.SDA),
174174
address=0x19)
175-
ROTATE = (int(((math.atan2(-ACCEL.acceleration.y, -ACCEL.acceleration.x) +
176-
math.pi) / (math.pi * 2) - 0.125) * 4) % 4) * 90
177-
DISPLAY.rotation = ROTATE
175+
DISPLAY.rotation = (int(((math.atan2(-ACCEL.acceleration.y,
176+
-ACCEL.acceleration.x) + math.pi) /
177+
(math.pi * 2) + 0.875) * 4) % 4) * 90
178178

179179
LARGE_FONT = bitmap_font.load_font('/fonts/helvB12.bdf')
180180
SMALL_FONT = bitmap_font.load_font('/fonts/helvR10.bdf')
@@ -189,7 +189,7 @@ def next_moon_data(datetime, utc_offset):
189189
# Element 0 is a stand-in item, later replaced with the moon phase bitmap
190190
# pylint: disable=bare-except
191191
try:
192-
FILENAME = 'moon/splash-' + str(ROTATE) + '.bmp'
192+
FILENAME = 'moon/splash-' + str(DISPLAY.rotation) + '.bmp'
193193
BITMAP = displayio.OnDiskBitmap(open(FILENAME, 'rb'))
194194
TILE_GRID = displayio.TileGrid(BITMAP,
195195
pixel_shader=displayio.ColorConverter(),)
@@ -339,7 +339,7 @@ def next_moon_data(datetime, utc_offset):
339339
else:
340340
NEXT_EVENT = NEXT_PERIOD.set
341341

342-
if ROTATE in (0, 180): # Horizontal 'landscape' orientation
342+
if DISPLAY.rotation in (0, 180): # Horizontal 'landscape' orientation
343343
CENTER_X = 48 # Text along right
344344
MOON_Y = 0 # Moon at left
345345
TIME_Y = 6 # Time at top right

RBG_Matrix/code.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# This example shows how to use text and graphics to create custom signage
2+
3+
import time
4+
import adafruit_display_text.label
5+
import board
6+
import displayio
7+
import framebufferio
8+
import rgbmatrix
9+
import terminalio
10+
11+
# If there was a display before (protomatter, LCD, or E-paper), release it so
12+
# we can create ours
13+
displayio.release_displays()
14+
15+
matrix = rgbmatrix.RGBMatrix(
16+
width=64, bit_depth=4,
17+
rgb_pins=[board.MTX_R1, board.MTX_G1, board.MTX_B1, board.MTX_R2, board.MTX_G2, board.MTX_B2],
18+
addr_pins=[board.MTX_ADDRA, board.MTX_ADDRB, board.MTX_ADDRC, board.MTX_ADDRD],
19+
clock_pin=board.MTX_CLK, latch_pin=board.MTX_LAT, output_enable_pin=board.MTX_OE)
20+
21+
# Associate the RGB matrix with a Display so that we can use displayio features
22+
display = framebufferio.FramebufferDisplay(matrix, auto_refresh=False)
23+
display.rotation = 180
24+
25+
R = adafruit_display_text.label.Label(
26+
terminalio.FONT,
27+
color=0xff0000,
28+
scale=3, x=2, y=13,
29+
text="R")
30+
B = adafruit_display_text.label.Label(
31+
terminalio.FONT,
32+
color=0x0000ff,
33+
scale=3, x=24, y=13,
34+
text="B")
35+
G = adafruit_display_text.label.Label(
36+
terminalio.FONT,
37+
color=0x00ff00,
38+
scale=3, x=46, y=13,
39+
text="G")
40+
41+
# Put each line of text into a Group, then show that group.
42+
g = displayio.Group()
43+
g.append(R)
44+
g.append(B)
45+
g.append(G)
46+
display.show(g)
47+
display.auto_refresh = True
48+
49+
bitmap_file = open("/rbg.bmp", "rb")
50+
# Setup the file as the bitmap data source
51+
bitmap = displayio.OnDiskBitmap(bitmap_file)
52+
# Create a TileGrid to hold the bitmap
53+
tile_grid = displayio.TileGrid(bitmap, pixel_shader=displayio.ColorConverter())
54+
print(dir(tile_grid))
55+
56+
while True:
57+
while g:
58+
g.pop()
59+
60+
g.append(tile_grid)
61+
for y in range(bitmap.height+32):
62+
tile_grid.y = 32-y
63+
time.sleep(0.05)
64+
65+
g.pop()
66+
67+
g.append(R)
68+
time.sleep(1)
69+
g.append(B)
70+
time.sleep(1)
71+
g.append(G)
72+
time.sleep(1)

RBG_Matrix/rbg.bmp

20.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)