From 5b795f8c6be846cf2f2231614b1623f93fb414ba Mon Sep 17 00:00:00 2001 From: AVartanyan <42091996+AramVartanyan@users.noreply.github.com> Date: Mon, 18 Sep 2023 21:14:06 +0300 Subject: [PATCH] Fix the Landscape orientation Thanks to Damian Glinojecki --- lvgl_tft/ssd1680.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lvgl_tft/ssd1680.c b/lvgl_tft/ssd1680.c index 8fb43b8..199ffc1 100644 --- a/lvgl_tft/ssd1680.c +++ b/lvgl_tft/ssd1680.c @@ -213,13 +213,16 @@ void ssd1680_set_px_cb(lv_disp_drv_t * disp_drv, uint8_t* buf, BIT_CLEAR(buf[mirrored_idx], 7 - bit_index); } #elif defined (CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE) - byte_index = y + ((x >> 3) * EPD_PANEL_HEIGHT); - bit_index = x & 0x7; - - if (color.full) { - BIT_SET(buf[byte_index], 7 - bit_index); + /* mirrored index */ + uint16_t mirrored_idx = (EPD_PANEL_HEIGHT - x) + ((y >> 3) * EPD_PANEL_HEIGHT); + byte_index = x + ((y >> 3) * EPD_PANEL_HEIGHT); + bit_index = y & 0x7; + /* 1 means white, 0 means black */ + /* note that the bit index is inverted in place */ + if (color.full == 0) { + BIT_SET(buf[mirrored_idx - 1], 7 - bit_index); } else { - BIT_CLEAR(buf[byte_index], 7 - bit_index); + BIT_CLEAR(buf[mirrored_idx - 1], 7 - bit_index); } #else #error "Unsupported orientation used"