rdagger / micropython-ili9341

MicroPython ILI9341Display & XPT2046 Touch Screen Driver
MIT License
194 stars 40 forks source link

Q: Support for ESP S3 BOX? #13

Closed jouellnyc closed 1 year ago

jouellnyc commented 1 year ago

Howdy. I noticed the esp32_s3_box has an ili9342c based display:

https://github.com/espressif/esp-box/blob/master/docs/hardware_overview/esp32_s3_box/hardware_overview_for_box.md

Clearly, that is different from an ili9341 and was not intended for that usage.

But, being curious, I tried.

I can use this repo and write to the screen but it comes out as a mirror image and write down the screen instead of across. What I am uncertain of is there would be support for the ili9342c/esp32_s3_box?

I've tried other repos w/o success using the esp32_s3_box and micropyton, so figured I'd toss the Q out there.

Thanks in advance!

rdagger commented 1 year ago

I don't have an ili9342c. I took a quick look at the datasheet and it does look similar. The issues you're having are probably due to differences in the MADCTL register (memory access control). You may be able to just modify the ROTATE constants. Currently my library uses:

    ROTATE = {
        0: 0x88,
        90: 0xE8,
        180: 0x48,
        270: 0x28
    }

I'd really need the display to know for sure but the following values may work: <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">

Rotation | Hex | Binary -- | -- | -- Portrait | 0x08 | 0b0000 1000 Landscape | 0x68 | 0b0110 1000 Inverted Portrait | 0xC8 | 0b1100 1000 Inverted Landscape | 0xA8 | 0b1010 1000 Portrait Mirrored | 0x48 | 0b0100 1000 Landscape Mirrored | 0x28 | 0b0010 1000 Inverted Portrait Mirrored | 0x88 | 0b1000 1000 Inverted Landscape Mirrored | 0xE8 | 0b1110 1000

So the new constants would be:

    ROTATE = {
        0: 0x08,
        90: 0x68,
        180: 0x88,
        270: 0xE8
    }

There could be other changes too. Again, it's very difficult without having a display to test.

jouellnyc commented 1 year ago

Oh Wow!. That's really super!

I played around with the values you suggested. If I set rotation=0 and

ROTATE = {
        0: 0xC8,
        90: 0xA8,
        180: 0x48,
        270: 0x28
    }

and also:

width=320
height=240

everything works perfectly, really. I can read from left to right, the screen is filled perfectly and colors are crisp!

Not to exclude this fact, but I can use the real RGB values for color565(). (For reference, withe esp s3 lite box, they were basically inverted)

So, in summary, it works perfectly. Wow and thank you so much!

(My email is on my profile. If you were to send your address, I am only too happy to send you an S3 Box for you to use/test)

rdagger commented 1 year ago

Thanks, I appreciate the offer! Unfortunately, I'm not able to take on any new projects right now.

jouellnyc commented 1 year ago

Sure thing, I should have explicitly said there are no expectations. I.E it was purely a thank you and offer stands. (I had been at road block on my project and now there is a green light again). Many thanks and virtual high five!!