Skip to content

Commit cab38ed

Browse files
committed
Doc fixes and renamed play_frame to next_frame
1 parent 0c95e6a commit cab38ed

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

shared-bindings/gifio/OnDiskGif.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* The MIT License (MIT)
55
*
6-
* Copyright (c) 2018 Scott Shawcroft for Adafruit Industries
6+
* Copyright (c) 2023 Mark Komus
77
*
88
* Permission is hereby granted, free of charge, to any person obtaining a copy
99
* of this software and associated documentation files (the "Software"), to deal
@@ -34,28 +34,28 @@
3434
#include "shared-bindings/gifio/OnDiskGif.h"
3535

3636
//| class OnDiskGif:
37-
//| """Loads values straight from disk. This minimizes memory use but can lead to
38-
//| much slower pixel load times
37+
//| """Loads frames of the GIF straight from disk. This minimizes memory use but can
38+
//| lead to much slower pixel load times
3939
//|
4040
//| .. code-block:: Python
4141
//|
4242
//| import board
4343
//| import gifio
44+
//| import displayio
4445
//| import time
45-
//| import pulseio
4646
//|
47-
//| splash = gifio.Group()
47+
//| splash = displayio.Group()
4848
//| board.DISPLAY.show(splash)
4949
//|
50-
//| odg = gifio.OnDiskBitmap('/sample.gif')
51-
//| odg.play_frame() # Load the first frame
52-
//| face = gifio.TileGrid(odg, pixel_shader=gifio.ColorConverter(input_colorspace=gifio.Colorspace.RGB565))
50+
//| odg = gifio.OnDiskGif('/sample.gif')
51+
//| odg.next_frame() # Load the first frame
52+
//| face = displayio.TileGrid(odg, pixel_shader=displayio.ColorConverter(input_colorspace=displayio.Colorspace.RGB565))
5353
//| splash.append(face)
5454
//| board.DISPLAY.refresh()
5555
//|
5656
//| # Wait forever
5757
//| while True:
58-
//| gif.play_frame()
58+
//| gif.next_frame()
5959
//| time.sleep(0.1)"""
6060
//|
6161
//| def __init__(self, file: str) -> None:
@@ -122,20 +122,22 @@ MP_DEFINE_CONST_FUN_OBJ_1(gifio_ondiskgif_get_bitmap_obj, gifio_ondiskgif_obj_ge
122122
MP_PROPERTY_GETTER(gifio_ondiskgif_bitmap_obj,
123123
(mp_obj_t)&gifio_ondiskgif_get_bitmap_obj);
124124

125-
//| play_frame: int
126-
//| """Play next frame. Returns expected delay until the next frame."""
127-
STATIC mp_obj_t gifio_ondiskgif_obj_play_frame(size_t n_args, const mp_obj_t *args) {
125+
//| def next_frame(self, set_dirty: bool = True) -> int:
126+
//| """Loads the next frame. Returns expected delay before the next frame in milliseconds.
127+
//|
128+
//| :param set_dirty: Mark the bitmap as dirty"""
129+
STATIC mp_obj_t gifio_ondiskgif_obj_next_frame(size_t n_args, const mp_obj_t *args) {
128130
gifio_ondiskgif_t *self = MP_OBJ_TO_PTR(args[0]);
129131
bool setDirty = mp_const_true;
130132

131133
if (n_args == 1) {
132134
setDirty = mp_obj_is_true(args[1]);
133135
}
134136

135-
return MP_OBJ_NEW_SMALL_INT(common_hal_gifio_ondiskgif_play_frame(self, setDirty));
137+
return MP_OBJ_NEW_SMALL_INT(common_hal_gifio_ondiskgif_next_frame(self, setDirty));
136138
}
137139

138-
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gifio_ondiskgif_play_frame_obj, 1, 2, gifio_ondiskgif_obj_play_frame);
140+
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gifio_ondiskgif_next_frame_obj, 1, 2, gifio_ondiskgif_obj_next_frame);
139141

140142
//| duration: int
141143
//| """Returns the total duration of the GIF in milliseconds. (read only)"""
@@ -194,7 +196,7 @@ STATIC const mp_rom_map_elem_t gifio_ondiskgif_locals_dict_table[] = {
194196
{ MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&gifio_ondiskgif_height_obj) },
195197
{ MP_ROM_QSTR(MP_QSTR_bitmap), MP_ROM_PTR(&gifio_ondiskgif_bitmap_obj) },
196198
{ MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&gifio_ondiskgif_width_obj) },
197-
{ MP_ROM_QSTR(MP_QSTR_play_frame), MP_ROM_PTR(&gifio_ondiskgif_play_frame_obj) },
199+
{ MP_ROM_QSTR(MP_QSTR_next_frame), MP_ROM_PTR(&gifio_ondiskgif_next_frame_obj) },
198200
{ MP_ROM_QSTR(MP_QSTR_duration), MP_ROM_PTR(&gifio_ondiskgif_duration_obj) },
199201
{ MP_ROM_QSTR(MP_QSTR_frame_count), MP_ROM_PTR(&gifio_ondiskgif_frame_count_obj) },
200202
{ MP_ROM_QSTR(MP_QSTR_min_delay), MP_ROM_PTR(&gifio_ondiskgif_min_delay_obj) },

shared-bindings/gifio/OnDiskGif.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* The MIT License (MIT)
55
*
6-
* Copyright (c) 2018 Scott Shawcroft for Adafruit Industries
6+
* Copyright (c) 2023 Mark Komus
77
*
88
* Permission is hereby granted, free of charge, to any person obtaining a copy
99
* of this software and associated documentation files (the "Software"), to deal
@@ -41,7 +41,7 @@ uint16_t common_hal_gifio_ondiskgif_get_height(gifio_ondiskgif_t *self);
4141
mp_obj_t common_hal_gifio_ondiskgif_get_pixel_shader(gifio_ondiskgif_t *self);
4242
mp_obj_t common_hal_gifio_ondiskgif_get_bitmap(gifio_ondiskgif_t *self);
4343
uint16_t common_hal_gifio_ondiskgif_get_width(gifio_ondiskgif_t *self);
44-
uint8_t common_hal_gifio_ondiskgif_play_frame(gifio_ondiskgif_t *self, bool setDirty);
44+
uint8_t common_hal_gifio_ondiskgif_next_frame(gifio_ondiskgif_t *self, bool setDirty);
4545
int32_t common_hal_gifio_ondiskgif_get_duration(gifio_ondiskgif_t *self);
4646
int32_t common_hal_gifio_ondiskgif_get_frame_count(gifio_ondiskgif_t *self);
4747
int32_t common_hal_gifio_ondiskgif_get_min_delay(gifio_ondiskgif_t *self);

shared-module/gifio/OnDiskGif.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* The MIT License (MIT)
55
*
6-
* Copyright (c) 2018 Scott Shawcroft for Adafruit Industries
6+
* Copyright (c) 2023 Mark Komus
77
*
88
* Permission is hereby granted, free of charge, to any person obtaining a copy
99
* of this software and associated documentation files (the "Software"), to deal
@@ -185,7 +185,7 @@ int32_t common_hal_gifio_ondiskgif_get_max_delay(gifio_ondiskgif_t *self) {
185185
return self->max_delay;
186186
}
187187

188-
uint8_t common_hal_gifio_ondiskgif_play_frame(gifio_ondiskgif_t *self, bool setDirty) {
188+
uint8_t common_hal_gifio_ondiskgif_next_frame(gifio_ondiskgif_t *self, bool setDirty) {
189189
int nextDelay = 0;
190190
int result = GIF_playFrame(&self->gif, &nextDelay, self->bitmap);
191191

shared-module/gifio/OnDiskGif.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* The MIT License (MIT)
55
*
6-
* Copyright (c) 2018 Scott Shawcroft for Adafruit Industries
6+
* Copyright (c) 2023 Mark Komus
77
*
88
* Permission is hereby granted, free of charge, to any person obtaining a copy
99
* of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)