How to make GRAM OFFSETs

Hi

I have LH114T display. It is work fine on TFT_eSPI.
But the image is shifted if i use lvgl.
How to adjust the offsets? just as it is done in the library for Arduino

#ifdef CGRAM_OFFSET
tft_settings.r0_x_offset = colstart;
tft_settings.r0_y_offset = rowstart;

Please send a screen shot about a working and a wrong screen.

II use this one


and

Why don’t you set the offsets to 0?

Where can i set the offsets in littlevg. I did not find this opportunity

I think this is part of your display driver, not LittlevGL.

but However, LittlevGL has a driver for this display

I would love to set the offsets myself, but I don’t know which file I should edit

I think @Carlos_Diaz knows; he seems to be an expert with the ESP32 stuff. :slightly_smiling_face:

hi @Carlos_Diaz please help me

Hi @Denis_Barinov,

Do you need to add offsets to the coordinate where lvgl draws the image?
I’ve checked the library (https://github.com/nopnop2002/esp-idf-st7789) and they add the offset (_offsetx and _offsety) when drawing:

void lcdDrawPixel(TFT_t * dev, uint16_t x, uint16_t y, uint16_t color){
	if (x >= dev->_width) return;
	if (y >= dev->_height) return;

	uint16_t _x = x + dev->_offsetx;
	uint16_t _y = y + dev->_offsety;

	spi_master_write_command(dev, 0x2A);	// set column(x) address
	spi_master_write_addr(dev, _x, _x);
	spi_master_write_command(dev, 0x2B);	// set Page(y) address
	spi_master_write_addr(dev, _y, _y);
	spi_master_write_command(dev, 0x2C);	//	Memory Write
	spi_master_write_data_word(dev, color);
}

I don’t have any display to test it right now but I think you need to edit st7789_flush function (available here: components/lvgl_esp32_drivers/lvgl_tft/st7789.c):

void st7789_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
{
    uint8_t data[4] = {0};

    /* You will need to calculate the offset by hand */
    area->x1 = offsetx;
    area->x2 = offsetx;
    area->y1 = offsety;
    area->y2 = offsety;

    /*Column addresses*/
    st7789_send_cmd(ST7789_CASET);
    data[0] = (area->x1 >> 8) & 0xFF;
    data[1] = area->x1 & 0xFF;
    data[2] = (area->x2 >> 8) & 0xFF;
    data[3] = area->x2 & 0xFF;
    st7789_send_data(data, 4);

    /*Page addresses*/
    st7789_send_cmd(ST7789_RASET);
    data[0] = (area->y1 >> 8) & 0xFF;
    data[1] = area->y1 & 0xFF;
    data[2] = (area->y2 >> 8) & 0xFF;
    data[3] = area->y2 & 0xFF;
    st7789_send_data(data, 4);

    /*Memory write*/
    st7789_send_cmd(ST7789_RAMWR);

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

    st7789_send_color((void*)color_map, size * 2);
} 

Once you find the right offset I will need to add it to the menuconfig (similar to the nopnop2002 repo), please let me know if that helps.

Regards
Carlos

thanks you, it is working

Great, I will think about adding the offset option to the menuconfig.

yes, it is great idea
i can test

also in the port for esp32 is the old version of the littlevgl (6.0.0), it cannot make lines thicker than 4 pixels

Great, i will let you know when i do it, thanks.

I think we were using 6.1 or something, I’m not sure, I can’t update it to v7 because it’s not released yet, I will try to get it update to the latest v6

Regards