ducalex / retro-go

Retro emulation for the ODROID-GO and other ESP32 devices
GNU General Public License v2.0
489 stars 114 forks source link

ST7789 Display Driver support? #112

Closed tomvanbraeckel closed 3 weeks ago

tomvanbraeckel commented 3 weeks ago

I would like to add support for the Fri3D Camp 2020/2022 and 2024 badges, which both use the wildly popular ST7789V display driver. The 2022 has 240x240 pixels while the 2024 edition has a 240x296 display.

Initially, I thought this isn't supported by retro-go at all because:

But digging deeper, it seems that there was a mention of ST7789 in the esplay-s3 support (commit a85bcf7b1954e5c840e1b007e8c4bb39b91a649c had "#define RG_SCREEN_TYPE 4 // 4 = ESPLAY-ST7789V2") and I started to suspect that these ILI9341_CMD commands just have an ILI9341-specific name for historical reasons but actually are used to initialize several different display drivers.

I couldn't find much info on that esplay-s3 or esplay-esp32-s3 device itself other than this obscure reference which does mention the ST7789. I did find the ESPlay micro V2 but that's an ILI9341.

So I was wondering, could you please help me clarify which configurations are made for which display drivers? It looks like that info got a bit lost in the refactoring of the above commit.

My goal is to know which ones are likely to work with my ST7789V display driver, or at least to use as a starting point. Thank you!

ziesto commented 3 weeks ago

Hi. I'm using ST7789 display and it works perfectly fine. Here is the changes I made to make it works:

You need to modify components/retro-go/targets/ file: [-] ILI9341_CMD(0x36, (0x20 | 0x80 | 0x08)); / Memory Access Control / \ [+] ILI9341_CMD(0x36, (0x00 | 0x00 | 0x08)); / Memory Access Control / \ [+] ILI9341_CMD(0x21, 0x80); / Invert colors / \

ILI9341_CMD(0x26, 0x01); / Gamma curve selected / \ [-] ILI9341_CMD(0xE0, 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, 0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00); \ [-] ILI9341_CMD(0xE1, 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, 0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F); [+] ILI9341_CMD(0xE0, 0xD0, 0x00, 0x05, 0x0E, 0x15, 0x0D, 0x37, 0x43, 0x47, 0x09, 0x15, 0x12, 0x16, 0x19); \ [+] ILI9341_CMD(0xE1, 0xD0, 0x00, 0x05, 0x0D, 0x0C, 0x06, 0x2D, 0x44, 0x40, 0x0E, 0x1C, 0x18, 0x16, 0x19);

image

That's it.

Also in my case I needed to rotate display, so I added this line: [+] ILI9341_CMD(0x36, (0x48 | 0xC0)); / Rotate screen / \

tomvanbraeckel commented 3 weeks ago

Woah that's freaking amazing! Thanks for the quick reply! Now I can't wait to try it out!

If I get it all working nicely, I should submit a pull request to have the Fri3D Camp badge in its own components/retro-go/targets folder.

Thanks again!