russhughes / ili9342c_mpy

ILI9342C Fast 'C' Driver for MicroPython (M5Stack Core)
Other
48 stars 13 forks source link

Support for ILI9341 #5

Closed klaasbrant closed 2 years ago

klaasbrant commented 2 years ago

Thanks for the great mpy extensions for ST7789 and ILI9342. They are great! The ILI9342 also works on ILI9341 displays which are almost identical. The difference is they are 240x320 and not 320x240, the colors are inverted and your rotation modes are flipped, so mirror modes an normal modes are reverse: 1-4 <-> 5-8 So with this in mind the following will work on a ili9341:

def main():

spi = SPI(
    2,
    baudrate=60000000,
    sck=Pin(18),
    mosi=Pin(23))

# initialize display

tft = ili9342c.ILI9342C(
    spi,
    240,
    320,
    reset=Pin(33, Pin.OUT),
    cs=Pin(26, Pin.OUT),    
    dc=Pin(5, Pin.OUT),
    rotation=5)

tft.init()
tft.inversion_mode(False)
tft.rotation(5)
tft.fill(ili9342c.BLACK)
row = 0
tft.write(font, "abcdefghijklmnopqrstuvwxyz", 0, row)
row += font.HEIGHT
tft.fill_rect(0, row, 100, 100, ili9342c.RED)

Would it be possible to solve this in an elegant way? e.g. pass as parameter to init? Or even better merge the ST7789 and ILI9342 into one DISPLAY extension that servers all 3 types?

If you want I can give you a hand.

Have you ever looked at the mpy fork from Loboris and his display implementation? (see https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/display ). Many people love the loboris fork but it now outdated and he abandoned the project. Loboris stuff is not easy to update and also it is near to impossible to extract stuff from it. His implementation is more a less a separate port for esp32

russhughes commented 2 years ago

I'm working on supporting the displays with a single code base by adding additional init parameters and using configuration classes or modules for each display.

klaasbrant commented 2 years ago

That is good news. I will, for myself, create a wrapper class in python for now. Let me know if I can be of help in e.g. testing. Closing the "issue".