|
36 | 36 | //| class OnDiskGif:
|
37 | 37 | //| """Loads one frame of a GIF into memory at a time.
|
38 | 38 | //|
|
| 39 | +//| The code can be used in cooperation with displayio but this mode is relatively slow: |
| 40 | +//| |
39 | 41 | //| .. code-block:: Python
|
40 | 42 | //|
|
41 | 43 | //| import board
|
|
69 | 71 | //| # minus the overhead measured to advance between frames.
|
70 | 72 | //| time.sleep(max(0, next_delay - overhead))
|
71 | 73 | //| 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) |
72 | 99 | //| """
|
73 | 100 | //|
|
74 | 101 | //| def __init__(self, file: str) -> None:
|
|
0 commit comments