summaryrefslogtreecommitdiff
path: root/shared-module
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2020-04-15 12:29:32 -0500
committerJeff Epler <jepler@gmail.com>2020-04-17 18:43:57 -0500
commit57ce2d1f417bd4c2988155d45739a3a61950471f (patch)
tree9f75b80a93b38affb58fdcd2098282d51131253d /shared-module
parent3d6258f63dce84519704251b86a16c832958c8a6 (diff)
framebufferio: get width, etc., from protocol, not object property
Diffstat (limited to 'shared-module')
-rw-r--r--shared-module/framebufferio/FramebufferDisplay.c31
-rw-r--r--shared-module/framebufferio/FramebufferDisplay.h10
2 files changed, 32 insertions, 9 deletions
diff --git a/shared-module/framebufferio/FramebufferDisplay.c b/shared-module/framebufferio/FramebufferDisplay.c
index bd0764e8e..db17013ea 100644
--- a/shared-module/framebufferio/FramebufferDisplay.c
+++ b/shared-module/framebufferio/FramebufferDisplay.c
@@ -42,10 +42,9 @@
#include "tick.h"
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) {
// Turn off auto-refresh as we init.
self->auto_refresh = false;
self->framebuffer = framebuffer;
@@ -54,15 +53,29 @@ void common_hal_framebufferio_framebufferdisplay_construct(framebufferio_framebu
uint16_t ram_width = 0x100;
uint16_t ram_height = 0x100;
- displayio_display_core_construct(&self->core, NULL, width, height, ram_width, ram_height, 0, 0, rotation,
- color_depth, false, false, bytes_per_cell, false, false);
+ displayio_display_core_construct(
+ &self->core,
+ NULL,
+ self->framebuffer_protocol->get_width(self->framebuffer),
+ self->framebuffer_protocol->get_height(self->framebuffer),
+ ram_width,
+ ram_height,
+ 0,
+ 0,
+ rotation,
+ self->framebuffer_protocol->get_color_depth(self->framebuffer),
+ false,
+ false,
+ self->framebuffer_protocol->get_bytes_per_cell(self->framebuffer),
+ false,
+ false);
self->first_manual_refresh = !auto_refresh;
- self->native_frames_per_second = native_frames_per_second;
- self->native_ms_per_frame = 1000 / native_frames_per_second;
+ self->native_frames_per_second = self->framebuffer_protocol->get_native_frames_per_second(self->framebuffer);
+ self->native_ms_per_frame = 1000 / self->native_frames_per_second;
- supervisor_start_terminal(width, height);
+ supervisor_start_terminal(self->core.width, self->core.height);
// Set the group after initialization otherwise we may send pixels while we delay in
// initialization.
diff --git a/shared-module/framebufferio/FramebufferDisplay.h b/shared-module/framebufferio/FramebufferDisplay.h
index a7b91a522..ea2fe168e 100644
--- a/shared-module/framebufferio/FramebufferDisplay.h
+++ b/shared-module/framebufferio/FramebufferDisplay.h
@@ -66,12 +66,22 @@ typedef bool (*framebuffer_set_brightness_fun)(mp_obj_t, mp_float_t);
typedef mp_float_t (*framebuffer_get_brightness_fun)(mp_obj_t);
typedef bool (*framebuffer_set_auto_brightness_fun)(mp_obj_t, bool);
typedef bool (*framebuffer_get_auto_brightness_fun)(mp_obj_t);
+typedef int (*framebuffer_get_width_fun)(mp_obj_t);
+typedef int (*framebuffer_get_height_fun)(mp_obj_t);
+typedef int (*framebuffer_get_color_depth_fun)(mp_obj_t);
+typedef int (*framebuffer_get_bytes_per_cell_fun)(mp_obj_t);
+typedef int (*framebuffer_get_native_frames_per_second_fun)(mp_obj_t);
typedef struct _framebuffer_p_t {
MP_PROTOCOL_HEAD // MP_QSTR_protocol_framebuffer
framebuffer_get_bufinfo_fun get_bufinfo;
framebuffer_swapbuffers_fun swapbuffers;
framebuffer_deinit_fun deinit;
+ framebuffer_get_width_fun get_width;
+ framebuffer_get_height_fun get_height;
+ framebuffer_get_color_depth_fun get_color_depth;
+ framebuffer_get_bytes_per_cell_fun get_bytes_per_cell;
+ framebuffer_get_native_frames_per_second_fun get_native_frames_per_second;
framebuffer_get_brightness_fun get_brightness;
framebuffer_set_brightness_fun set_brightness;
framebuffer_get_auto_brightness_fun get_auto_brightness;