From ac0bf1049a9413fd0d85389fc8297c31c381a3d1 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 1 Mar 2023 17:50:02 -0600 Subject: [PATCH 1/3] document going directly to display with ondiskgif --- shared-bindings/gifio/OnDiskGif.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/shared-bindings/gifio/OnDiskGif.c b/shared-bindings/gifio/OnDiskGif.c index a1eb6051eb..b4a2e04cdb 100644 --- a/shared-bindings/gifio/OnDiskGif.c +++ b/shared-bindings/gifio/OnDiskGif.c @@ -36,6 +36,8 @@ //| class OnDiskGif: //| """Loads one frame of a GIF into memory at a time. //| +//| The code can be used in cooperation with displayio but this mode is relatively slow: +//| //| .. code-block:: Python //| //| import board @@ -69,6 +71,32 @@ //| # minus the overhead measured to advance between frames. //| time.sleep(max(0, next_delay - overhead)) //| next_delay = odg.next_frame() +//| +//| The displayio Group and TileGrid layers can be bypassed and the image can +//| be directly blitted to the full screen. This can give a speed-up of ~4x to +//| ~6x depending on the GIF and display. This requires an LCD that uses +//| standard codes to set the update area, and which accepts RGB565_SWAPPED +//| pixel data directly: +//| +//| .. code-block:: Python +//| # Initial set-up the same as above +//| +//| # Take over display to drive directly +//| display.auto_refresh = False +//| bus = display.bus +//| +//| # Display repeatedly & directly. +//| while True: +//| # Sleep for the frame delay specified by the GIF, +//| # minus the overhead measured to advance between frames. +//| time.sleep(max(0, next_delay - overhead)) +//| next_delay = odg.next_frame() +//| +//| display_bus.send(42, struct.pack(">hh", 0, odg.bitmap.width - 1)) +//| display_bus.send(43, struct.pack(">hh", 0, odg.bitmap.height - 1)) +//| display_bus.send(44, d.bitmap) +//| +//| d.next_frame() //| """ //| //| def __init__(self, file: str) -> None: From 6eae40338cfe2aaf06fcdb4b686eb249f67f7fc8 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 1 Mar 2023 17:56:18 -0600 Subject: [PATCH 2/3] fix problems spotted very quickly by gamblor :) --- shared-bindings/gifio/OnDiskGif.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/shared-bindings/gifio/OnDiskGif.c b/shared-bindings/gifio/OnDiskGif.c index b4a2e04cdb..24412c7cfe 100644 --- a/shared-bindings/gifio/OnDiskGif.c +++ b/shared-bindings/gifio/OnDiskGif.c @@ -83,7 +83,7 @@ //| //| # Take over display to drive directly //| display.auto_refresh = False -//| bus = display.bus +//| display_bus = display.bus //| //| # Display repeatedly & directly. //| while True: @@ -95,8 +95,6 @@ //| display_bus.send(42, struct.pack(">hh", 0, odg.bitmap.width - 1)) //| display_bus.send(43, struct.pack(">hh", 0, odg.bitmap.height - 1)) //| display_bus.send(44, d.bitmap) -//| -//| d.next_frame() //| """ //| //| def __init__(self, file: str) -> None: From 2ac1c7a0205745edd50abcc86467d1171fd5180d Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sat, 4 Mar 2023 11:59:31 -0500 Subject: [PATCH 3/3] Add blank line after code-block --- shared-bindings/gifio/OnDiskGif.c | 1 + 1 file changed, 1 insertion(+) diff --git a/shared-bindings/gifio/OnDiskGif.c b/shared-bindings/gifio/OnDiskGif.c index 24412c7cfe..7fb3fcf2bd 100644 --- a/shared-bindings/gifio/OnDiskGif.c +++ b/shared-bindings/gifio/OnDiskGif.c @@ -79,6 +79,7 @@ //| pixel data directly: //| //| .. code-block:: Python +//| //| # Initial set-up the same as above //| //| # Take over display to drive directly