E5E3 Merge pull request #7668 from jepler/gifio-directio-example · tannewt/circuitpython@0ca6cc7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0ca6cc7

Browse files
authored
Merge pull request micropython#7668 from jepler/gifio-directio-example
document going directly to display with ondiskgif
2 parents 4e169bb + 2ac1c7a commit 0ca6cc7

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

shared-bindings/gifio/OnDiskGif.c

Lines changed: 27 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,31 @@
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+
//|
83+
//| # Initial set-up the same as above
84+
//|
85+
//| # Take over display to drive directly
86+
//| display.auto_refresh = False
87+
//| display_bus = display.bus
88+
//|
89+
//| # Display repeatedly & directly.
90+
//| while True:
91+
//| # Sleep for the frame delay specified by the GIF,
92+
//| # minus the overhead measured to advance between frames.
93+
//| time.sleep(max(0, next_delay - overhead))
94+
//| next_delay = odg.next_frame()
95+
//|
96+
//| display_bus.send(42, struct.pack(">hh", 0, odg.bitmap.width - 1))
97+
//| display_bus.send(43, struct.pack(">hh", 0, odg.bitmap.height - 1))
98+
//| display_bus.send(44, d.bitmap)
7299
//| """
73100
//|
74101
//| def __init__(self, file: str) -> None:

0 commit comments

Comments
 (0)
0