lvgl_esp32_drivers icon indicating copy to clipboard operation
lvgl_esp32_drivers copied to clipboard

Allow little-endian for ST7789

Open jhnlmn opened this issue 3 years ago • 3 comments

I found that I can insert {ST7789_DISPON, {0}, 0x80}, //existing line #if LV_COLOR_16_SWAP == 0 // Test: enable little endian. {ST7789_RAMCTRL, {0, 8}, 2}, // Test: enable little endian. #endif //DL: enable little endian. {0, {0}, 0xff}, //existing line to st7789_init_cmds in st7789.c and now I can build with CONFIG_LV_COLOR_16_SWAP=n and make LVGL code 500 bytes smaller and more efficient.

Note that ST7789VW doc says "Note: Little Endian only can be supported in 65K 8-bit and 9-bit interface.", so this trick may not work for everyone, but it seem to work for me (I am using SPI, of course).

Also, it will be nice to remove "static" from "static void st7789_send_cmd(uint8_t cmd)" and "static void st7789_send_data(void * data, uint16_t length)" so I can experiment with register programming from my own code.

Thank you

jhnlmn avatar May 06 '21 23:05 jhnlmn

Hi, I will try to add support for it and remove the static from the functions so you can add custom configuration, this weekend I might be free.

C47D avatar May 07 '21 00:05 C47D

I've pushed the branch st7789_expose_cmd_api where st7789_send_cmd and st7789_send_data are available outside st7789.c, can you test it?

C47D avatar May 10 '21 02:05 C47D

Yes I added #if LV_COLOR_16_SWAP==0 //CONFIG_LV_COLOR_16_SWAP=n is more efficient for little endian platforms st7789_send_cmd(ST7789_RAMCTRL); st7789_send_data( (uint8_t[]) {0, 8}, 2); #endif to guiTask in main.c and it works OK for both CONFIG_LV_COLOR_16_SWAP=n and CONFIG_LV_COLOR_16_SWAP=y I recommend CONFIG_LV_COLOR_16_SWAP=n

  • code is smaller and more efficient.

Also, I suggest you add #if LV_COLOR_16_SWAP == 0 {ST7789_RAMCTRL, {0, 8}, 2}, #endif to st7789_init

jhnlmn avatar May 18 '21 06:05 jhnlmn