I've run into a problem with the optimized ILI9341 driver implementations by Paul S. and Kurt E.
The issue is this: Reading from the display can't be done with a const class reference because the methods like readRect() are not marked const, which creates some encapsulation issues.
It's also a show stopper for me for reasons - long story that doesn't bear explaining here.
Unfortunately the way the drivers are implemented it is not possible to make them const.
The reason being is that the SPI class and related is held around with the class instance instead of a separate static class.
You'll perhaps note that TFT_eSPI does const reads and is implemented with a class that looks like a normal class, but is actually backed by all static member fields.
That itself creates a disadvantage in that you can't have two instances of the TFT_eSPI class, so driving multiple displays is problematic.
There's a way to have the best of both worlds here. The way to do it is to create a static template class whose arguments are the SPI host # to use (0, 1, or 2 on the Teensy 4.1 for example, for SPI, SPI1, and SPI2) and the CS pin #. That way all the static fields are specific to the template instantiation, and thus allowing you multiple instances as long as each one is on its own CS line.
You then reference that static class from your instance class.
I've done almost all this, and made a proof of concept here: https://github.com/codewitch-honey-c...teensy_gfx.hpp
It implements a driver for htcw_gfx, not the ILI9341_t3 API, but it should illustrate the concept.
The trouble is, this sketch doesn't work. It fills the screen with purple (like it's supposed to), but then waits a bit, then reboots with no dump to serial instead of displaying the font.
The trouble almost has to be in the teensy_tft_spi_driver<> template class, because the actual driver that uses it is fairly straightforward, and I've implemented it many times, just not for the teensy.
Here's what I'd love to see:
The ILI9341_t3n driver refactored such that it can do const reads.
And/or
A correction to my code to fix the issue with it. I can't find the problem for the life of me.
I know this is asking a lot, but I figured I'd shoot the moon here and maybe get lucky.![]()