Skip to content

Commit 7165a3b

Browse files
committed
Merge branch 'feat/mipi_dsi_draw_pixel_round_boundary_v5.3' into 'release/v5.3'
feat(mipi_dsi): round to boundary when draw pixel (v5.3) See merge request espressif/esp-idf!30694
2 parents 1b331d2 + b9f15ba commit 7165a3b

File tree

6 files changed

+16
-9
lines changed

6 files changed

+16
-9
lines changed

components/esp_lcd/dsi/esp_lcd_panel_dpi.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6+
#include <sys/param.h>
67
#include "freertos/FreeRTOS.h"
78
#include "freertos/task.h"
89
#include "freertos/semphr.h"
@@ -417,6 +418,14 @@ static esp_err_t dpi_panel_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int
417418
size_t frame_buffer_size = dpi_panel->frame_buffer_size;
418419
size_t bytes_per_pixel = dpi_panel->bytes_per_pixel;
419420

421+
// clip to boundaries
422+
int h_res = dpi_panel->h_pixels;
423+
int v_res = dpi_panel->v_pixels;
424+
x_start = MAX(x_start, 0);
425+
x_end = MIN(x_end, h_res);
426+
y_start = MAX(y_start, 0);
427+
y_end = MIN(y_end, v_res);
428+
420429
bool do_copy = false;
421430
uint8_t draw_buf_fb_index = 0;
422431
// check if the user draw buffer resides in any frame buffer's memory range

components/esp_lcd/rgb/esp_lcd_panel_rgb.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,6 @@ static esp_err_t rgb_panel_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int
706706
{
707707
esp_rgb_panel_t *rgb_panel = __containerof(panel, esp_rgb_panel_t, base);
708708
ESP_RETURN_ON_FALSE(rgb_panel->num_fbs > 0, ESP_ERR_NOT_SUPPORTED, TAG, "no frame buffer installed");
709-
assert((x_start < x_end) && (y_start < y_end) && "start position must be smaller than end position");
710709

711710
// check if we need to copy the draw buffer (pointed by the color_data) to the driver's frame buffer
712711
bool do_copy = false;
@@ -726,18 +725,19 @@ static esp_err_t rgb_panel_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int
726725
y_start += rgb_panel->y_gap;
727726
x_end += rgb_panel->x_gap;
728727
y_end += rgb_panel->y_gap;
729-
// round the boundary
728+
729+
// clip to boundaries
730730
int h_res = rgb_panel->timings.h_res;
731731
int v_res = rgb_panel->timings.v_res;
732732
if (rgb_panel->rotate_mask & ROTATE_MASK_SWAP_XY) {
733-
x_start = MIN(x_start, v_res);
733+
x_start = MAX(x_start, 0);
734734
x_end = MIN(x_end, v_res);
735-
y_start = MIN(y_start, h_res);
735+
y_start = MAX(y_start, 0);
736736
y_end = MIN(y_end, h_res);
737737
} else {
738-
x_start = MIN(x_start, h_res);
738+
x_start = MAX(x_start, 0);
739739
x_end = MIN(x_end, h_res);
740-
y_start = MIN(y_start, v_res);
740+
y_start = MAX(y_start, 0);
741741
y_end = MIN(y_end, v_res);
742742
}
743743

components/esp_lcd/src/esp_lcd_panel_nt35510.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ static esp_err_t panel_nt35510_draw_bitmap(esp_lcd_panel_t *panel, int x_start,
188188
const void *color_data)
189189
{
190190
nt35510_panel_t *nt35510 = __containerof(panel, nt35510_panel_t, base);
191-
assert((x_start < x_end) && (y_start < y_end) && "start position must be smaller than end position");
192191
esp_lcd_panel_io_handle_t io = nt35510->io;
193192

194193
x_start += nt35510->x_gap;

components/esp_lcd/src/esp_lcd_panel_ops.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ esp_err_t esp_lcd_panel_del(esp_lcd_panel_handle_t panel)
3232
esp_err_t esp_lcd_panel_draw_bitmap(esp_lcd_panel_handle_t panel, int x_start, int y_start, int x_end, int y_end, const void *color_data)
3333
{
3434
ESP_RETURN_ON_FALSE(panel, ESP_ERR_INVALID_ARG, TAG, "invalid panel handle");
35+
ESP_RETURN_ON_FALSE((x_start < x_end) && (y_start < y_end), ESP_ERR_INVALID_ARG, TAG, "start position must be smaller than end position");
3536
ESP_RETURN_ON_FALSE(panel->draw_bitmap, ESP_ERR_NOT_SUPPORTED, TAG, "draw_bitmap is not supported by this panel");
3637
return panel->draw_bitmap(panel, x_start, y_start, x_end, y_end, color_data);
3738
}

components/esp_lcd/src/esp_lcd_panel_ssd1306.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ static esp_err_t panel_ssd1306_init(esp_lcd_panel_t *panel)
168168
static esp_err_t panel_ssd1306_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, const void *color_data)
169169
{
170170
ssd1306_panel_t *ssd1306 = __containerof(panel, ssd1306_panel_t, base);
171-
assert((x_start < x_end) && (y_start < y_end) && "start position must be smaller than end position");
172171
esp_lcd_panel_io_handle_t io = ssd1306->io;
173172

174173
// adding extra gap

components/esp_lcd/src/esp_lcd_panel_st7789.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ static esp_err_t panel_st7789_draw_bitmap(esp_lcd_panel_t *panel, int x_start, i
198198
const void *color_data)
199199
{
200200
st7789_panel_t *st7789 = __containerof(panel, st7789_panel_t, base);
201-
assert((x_start < x_end) && (y_start < y_end) && "start position must be smaller than end position");
202201
esp_lcd_panel_io_handle_t io = st7789->io;
203202

204203
x_start += st7789->x_gap;

0 commit comments

Comments
 (0)