Skip to content

Commit b4edc7c

Browse files
committed
Fix bugs flagged by cursor[bot]
1 parent b8f97a0 commit b4edc7c

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

components/lcd/esp_lcd_ssd1681/esp_lcd_panel_ssd1681.c

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static esp_err_t epaper_set_lut(esp_lcd_panel_io_handle_t io, const uint8_t *lut
151151

152152
static esp_err_t epaper_set_cursor(esp_lcd_panel_io_handle_t io, uint32_t cur_x, uint32_t cur_y)
153153
{
154-
//esp_log_level_set(TAG, ESP_LOG_DEBUG);
154+
esp_log_level_set(TAG, ESP_LOG_DEBUG);
155155
ESP_LOGD(TAG, "set_cursor: x,y = %lu, %lu", cur_x, cur_y);
156156
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, SSD1681_CMD_SET_INIT_X_ADDR_COUNTER, (uint8_t[]) {
157157
(uint8_t)((cur_x >> 3) & 0xff)
@@ -167,7 +167,7 @@ static esp_err_t epaper_set_cursor(esp_lcd_panel_io_handle_t io, uint32_t cur_x,
167167

168168
static esp_err_t epaper_set_area(esp_lcd_panel_io_handle_t io, uint32_t start_x, uint32_t start_y, uint32_t end_x, uint32_t end_y)
169169
{
170-
//esp_log_level_set(TAG, ESP_LOG_DEBUG);
170+
esp_log_level_set(TAG, ESP_LOG_DEBUG);
171171
ESP_LOGD(TAG, "epaper_set_area: start_xy=(%lu,%lu), end_xy=(%lu,%lu)", start_x, start_y, end_x, end_y);
172172
// --- Set RAMX Start/End Position
173173
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, SSD1681_CMD_SET_RAMX_START_END_POS, (uint8_t[]) {
@@ -196,7 +196,7 @@ static esp_err_t panel_epaper_wait_busy(esp_lcd_panel_t *panel)
196196

197197
esp_err_t panel_epaper_set_vram(esp_lcd_panel_io_handle_t io, uint8_t *bw_bitmap, uint8_t *red_bitmap, size_t size)
198198
{
199-
//esp_log_level_set(TAG, ESP_LOG_DEBUG);
199+
esp_log_level_set(TAG, ESP_LOG_DEBUG);
200200
ESP_LOGD(TAG, "panel_epaper_set_vram: size = %u", size);
201201

202202
// Note: the screen region to be used to draw bitmap had been defined
@@ -249,7 +249,7 @@ esp_err_t
249249
esp_lcd_new_panel_ssd1681(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *const panel_dev_config,
250250
esp_lcd_panel_handle_t *const ret_panel)
251251
{
252-
//esp_log_level_set(TAG, ESP_LOG_DEBUG);
252+
esp_log_level_set(TAG, ESP_LOG_DEBUG);
253253
ESP_RETURN_ON_FALSE(io && panel_dev_config && ret_panel, ESP_ERR_INVALID_ARG, TAG, "1 or more args is NULL");
254254
esp_lcd_ssd1681_config_t *epaper_ssd1681_conf = panel_dev_config->vendor_config;
255255
esp_err_t ret = ESP_OK;
@@ -335,7 +335,7 @@ esp_lcd_new_panel_ssd1681(const esp_lcd_panel_io_handle_t io, const esp_lcd_pane
335335

336336
static esp_err_t epaper_panel_del(esp_lcd_panel_t *panel)
337337
{
338-
//esp_log_level_set(TAG, ESP_LOG_DEBUG);
338+
esp_log_level_set(TAG, ESP_LOG_DEBUG);
339339
epaper_panel_t *epaper_panel = __containerof(panel, epaper_panel_t, base);
340340
// --- Reset used GPIO pins
341341
if ((epaper_panel->reset_gpio_num) >= 0) {
@@ -389,7 +389,7 @@ static esp_err_t epaper_panel_init(esp_lcd_panel_t *panel)
389389
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, SSD1681_CMD_SWRST, NULL, 0), TAG,
390390
"param SSD1681_CMD_SWRST err");
391391
panel_epaper_wait_busy(panel);
392-
// --- Driver Output Control: prescribe the number of rows
392+
// --- Driver Output Control: prescribe the length of a row
393393
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(epaper_panel->io, SSD1681_CMD_OUTPUT_CTRL,
394394
SSD1681_PARAM_OUTPUT_CTRL(epaper_panel->display_y), 3), TAG, "SSD1681_CMD_OUTPUT_CTRL err");
395395

@@ -421,7 +421,7 @@ static esp_err_t epaper_panel_init(esp_lcd_panel_t *panel)
421421
static esp_err_t
422422
epaper_panel_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, const void *color_data)
423423
{
424-
//esp_log_level_set(TAG, ESP_LOG_DEBUG);
424+
esp_log_level_set(TAG, ESP_LOG_DEBUG);
425425
ESP_LOGD(TAG, "epaper_panel_draw_bitmap: xy_start=(%d,%d), end=(%d,%d)", x_start, y_start, x_end, y_end);
426426
epaper_panel_t *epaper_panel = __containerof(panel, epaper_panel_t, base);
427427
if (gpio_get_level(epaper_panel->busy_gpio_num)) {
@@ -472,11 +472,11 @@ epaper_panel_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x
472472
}
473473
// Y MIRROR
474474
else if ((!(epaper_panel->_mirror_x)) && (epaper_panel->_mirror_y)) {
475-
#if SQUARE_PANEL // code for square panel
476-
y_end = y_end + len_y - 1;
477-
#else // code that works with rectangular panels
478-
y_end = 0;
479-
#endif
475+
if (epaper_panel->display_x == epaper_panel->display_y) {
476+
y_end = y_end + len_y - 1; // code for square panel
477+
} else {
478+
y_end = 0; // code for rectangular panels
479+
}
480480
ESP_LOGD(TAG, "epaper_panel_draw_bitmap, mirror Y: x0,y0 = %d,%d, x1,y1=%d,%d", x_start, y_start + len_y - 1, x_end, y_end);
481481
// --- Cursor Settings
482482
ESP_RETURN_ON_ERROR(epaper_set_area(epaper_panel->io, x_start, y_start + len_y - 1, x_end, y_end), TAG,
@@ -490,11 +490,11 @@ epaper_panel_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x
490490
}
491491
// X MIRROR
492492
else if (((epaper_panel->_mirror_x)) && (!(epaper_panel->_mirror_y))) {
493-
#if SQUARE_PANEL // code for square panel
494-
y_end = y_end + len_y - 1;
495-
#else // code that works with rectangular panels
496-
y_end = 0;
497-
#endif
493+
if (epaper_panel->display_x == epaper_panel->display_y) {
494+
y_end = y_end + len_y - 1; // code for square panel
495+
} else {
496+
y_end = 0; // code for rectangular panels
497+
}
498498
ESP_LOGD(TAG, "epaper_panel_draw_bitmap, mirror X: x0,y0 = %d,%d, x1,y1=%d,%d", x_start, y_start + len_y - 1, x_end, y_end);
499499
// --- Cursor Settings
500500
ESP_RETURN_ON_ERROR(epaper_set_area(epaper_panel->io, x_start, y_start + len_y - 1, x_end, y_end), TAG,
@@ -605,7 +605,7 @@ static esp_err_t epaper_panel_disp_on_off(esp_lcd_panel_t *panel, bool on_off)
605605

606606
static esp_err_t process_bitmap(esp_lcd_panel_t *panel, int len_x, int len_y, int buffer_size, const void *color_data)
607607
{
608-
//esp_log_level_set(TAG, ESP_LOG_DEBUG);
608+
esp_log_level_set(TAG, ESP_LOG_DEBUG);
609609
epaper_panel_t *epaper_panel = __containerof(panel, epaper_panel_t, base);
610610
// --- Convert image according to configuration
611611
// NO MIRROR
@@ -678,6 +678,7 @@ static esp_err_t process_bitmap(esp_lcd_panel_t *panel, int len_x, int len_y, in
678678
} else {
679679
// Copy to framebuffer: image ends up with X & Y axes mirrored. When epaper_panel_draw_bitmap is called,
680680
// image is transferred to panel by starting at Y=0 and incrementing with each row.
681+
ESP_LOGD(TAG, "process_bitmap, mirror XY, no swap: buffer_size = %d", buffer_size);
681682
for (int i = 0; i < buffer_size; i++) {
682683
(epaper_panel->_framebuffer)[buffer_size - i - 1] = byte_reverse(((uint8_t *)(color_data))[i]);
683684
}
@@ -687,6 +688,16 @@ static esp_err_t process_bitmap(esp_lcd_panel_t *panel, int len_x, int len_y, in
687688
return ESP_OK;
688689
}
689690

691+
esp_err_t set_panel_size(esp_lcd_panel_t *panel, int len_x, int len_y)
692+
{
693+
epaper_panel_t *epaper_panel = __containerof(panel, epaper_panel_t, base);
694+
esp_log_level_set(TAG, ESP_LOG_DEBUG);
695+
ESP_LOGD(TAG, "set_panel_size: x,y = %d, %d", len_x, len_y);
696+
ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(epaper_panel->io, SSD1681_CMD_OUTPUT_CTRL,
697+
SSD1681_PARAM_OUTPUT_CTRL(len_x), 0), TAG, "SSD1681_CMD_OUTPUT_CTRL err");
698+
return ESP_OK;
699+
}
700+
690701
// If MIRROR Y, then bytes must be reversed.
691702
static inline uint8_t byte_reverse(uint8_t data)
692703
{

components/lcd/esp_lcd_ssd1681/examples/epaper_lvgl_rotate/main/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,6 @@ void app_main(void)
529529
// The task running lv_timer_handler should have lower priority than that running `lv_tick_inc`
530530
lv_time = lv_timer_handler();
531531
ESP_LOGD(TAG, "lv_time returned = %lu", lv_time);
532-
memset(buf1, 0x0, DISPLAY_X * DISPLAY_Y / 8);
533532
set_swap_mirror(&disp_drv, ROTATE_TEST[i]);
534533
lvgl_canvas_ui(DISPLAY_X, DISPLAY_Y, ROTATE_TEST[i]);
535534
int delay_ms = 0;

0 commit comments

Comments
 (0)