Inverted ILI9341 IPS screen

I recently designed my own board based on the usual ESP32 + ILI 240x320 touch. When buying the bare display (one without the PCB and header pins) I had the choice between “normal” and “IPS” displays. So I ordered the IPS aóne as these usually have a superior image.

The display worked fine out of the box but the colors were inverted. I have seen this with cheap R-Pi display addons as well.

One solution is to use the “invert display” command (0x21) to the ili9341 to adjust for this inversion right after calling the constructor:

disp = ili9341(miso=......)  # call constructor as usual
disp.send_cmd(0x21);   # send "invert display" command

The resulting image has the correct colors and looks indeed significantly better than the normal non-IPS displays.

Thanks for the tip @Till_Harbaum!

It makes sense to add this as an optional argument to ili9XXX constructor, instead of explicitly calling send_cmd.
If you want, you can open a PR.

I would usually say “yes,of course”.

But in this case … why would want an option for that? You’d barely reduce the code required in the application. After all the single send_cmd is only a few characters. Plus you’d increase the size of the ili9xxx which isn’t wanted in an embedded project. And finally this should then be implemented for the ili9488 as well for consistency which I simply don’t own.

It’s a usability thing.
One of the goals of Micropython is to provide a quick and easy development experience.

Suppose a user sees inverted colors. The first thing he’ll do is go over the arguments he provided to the display driver to see if he missed anything. If “invert_colors” appears there he would try it out.
On the other hand if there is no “invert_colors” option, then he’d start looking at forums, display datasheet etc.

You are right that it would increase the driver size, but I think this increase is negligible. Going that path, there could be lots of other micro-optimizations I could do in the driver to make it smaller and less convenient for use.
But when a user selects Micropython over C, that means he prefers a user friendly and interactive development experience that could shorten the development time and effort, at the expense of some RAM and performance.

Doesn’t have to.
You can implement this for ili9341 only.
btw, looking at ili9488 datasheet it looks like the command is the same there.
I don’t own ili9488 either but I would still add it to both if the datasheet looks the same for that command.