From 0ebf78dd042dffad80763f16e7e7ebdcddf97c26 Mon Sep 17 00:00:00 2001 From: James Carr Date: Sat, 7 Aug 2021 21:44:45 +0100 Subject: [PATCH 1/2] Update OnDiskBitmap code to take a filename string with CP7 Replace displayio.Sprite with displayio.TileGrid Replace board.D13 with board.LED --- .../hallowing_jump_scare_trap.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/HalloWing_Jump_Scare_Trap/hallowing_jump_scare_trap.py b/HalloWing_Jump_Scare_Trap/hallowing_jump_scare_trap.py index d2e3220d9..9e989e6c4 100644 --- a/HalloWing_Jump_Scare_Trap/hallowing_jump_scare_trap.py +++ b/HalloWing_Jump_Scare_Trap/hallowing_jump_scare_trap.py @@ -12,7 +12,7 @@ import audioio import audiocore # Setup LED and PIR pins -LED_PIN = board.D13 # Pin number for the board's built in LED. +LED_PIN = board.LED # Pin number for the board's built in LED. PIR_PIN = board.SENSE # Pin port connected to PIR sensor output wire. # Setup digital input for PIR sensor: pir = digitalio.DigitalInOut(PIR_PIN) @@ -94,9 +94,18 @@ def blink(count, speed): "trap_set.bmp"] # Function for displaying images on HalloWing TFT screen def show_image(filename): + # CircuitPython 6 & 7 compatible image_file = open(filename, "rb") odb = displayio.OnDiskBitmap(image_file) - face = displayio.Sprite(odb, pixel_shader=displayio.ColorConverter(), position=(0, 0)) + face = displayio.TileGrid( + odb, + pixel_shader=getattr(odb, 'pixel_shader', displayio.ColorConverter()) + ) + + # # CircuitPython 7+ compatible + # odb = displayio.OnDiskBitmap(filename) + # face = displayio.TileGrid(odb, pixel_shader=odb.pixel_shader) + backlight.duty_cycle = 0 splash.append(face) # Wait for the image to load. From ca06d3c6259e2ac58a197b7d36d7b01eadb41393 Mon Sep 17 00:00:00 2001 From: James Carr Date: Sat, 7 Aug 2021 23:57:20 +0100 Subject: [PATCH 2/2] Remove out-of-date DISPLAY.wait_for_frame() --- HalloWing_Jump_Scare_Trap/hallowing_jump_scare_trap.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/HalloWing_Jump_Scare_Trap/hallowing_jump_scare_trap.py b/HalloWing_Jump_Scare_Trap/hallowing_jump_scare_trap.py index 9e989e6c4..07214ca9b 100644 --- a/HalloWing_Jump_Scare_Trap/hallowing_jump_scare_trap.py +++ b/HalloWing_Jump_Scare_Trap/hallowing_jump_scare_trap.py @@ -108,11 +108,7 @@ def show_image(filename): backlight.duty_cycle = 0 splash.append(face) - # Wait for the image to load. - try: - board.DISPLAY.refresh(target_frames_per_second=60) - except AttributeError: - board.DISPLAY.wait_for_frame() + board.DISPLAY.refresh(target_frames_per_second=60) backlight.duty_cycle = max_brightness beep(1) # startup beep