pythoncoder wrote: ↑Wed Jan 27, 2021 8:43 am
My view is that RA8875 is the best solution for large, touch sensitive displays. Its one drawback is that it isn't particularly fast: a complete redraw of complex screens with a lot of elements (like my keyboard demos) is not visually instantaneous.
If speed is crucial you'll find a solution based on SSD1963 and XPT2046
here. It uses a parallel interface and highly optimised code courtesy of @roberthh, but inevitably that means it uses a lot of pins. And it's Pyboard only, where my other drivers are cross-platform.
The other option is to assess whether you really need such a big display. The official LCD160CR has a factory calibrated touch overlay and with careful design can display a good deal of information: see
this repo. The touch GUI allows for nested screens which enhances this.
Lastly, if you don't need touch,
nano-gui supports a good many smaller displays up to (at a pinch) ILI9341. But the buffer is 34K even with 4-bit pixels. Note the monochrome ePaper displays that have quite a lot of pixels with a small frame buffer (1 bit per pixel).
There is quite a lot of choice.
You have done excellect job with drivers! I try to adapt best practises to my code.
First try with your example I had no success.
I have to learn more about what goes wrong with memory allocation ...
REPL:
Code: Select all
Ignoring framebuf_utils.mpy: compiled for incorrect architecture.
Traceback (most recent call last):
File "main.py", line 674, in <module>
File "drivers/ili93xx/ili9341.py", line 58, in __init__
MemoryError: memory allocation failed, allocating 38400 bytes
MicroPython v1.13 on 2020-09-02; ESP32 module with ESP32
Type "help()" for more information.
main.py
Code: Select all
from drivers.ili93xx.ili9341 import ILI9341 as SSD
from gui.core.nanogui import refresh
...
665:height = 240
666:
667: pdc = Pin(TFT_DC_PIN, Pin.OUT, value=0) # Arbitrary pins
668: pcs = Pin(TFT_CS_PIN, Pin.OUT, value=1)
669: prst = Pin(TFT_RST_PIN, Pin.OUT, value=1)
670: # Hardware SPI on native pins for performance. Check DRIVERS.md for optimum baudrate.
671: spi = SPI(TFT_SPI, baudrate=10000000, sck=Pin(TFT_CLK_PIN), mosi=Pin(TFT_MOSI_PIN), miso=Pin(TFT_MISO_PIN))
672: gc.collect()
673: # ssd = SSD(spi, pcs, pdc, prst, height=height) # Must specify height for SSD1351
674: ssd = SSD(spi, pcs, pdc, prst) # The other Adafruit displays use defaults
675: # On st7735r 1.8 inch display can exchange height and width for portrait mode. See docs.
676: # The 1.44 inch display is symmetrical so this doesn't apply
677:
678:
679: refresh(ssd, True) # Initialise and clear display.
680: # Uncomment for ePaper displays
681: # ssd.wait_until_ready()
682: ssd.fill(0)
683: ssd.line(0, 0, ssd.width - 1, ssd.height - 1, ssd.rgb(0, 255, 0)) # Green diagonal corner-to-corner
684: ssd.rect(0, 0, 15, 15, ssd.rgb(255, 0, 0)) # Red square at top left
685: ssd.rect(ssd.width -15, ssd.height -15, 15, 15, ssd.rgb(0, 0, 255)) # Blue square at bottom right
686: ssd.show()
and in the ili9341.py
Code: Select all
...
57: gc.collect()
58: buf = bytearray(self.height * self.width // 2)
Update:
I tried with IDFv3 and IDFv4, same result. In ili9341.py I changed from time import sleep_ms to utime, and then memory allocation error is only 4xx bytes, but still does not work. I commented out @micropython.viper and I tried to understand def _lcopy(dest: ptr8, source: ptr8, lut: ptr8, length: int): meaning, because I do not see from where ptr8 shall inherit from.