|
48 | 48 | //| display.root_group = splash |
49 | 49 | //| |
50 | 50 | //| odg = gifio.OnDiskGif('/sample.gif') |
| 51 | +//| |
| 52 | +//| start = time.monotonic() |
51 | 53 | //| odg.next_frame() # Load the first frame |
52 | | -//| # Depending on your display the next line may need Colorspace.RGB565 instead of Colorspace.RGB565_SWAPPED |
53 | | -//| face = displayio.TileGrid(odg.bitmap, pixel_shader=displayio.ColorConverter(input_colorspace=displayio.Colorspace.RGB565_SWAPPED)) |
| 54 | +//| end = time.monotonic() |
| 55 | +//| overhead = end - start |
| 56 | +//| |
| 57 | +//| face = displayio.TileGrid( |
| 58 | +//| odg.bitmap, |
| 59 | +//| pixel_shader=displayio.ColorConverter( |
| 60 | +//| input_colorspace=displayio.Colorspace.RGB565_SWAPPED |
| 61 | +//| ), |
| 62 | +//| ) |
54 | 63 | //| splash.append(face) |
55 | 64 | //| board.DISPLAY.refresh() |
56 | 65 | //| |
57 | | -//| # Wait forever |
| 66 | +//| # Display repeatedly. |
58 | 67 | //| while True: |
| 68 | +//| # Sleep for the frame delay specified by the GIF, |
| 69 | +//| # minus the overhead measured to advance between frames. |
| 70 | +//| time.sleep(max(0, next_delay - overhead)) |
59 | 71 | //| next_delay = odg.next_frame() |
60 | | -//| time.sleep(next_delay)""" |
| 72 | +//| """ |
61 | 73 | //| |
62 | 74 | //| def __init__(self, file: str) -> None: |
63 | | -//| """Create an OnDiskGif object with the given file. |
| 75 | +//| """Create an `OnDiskGif` object with the given file. |
| 76 | +//| The GIF frames are decoded into RGB565 big-endian format. |
| 77 | +//| `displayio` expects little-endian, so the example above uses `Colorspace.RGB565_SWAPPED`. |
64 | 78 | //| |
65 | 79 | //| :param file file: The name of the GIF file. |
66 | | -//| |
67 | 80 | //| """ |
68 | 81 | //| ... |
69 | 82 | STATIC mp_obj_t gifio_ondiskgif_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { |
|
0 commit comments