From 13e42db094daf409386b1cbc5526180abd87bb8d Mon Sep 17 00:00:00 2001 From: James Carr Date: Tue, 13 Jul 2021 10:19:26 +0100 Subject: [PATCH 1/2] Update the pixel_shader usage of OnDiskBitmap --- examples/gizmo_eink_simpletest.py | 7 ++++++- examples/gizmo_tft_thermometer.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/examples/gizmo_eink_simpletest.py b/examples/gizmo_eink_simpletest.py index 3392c64..0645c66 100644 --- a/examples/gizmo_eink_simpletest.py +++ b/examples/gizmo_eink_simpletest.py @@ -16,7 +16,12 @@ with open("/display-ruler.bmp", "rb") as file: picture = displayio.OnDiskBitmap(file) # Create a Tilegrid with the bitmap and put in the displayio group - sprite = displayio.TileGrid(picture, pixel_shader=displayio.ColorConverter()) + sprite = displayio.TileGrid( + picture, + pixel_shader=getattr(picture, "pixel_shader", displayio.ColorConverter()), + # TODO: Once CP6 is no longer supported, replace the above line with below + # pixel_shader=picture.pixel_shader, + ) display_group.append(sprite) # Place the display group on the screen diff --git a/examples/gizmo_tft_thermometer.py b/examples/gizmo_tft_thermometer.py index 7cc4fb5..1bb4b4c 100644 --- a/examples/gizmo_tft_thermometer.py +++ b/examples/gizmo_tft_thermometer.py @@ -44,7 +44,12 @@ def c_to_f(c_val): bitmap = displayio.OnDiskBitmap(bitmap_file) # Create a TileGrid to hold the bitmap - tile_grid = displayio.TileGrid(bitmap, pixel_shader=displayio.ColorConverter()) + tile_grid = displayio.TileGrid( + bitmap, + pixel_shader=getattr(bitmap, "pixel_shader", displayio.ColorConverter()), + # TODO: Once CP6 is no longer supported, replace the above line with below + # pixel_shader=bitmap.pixel_shader, + ) # Create a Group to hold the TileGrid group = displayio.Group() From ebd4118e42600966dc68050fe02943f116bc440e Mon Sep 17 00:00:00 2001 From: James Carr Date: Tue, 13 Jul 2021 11:15:44 +0100 Subject: [PATCH 2/2] Rewrite the changes as this is example code. --- examples/gizmo_eink_simpletest.py | 5 +++-- examples/gizmo_tft_thermometer.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/gizmo_eink_simpletest.py b/examples/gizmo_eink_simpletest.py index 0645c66..040e870 100644 --- a/examples/gizmo_eink_simpletest.py +++ b/examples/gizmo_eink_simpletest.py @@ -16,12 +16,13 @@ with open("/display-ruler.bmp", "rb") as file: picture = displayio.OnDiskBitmap(file) # Create a Tilegrid with the bitmap and put in the displayio group + # CircuitPython 6 & 7 compatible sprite = displayio.TileGrid( picture, pixel_shader=getattr(picture, "pixel_shader", displayio.ColorConverter()), - # TODO: Once CP6 is no longer supported, replace the above line with below - # pixel_shader=picture.pixel_shader, ) + # CircuitPython 7 compatible only + # sprite = displayio.TileGrid(picture, pixel_shader=bitmap.pixel_shader) display_group.append(sprite) # Place the display group on the screen diff --git a/examples/gizmo_tft_thermometer.py b/examples/gizmo_tft_thermometer.py index 1bb4b4c..bfccc2b 100644 --- a/examples/gizmo_tft_thermometer.py +++ b/examples/gizmo_tft_thermometer.py @@ -44,12 +44,13 @@ def c_to_f(c_val): bitmap = displayio.OnDiskBitmap(bitmap_file) # Create a TileGrid to hold the bitmap + # CircuitPython 6 & 7 compatible tile_grid = displayio.TileGrid( bitmap, pixel_shader=getattr(bitmap, "pixel_shader", displayio.ColorConverter()), - # TODO: Once CP6 is no longer supported, replace the above line with below - # pixel_shader=bitmap.pixel_shader, ) + # CircuitPython 7 compatible only + # tile_grid = displayio.TileGrid(bitmap, pixel_shader=bitmap.pixel_shader) # Create a Group to hold the TileGrid group = displayio.Group()