diff options
| author | Jeff Epler <jepler@gmail.com> | 2020-04-15 12:29:32 -0500 |
|---|---|---|
| committer | Jeff Epler <jepler@gmail.com> | 2020-04-17 18:43:57 -0500 |
| commit | 57ce2d1f417bd4c2988155d45739a3a61950471f (patch) | |
| tree | 9f75b80a93b38affb58fdcd2098282d51131253d /shared-bindings | |
| parent | 3d6258f63dce84519704251b86a16c832958c8a6 (diff) | |
framebufferio: get width, etc., from protocol, not object property
Diffstat (limited to 'shared-bindings')
| -rw-r--r-- | shared-bindings/framebufferio/FramebufferDisplay.c | 17 | ||||
| -rw-r--r-- | shared-bindings/framebufferio/FramebufferDisplay.h | 7 | ||||
| -rw-r--r-- | shared-bindings/rgbmatrix/RGBMatrix.c | 26 |
3 files changed, 30 insertions, 20 deletions
diff --git a/shared-bindings/framebufferio/FramebufferDisplay.c b/shared-bindings/framebufferio/FramebufferDisplay.c index 5014f3924..820eda51a 100644 --- a/shared-bindings/framebufferio/FramebufferDisplay.c +++ b/shared-bindings/framebufferio/FramebufferDisplay.c @@ -39,10 +39,6 @@ #include "shared-module/displayio/__init__.h" #include "supervisor/shared/translate.h" -STATIC int get_int_property(mp_obj_t obj, qstr attr) { - return mp_obj_get_int(mp_load_attr(obj, attr)); -} - //| .. currentmodule:: framebufferio //| //| :class:`FramebufferDisplay` -- Manage updating a display with framebuffer in RAM @@ -79,25 +75,14 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_make_new(const mp_obj_type_t *t mp_raise_ValueError(translate("Display rotation must be in 90 degree increments")); } - int width = get_int_property(framebuffer, MP_QSTR_width); - int height = get_int_property(framebuffer, MP_QSTR_height); - int color_depth = get_int_property(framebuffer, MP_QSTR_color_depth); - int bytes_per_cell = get_int_property(framebuffer, MP_QSTR_bytes_per_cell); - int native_frames_per_second = get_int_property(framebuffer, MP_QSTR_native_frames_per_second); - primary_display_t *disp = allocate_display_or_raise(); framebufferio_framebufferdisplay_obj_t *self = &disp->framebuffer_display; self->base.type = &framebufferio_framebufferdisplay_type; common_hal_framebufferio_framebufferdisplay_construct( self, framebuffer, - width, - height, rotation, - color_depth, - bytes_per_cell, - args[ARG_auto_refresh].u_bool, - native_frames_per_second + args[ARG_auto_refresh].u_bool ); return self; diff --git a/shared-bindings/framebufferio/FramebufferDisplay.h b/shared-bindings/framebufferio/FramebufferDisplay.h index b472088d2..e7ead6ac5 100644 --- a/shared-bindings/framebufferio/FramebufferDisplay.h +++ b/shared-bindings/framebufferio/FramebufferDisplay.h @@ -39,10 +39,9 @@ extern const mp_obj_type_t framebufferio_framebufferdisplay_type; #define NO_BRIGHTNESS_COMMAND 0x100 void common_hal_framebufferio_framebufferdisplay_construct(framebufferio_framebufferdisplay_obj_t* self, - mp_obj_t framebuffer, uint16_t width, uint16_t height, - uint16_t rotation, uint16_t color_depth, - uint8_t bytes_per_cell, - bool auto_refresh, uint16_t native_frames_per_second); + mp_obj_t framebuffer, + uint16_t rotation, + bool auto_refresh); bool common_hal_framebufferio_framebufferdisplay_show(framebufferio_framebufferdisplay_obj_t* self, displayio_group_t* root_group); diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index c62b587bf..368b73091 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -443,11 +443,37 @@ STATIC bool protomatter_protomatter_set_brightness_proto(mp_obj_t self_in, mp_fl return true; } +STATIC int protomatter_protomatter_get_width_proto(mp_obj_t self_in) { + return common_hal_protomatter_protomatter_get_width(self_in); +} + +STATIC int protomatter_protomatter_get_height_proto(mp_obj_t self_in) { + return common_hal_protomatter_protomatter_get_height(self_in); +} + +STATIC int protomatter_protomatter_get_color_depth_proto(mp_obj_t self_in) { + return 16; +} + +STATIC int protomatter_protomatter_get_bytes_per_cell_proto(mp_obj_t self_in) { + return 1; +} + +STATIC int protomatter_protomatter_get_native_frames_per_second_proto(mp_obj_t self_in) { + return 250; +} + + STATIC const framebuffer_p_t protomatter_protomatter_proto = { MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuffer) .get_bufinfo = protomatter_protomatter_get_bufinfo, .set_brightness = protomatter_protomatter_set_brightness_proto, .get_brightness = protomatter_protomatter_get_brightness_proto, + .get_width = protomatter_protomatter_get_width_proto, + .get_height = protomatter_protomatter_get_height_proto, + .get_color_depth = protomatter_protomatter_get_color_depth_proto, + .get_bytes_per_cell = protomatter_protomatter_get_bytes_per_cell_proto, + .get_native_frames_per_second = protomatter_protomatter_get_native_frames_per_second_proto, .swapbuffers = protomatter_protomatter_swapbuffers, .deinit = protomatter_protomatter_deinit_proto, }; |
