Skip to content

Commit 45e721a

Browse files
authored
Merge pull request adafruit#8698 from jepler/qualia-width-16
rgbframebuffer: round up internal size to multiple of 16 pixels
2 parents 156f417 + 15ba61e commit 45e721a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

ports/espressif/common-hal/dotclockframebuffer/DotClockFramebuffer.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void common_hal_dotclockframebuffer_framebuffer_construct(dotclockframebuffer_fr
114114

115115
esp_lcd_rgb_panel_config_t *cfg = &self->panel_config;
116116
cfg->timings.pclk_hz = frequency;
117-
cfg->timings.h_res = width + overscan_left;
117+
cfg->timings.h_res = (width + overscan_left + 15) / 16 * 16; // round up to multiple of 16
118118
cfg->timings.v_res = height;
119119
cfg->timings.hsync_pulse_width = hsync_pulse_width;
120120
cfg->timings.hsync_back_porch = hsync_back_porch;
@@ -174,9 +174,10 @@ void common_hal_dotclockframebuffer_framebuffer_construct(dotclockframebuffer_fr
174174
cp_check_esp_error(esp_lcd_rgb_panel_get_frame_buffer(self->panel_handle, 1, &fb));
175175

176176
self->frequency = frequency;
177-
self->row_stride = 2 * (width + overscan_left);
177+
self->width = width;
178+
self->row_stride = 2 * (cfg->timings.h_res);
178179
self->first_pixel_offset = 2 * overscan_left;
179-
self->refresh_rate = frequency / (width + hsync_front_porch + hsync_back_porch) / (height + vsync_front_porch + vsync_back_porch);
180+
self->refresh_rate = frequency / (cfg->timings.h_res + hsync_front_porch + hsync_back_porch) / (height + vsync_front_porch + vsync_back_porch);
180181
self->bufinfo.buf = (uint8_t *)fb;
181182
self->bufinfo.len = 2 * (cfg->timings.h_res * cfg->timings.v_res);
182183
self->bufinfo.typecode = 'H' | MP_OBJ_ARRAY_TYPECODE_FLAG_RW;
@@ -203,7 +204,7 @@ bool common_hal_dotclockframebuffer_framebuffer_deinitialized(dotclockframebuffe
203204

204205

205206
mp_int_t common_hal_dotclockframebuffer_framebuffer_get_width(dotclockframebuffer_framebuffer_obj_t *self) {
206-
return self->panel_config.timings.h_res - self->first_pixel_offset / 2;
207+
return self->width;
207208
}
208209

209210
mp_int_t common_hal_dotclockframebuffer_framebuffer_get_height(dotclockframebuffer_framebuffer_obj_t *self) {

ports/espressif/common-hal/dotclockframebuffer/DotClockFramebuffer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
typedef struct dotclockframebuffer_framebuffer_obj {
3838
mp_obj_base_t base;
3939
mp_buffer_info_t bufinfo;
40-
mp_int_t row_stride;
40+
mp_int_t width, row_stride;
4141
uint32_t frequency, refresh_rate;
4242
uint32_t first_pixel_offset;
4343
uint64_t used_pins_mask;

0 commit comments

Comments
 (0)