Skip to content

Commit dd04d13

Browse files
authored
Merge pull request #1685 from lesamouraipourpre/moon-clock
Matrix Portal Moon Clock: Update for CP7
2 parents ca258c3 + c907348 commit dd04d13

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

Matrix_Portal_Moon_Clock/code.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,20 +191,31 @@ def __init__(self, datetime, hours_ahead, utc_offset):
191191

192192
# Display group is set up once, then we just shuffle items around later.
193193
# Order of creation here determines their stacking order.
194-
GROUP = displayio.Group(max_size=10)
194+
GROUP = displayio.Group()
195+
195196
# Element 0 is a stand-in item, later replaced with the moon phase bitmap
196197
# pylint: disable=bare-except
197198
try:
198199
FILENAME = 'moon/splash-' + str(DISPLAY.rotation) + '.bmp'
200+
201+
# CircuitPython 6 & 7 compatible
199202
BITMAP = displayio.OnDiskBitmap(open(FILENAME, 'rb'))
200-
TILE_GRID = displayio.TileGrid(BITMAP,
201-
pixel_shader=getattr(BITMAP, 'pixel_shader', displayio.ColorConverter()),)
203+
TILE_GRID = displayio.TileGrid(
204+
BITMAP,
205+
pixel_shader=getattr(BITMAP, 'pixel_shader', displayio.ColorConverter())
206+
)
207+
208+
# # CircuitPython 7+ compatible
209+
# BITMAP = displayio.OnDiskBitmap(FILENAME)
210+
# TILE_GRID = displayio.TileGrid(BITMAP, pixel_shader=BITMAP.pixel_shader)
211+
202212
GROUP.append(TILE_GRID)
203213
except:
204214
GROUP.append(adafruit_display_text.label.Label(SMALL_FONT, color=0xFF0000,
205215
text='AWOO'))
206216
GROUP[0].x = (DISPLAY.width - GROUP[0].bounding_box[2] + 1) // 2
207217
GROUP[0].y = DISPLAY.height // 2 - 1
218+
208219
# Elements 1-4 are an outline around the moon percentage -- text labels
209220
# offset by 1 pixel up/down/left/right. Initial position is off the matrix,
210221
# updated on first refresh. Initial text value must be long enough for
@@ -363,9 +374,18 @@ def __init__(self, datetime, hours_ahead, utc_offset):
363374

364375
# Update moon image (GROUP[0])
365376
FILENAME = 'moon/moon' + '{0:0>2}'.format(FRAME) + '.bmp'
377+
378+
# CircuitPython 6 & 7 compatible
366379
BITMAP = displayio.OnDiskBitmap(open(FILENAME, 'rb'))
367-
TILE_GRID = displayio.TileGrid(BITMAP,
368-
pixel_shader=getattr(BITMAP, 'pixel_shader', displayio.ColorConverter()),)
380+
TILE_GRID = displayio.TileGrid(
381+
BITMAP,
382+
pixel_shader=getattr(BITMAP, 'pixel_shader', displayio.ColorConverter())
383+
)
384+
385+
# # CircuitPython 7+ compatible
386+
# BITMAP = displayio.OnDiskBitmap(FILENAME)
387+
# TILE_GRID = displayio.TileGrid(BITMAP, pixel_shader=BITMAP.pixel_shader)
388+
369389
TILE_GRID.x = 0
370390
TILE_GRID.y = MOON_Y
371391
GROUP[0] = TILE_GRID

0 commit comments

Comments
 (0)