Skip to content

Commit 20eb7d1

Browse files
committed
Changes times to seconds, remove dirty bitmap flag
1 parent fa43546 commit 20eb7d1

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

shared-bindings/gifio/OnDiskGif.c

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -122,29 +122,23 @@ 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-
//| 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) {
130-
gifio_ondiskgif_t *self = MP_OBJ_TO_PTR(args[0]);
131-
bool setDirty = mp_const_true;
132-
133-
if (n_args == 1) {
134-
setDirty = mp_obj_is_true(args[1]);
135-
}
125+
//| def next_frame(self) -> float:
126+
//| """Loads the next frame. Returns expected delay before the next frame in seconds."""
127+
STATIC mp_obj_t gifio_ondiskgif_obj_next_frame(mp_obj_t self_in) {
128+
gifio_ondiskgif_t *self = MP_OBJ_TO_PTR(self_in);
136129

137-
return MP_OBJ_NEW_SMALL_INT(common_hal_gifio_ondiskgif_next_frame(self, setDirty));
130+
return mp_obj_new_float((float)common_hal_gifio_ondiskgif_next_frame(self, true) / 1000);
138131
}
139132

140-
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gifio_ondiskgif_next_frame_obj, 1, 2, gifio_ondiskgif_obj_next_frame);
133+
MP_DEFINE_CONST_FUN_OBJ_1(gifio_ondiskgif_next_frame_obj, gifio_ondiskgif_obj_next_frame);
134+
141135

142-
//| duration: int
143-
//| """Returns the total duration of the GIF in milliseconds. (read only)"""
136+
//| duration: float
137+
//| """Returns the total duration of the GIF in seconds. (read only)"""
144138
STATIC mp_obj_t gifio_ondiskgif_obj_get_duration(mp_obj_t self_in) {
145139
gifio_ondiskgif_t *self = MP_OBJ_TO_PTR(self_in);
146140

147-
return MP_OBJ_NEW_SMALL_INT(common_hal_gifio_ondiskgif_get_duration(self));
141+
return mp_obj_new_float((float)common_hal_gifio_ondiskgif_get_duration(self) / 1000);
148142
}
149143

150144
MP_DEFINE_CONST_FUN_OBJ_1(gifio_ondiskgif_get_duration_obj, gifio_ondiskgif_obj_get_duration);
@@ -165,26 +159,26 @@ MP_DEFINE_CONST_FUN_OBJ_1(gifio_ondiskgif_get_frame_count_obj, gifio_ondiskgif_o
165159
MP_PROPERTY_GETTER(gifio_ondiskgif_frame_count_obj,
166160
(mp_obj_t)&gifio_ondiskgif_get_frame_count_obj);
167161

168-
//| min_delay: int
162+
//| min_delay: float
169163
//| """The minimum delay found between frames. (read only)"""
170164
STATIC mp_obj_t gifio_ondiskgif_obj_get_min_delay(mp_obj_t self_in) {
171165
gifio_ondiskgif_t *self = MP_OBJ_TO_PTR(self_in);
172166

173-
return MP_OBJ_NEW_SMALL_INT(common_hal_gifio_ondiskgif_get_min_delay(self));
167+
return mp_obj_new_float((float)common_hal_gifio_ondiskgif_get_min_delay(self) / 1000);
174168
}
175169

176170
MP_DEFINE_CONST_FUN_OBJ_1(gifio_ondiskgif_get_min_delay_obj, gifio_ondiskgif_obj_get_min_delay);
177171

178172
MP_PROPERTY_GETTER(gifio_ondiskgif_min_delay_obj,
179173
(mp_obj_t)&gifio_ondiskgif_get_min_delay_obj);
180174

181-
//| max_delay: int
175+
//| max_delay: float
182176
//| """The maximum delay found between frames. (read only)"""
183177
//|
184178
STATIC mp_obj_t gifio_ondiskgif_obj_get_max_delay(mp_obj_t self_in) {
185179
gifio_ondiskgif_t *self = MP_OBJ_TO_PTR(self_in);
186180

187-
return MP_OBJ_NEW_SMALL_INT(common_hal_gifio_ondiskgif_get_max_delay(self));
181+
return mp_obj_new_float((float)common_hal_gifio_ondiskgif_get_max_delay(self) / 1000);
188182
}
189183

190184
MP_DEFINE_CONST_FUN_OBJ_1(gifio_ondiskgif_get_max_delay_obj, gifio_ondiskgif_obj_get_max_delay);

0 commit comments

Comments
 (0)