Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disp_drv.rotated not working with ST7735 driver #3

Open
Lisa999 opened this issue Dec 18, 2020 · 5 comments
Open

disp_drv.rotated not working with ST7735 driver #3

Lisa999 opened this issue Dec 18, 2020 · 5 comments

Comments

@Lisa999
Copy link

Lisa999 commented Dec 18, 2020

The problem is that the ST7735 display is 160x128 pixels.
So if you set:

  • Landscape during compile time
  • disp_drv.rotated = 1 in the code
  • Swap display width and height in the code
  • Call the ST7735 rotation function for a hardware rotate

It still is not working in portrait mode. The upper 128 pixels are working in portrait mode, the bottom 32 pixels are not functioning at all (pixel noise).
I suspect the LVGL driver code is still thinking that the height is 128 pixels, despite the rotated setting.

Maybe because of this code in LV_CONF.H ?
#define LV_VER_RES_MAX (CONFIG_LVGL_DISPLAY_HEIGHT)

pixelnoise

Little log:
D (00:00:02.871) screen: LVGL Width: 128 , Height 160
I (00:00:02.879) lvgl_helpers: Display hor size: 160, ver size: 128
I (00:00:02.880) lvgl_helpers: Display buffer size: 6400
I (00:00:02.890) lvgl_helpers: Initializing SPI master for display
I (00:00:02.892) lvgl_helpers: Configuring SPI host VSPI_HOST (2)
I (00:00:02.898) lvgl_helpers: MISO pin: -1, MOSI pin: 23, SCLK pin: 18
I (00:00:02.910) lvgl_helpers: Max transfer size: 12800 (bytes)
I (00:00:02.912) lvgl_helpers: Initializing SPI bus...

@C47D
Copy link
Collaborator

C47D commented Dec 20, 2020

Hi,

You're right, the drivers code were developed without taking in consideration the rotated field. We're about to move the drivers code into its own repository. You can find it here.

After merging that repo I will try to update the drivers orientation code.

@Lisa999
Copy link
Author

Lisa999 commented Dec 20, 2020

void st7735s_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
{
uint8_t data[4];
ESP_LOGD(TAG, "Flush, Portrait mode: %u, width: %u , height %u", drv->rotated, drv->hor_res, drv->ver_res);

/*Column addresses*/
st7735s_send_cmd(ST7735_CASET);
data[0] = (area->x1 >> 8) & 0xFF;
data[1] = (area->x1 & 0xFF) + (drv->rotated ? COLSTART : ROWSTART);
data[2] = (area->x2 >> 8) & 0xFF;
data[3] = (area->x2 & 0xFF) + (drv->rotated ? COLSTART : ROWSTART);
st7735s_send_data(data, 4);

/*Page addresses*/
st7735s_send_cmd(ST7735_RASET);
data[0] = (area->y1 >> 8) & 0xFF;
data[1] = (area->y1 & 0xFF) + (drv->rotated ? ROWSTART : COLSTART);
data[2] = (area->y2 >> 8) & 0xFF;
data[1] = (area->y1 & 0xFF) + (drv->rotated ? ROWSTART : COLSTART);
st7735s_send_data(data, 4);

/*Memory write*/
st7735s_send_cmd(ST7735_RAMWR);

uint32_t size = lv_area_get_width(area) * lv_area_get_height(area);

st7735s_send_color((void*)color_map, size * 2);

}

@Lisa999
Copy link
Author

Lisa999 commented Dec 20, 2020

Ditch st7735s_portrait_mode var, totally unnecessary...

@Lisa999
Copy link
Author

Lisa999 commented Dec 20, 2020

Wrong:
uint8_t data[] = {0xC8, 0xC8, 0xA8, 0xA8};
Right:
uint8_t data[] = {0xC0, 0x00, 0x60, 0xA0};

@C47D C47D transferred this issue from lvgl/lv_port_esp32 Dec 20, 2020
C47D pushed a commit that referenced this issue Mar 29, 2021
martinberlin referenced this issue in martinberlin/lvgl_epaper_drivers May 30, 2021
martinberlin referenced this issue in martinberlin/lvgl_epaper_drivers May 30, 2021
@martinberlin
Copy link

Sorry for last two mentions, I didn’t intend too, never though from a fork the parent repo issues are touched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants