Skip to content

Commit ac0bf10

Browse files
committed
document going directly to display with ondiskgif
1 parent 965caa0 commit ac0bf10

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

shared-bindings/gifio/OnDiskGif.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
//| class OnDiskGif:
3737
//| """Loads one frame of a GIF into memory at a time.
3838
//|
39+
//| The code can be used in cooperation with displayio but this mode is relatively slow:
40+
//|
3941
//| .. code-block:: Python
4042
//|
4143
//| import board
@@ -69,6 +71,32 @@
6971
//| # minus the overhead measured to advance between frames.
7072
//| time.sleep(max(0, next_delay - overhead))
7173
//| next_delay = odg.next_frame()
74+
//|
75+
//| The displayio Group and TileGrid layers can be bypassed and the image can
76+
//| be directly blitted to the full screen. This can give a speed-up of ~4x to
77+
//| ~6x depending on the GIF and display. This requires an LCD that uses
78+
//| standard codes to set the update area, and which accepts RGB565_SWAPPED
79+
//| pixel data directly:
80+
//|
81+
//| .. code-block:: Python
82+
//| # Initial set-up the same as above
83+
//|
84+
//| # Take over display to drive directly
85+
//| display.auto_refresh = False
86+
//| bus = display.bus
87+
//|
88+
//| # Display repeatedly & directly.
89+
//| while True:
90+
//| # Sleep for the frame delay specified by the GIF,
91+
//| # minus the overhead measured to advance between frames.
92+
//| time.sleep(max(0, next_delay - overhead))
93+
//| next_delay = odg.next_frame()
94+
//|
95+
//| display_bus.send(42, struct.pack(">hh", 0, odg.bitmap.width - 1))
96+
//| display_bus.send(43, struct.pack(">hh", 0, odg.bitmap.height - 1))
97+
//| display_bus.send(44, d.bitmap)
98+
//|
99+
//| d.next_frame()
72100
//| """
73101
//|
74102
//| def __init__(self, file: str) -> None:

0 commit comments

Comments
 (0)