Skip to content

Commit 1b6283a

Browse files
author
Amit Sides
committed
Adding quick refresh support
1 parent 57841dc commit 1b6283a

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

shared-bindings/displayio/EPaperDisplay.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,30 @@ STATIC mp_obj_t displayio_epaperdisplay_obj_show(mp_obj_t self_in, mp_obj_t grou
217217
}
218218
MP_DEFINE_CONST_FUN_OBJ_2(displayio_epaperdisplay_show_obj, displayio_epaperdisplay_obj_show);
219219

220+
STATIC mp_obj_t update_refresh_mode(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
221+
{
222+
enum { ARG_start_sequence, ARG_seconds_per_frame };
223+
static const mp_arg_t allowed_args[] = {
224+
{ MP_QSTR_start_sequence, MP_ARG_REQUIRED | MP_ARG_OBJ },
225+
{ MP_QSTR_seconds_per_frame, MP_ARG_OBJ, {.u_obj = MP_OBJ_NEW_SMALL_INT(180)} },
226+
};
227+
displayio_epaperdisplay_obj_t *self = native_display(pos_args[0]);
228+
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
229+
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
230+
231+
// Get parameters
232+
mp_buffer_info_t start_sequence;
233+
mp_get_buffer_raise(args[ARG_start_sequence].u_obj, &start_sequence, MP_BUFFER_READ);
234+
float seconds_per_frame = mp_obj_get_float(args[ARG_seconds_per_frame].u_obj);
235+
236+
// Update parameters
237+
self->start_sequence = (uint8_t *)start_sequence.buf;
238+
self->start_sequence_len = start_sequence.len;
239+
self->milliseconds_per_frame = seconds_per_frame * 1000;
240+
return mp_const_none;
241+
}
242+
MP_DEFINE_CONST_FUN_OBJ_KW(update_refresh_mode_obj, 3, update_refresh_mode);
243+
220244
//| def refresh(self) -> None:
221245
//| """Refreshes the display immediately or raises an exception if too soon. Use
222246
//| ``time.sleep(display.time_to_refresh)`` to sleep until a refresh can occur."""
@@ -339,6 +363,7 @@ const mp_obj_property_t displayio_epaperdisplay_bus_obj = {
339363

340364
STATIC const mp_rom_map_elem_t displayio_epaperdisplay_locals_dict_table[] = {
341365
{ MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&displayio_epaperdisplay_show_obj) },
366+
{ MP_ROM_QSTR(MP_QSTR_update_refresh_mode), MP_ROM_PTR(&update_refresh_mode_obj) },
342367
{ MP_ROM_QSTR(MP_QSTR_refresh), MP_ROM_PTR(&displayio_epaperdisplay_refresh_obj) },
343368

344369
{ MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_epaperdisplay_width_obj) },

shared-bindings/displayio/EPaperDisplay.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extern const mp_obj_type_t displayio_epaperdisplay_type;
3939
#define NO_COMMAND 0x100
4040

4141
void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t *self,
42-
mp_obj_t bus, const uint8_t *start_sequence, uint16_t start_sequence_len, const uint8_t *stop_sequence, uint16_t stop_sequence_len,
42+
mp_obj_t bus, uint8_t *start_sequence, uint16_t start_sequence_len, const uint8_t *stop_sequence, uint16_t stop_sequence_len,
4343
uint16_t width, uint16_t height, uint16_t ram_width, uint16_t ram_height, int16_t colstart, int16_t rowstart, uint16_t rotation,
4444
uint16_t set_column_window_command, uint16_t set_row_window_command,
4545
uint16_t set_current_column_command, uint16_t set_current_row_command,

shared-module/displayio/EPaperDisplay.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#include <string.h>
4444

4545
void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t *self,
46-
mp_obj_t bus, const uint8_t *start_sequence, uint16_t start_sequence_len,
46+
mp_obj_t bus, uint8_t *start_sequence, uint16_t start_sequence_len,
4747
const uint8_t *stop_sequence, uint16_t stop_sequence_len,
4848
uint16_t width, uint16_t height, uint16_t ram_width, uint16_t ram_height,
4949
int16_t colstart, int16_t rowstart, uint16_t rotation,

shared-module/displayio/EPaperDisplay.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ typedef struct {
3838
displayio_display_core_t core;
3939
digitalio_digitalinout_obj_t busy;
4040
uint32_t milliseconds_per_frame;
41-
const uint8_t *start_sequence;
41+
uint8_t *start_sequence;
4242
uint32_t start_sequence_len;
4343
const uint8_t *stop_sequence;
4444
uint32_t stop_sequence_len;

0 commit comments

Comments
 (0)