Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document going directly to display with ondiskgif #7668

Merged
merged 3 commits into from
Mar 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions shared-bindings/gifio/OnDiskGif.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -69,6 +71,31 @@
//| # 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
//| display_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)
//| """
//|
//| def __init__(self, file: str) -> None:
Expand Down