driver for 3.5inch RPi LCD (A) ili9486 + pbm display on nucleo-f746 #10404
Replies: 10 comments 2 replies
-
That driver looks good. Have you tested it with |
Beta Was this translation helpful? Give feedback.
-
my filesystem size is 80k - could not do a full install of nano_gui... refresh cleared the screen to black and the final output is this: you are welcome to use any of the above code |
Beta Was this translation helpful? Give feedback.
-
Thank you. The test result looks spot-on. A few queries.
|
Beta Was this translation helpful? Give feedback.
-
removed the 3 gamma setup lines and can not tell any difference in the output |
Beta Was this translation helpful? Give feedback.
-
First the good news. Your driver works fine with nano-gui (and hence cwriter) and probably works with micro-gui. Alas I don't understand why it works. The code doesn't conform with the device datasheet, particularly in regard to the zero padding. This is invalid for an SPI connected device. I have rewritten the driver to conform with the datasheet. It now supports landscape, portrait and upside-down modes. It has been tested with the above GUI's. To run micro-gui I used frozen bytecode to conserve RAM: in that mode it runs with about 75K free. There is a peculiarity of this chip. I started out by trying to adapt your driver, replacing non-conformant code. Portrait mode worked readily, but for landscape mode I had to include a single line derived from your driver: self._wcd(b'\x2a', b'\x00\x00\x00\x00\x00\x01\x00\xdf') Your driver executes this after computing the The published version runs the chip in portrait mode using only legal code. The rotation to support landscape mode is done in Viper. |
Beta Was this translation helpful? Give feedback.
-
what display are you testing with? my understanding is that this display implements the spi bus as the input to cascaded shift registers (16 bits). register writes are 8 bits, hence the padding. the above command is effectively write(b'\x2a', b'\x00\x00\x01\xdf'). maybe this makes sense... |
Beta Was this translation helpful? Give feedback.
-
I am using exactly the same display. Do you have a schematic for the board or other authoritative documentation? On the face of it there seems to be no reason to modify the chip's SPI interface. I agree that your assertion is backed up by the line I cited. But the contrary evidence is that, in portrait mode, my driver works on the basis of 8-bit data. In particular if register numbers are 16 bit, my version should fail, but if they are 8-bit yours should. The fact that both drivers work has me baffled. I can only think that the chip, however it is being driven, is remarkably tolerant. |
Beta Was this translation helpful? Give feedback.
-
not a smoking gun, but: 2ea 74hc4094 shift registers on lcd carrier pcb. lcd connector pin 23 (sck) is routed to the clock input on both shift registers and from the luma.lcd repo file, starting line 787
|
Beta Was this translation helpful? Give feedback.
-
Your observation about the shift registers is persuasive. I wonder why they did it - perhaps the Pi can emit very high clock rates. I remain foxed by the fact that (to take two random lines) your self._wcd(b'\x00\x3a', b'\x00\x55')
self._wcmd(b'\x00\x2c') and my self._wcd(b'\x3a', b'\x55')
self._wcmd(b'\x2c') # WRITE_RAM both work. At one point I removed the zero padding throughout from addresses and data: portrait mode worked; for landscape mode the one line which required padding was the one I described above. Very puzzling. I have ordered an ILI9486 display from eBay which lacks this extra hardware. My driver needs to work with generic hardware. The fact that it also works with this board puts me in a dilemma: I guess I'll need to put a warning in the docs pointing users to this thread and your code... |
Beta Was this translation helpful? Give feedback.
-
I think I've figured out what's going on, but it's rather speculative. My guess is that the board's hardware issues a write pulse to the parallel interface under two conditions:
Commands with a single data byte will behave similarly, with the data byte ending up in the LSB whether or not it is padded. Commands with multi-byte data will fail unless the data is padded. The fact that padding is necessary implies that the chip expects to find successive data bytes in the LS byte. Mass transfers of image bytes use the full 16 bit width. My non-padded version works in portrait mode because the write to register self._wcd(b'\x2a', b'\x00\x00\x00\x00\x00\x01\x00\xdf') Practical takeaways from all this are:
I feel this all makes some sense now. Thanks for helping me with this. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
https://www.waveshare.com/wiki/3.5inch_RPi_LCD_(A)
datasheet:
https://datasheetspdf.com/datasheet/ILI9486.html
hacked up from pythoncoder's nano gui ili9341 driver
thanks @peterhinch
the bodmer, luma.lcd and juj repos were helpful:
https://github.com/Bodmer/TFT_eSPI/blob/master/TFT_Drivers/ILI9486_Init.h
https://github.com/rm-hull/luma.lcd/blob/master/luma/lcd/device.py
https://github.com/juj/fbcp-ili9341/blob/master/ili9486.cpp
8 bit writes require padding to 16 bits
no miso from lcd, write only - this seems to be a hw limitation on this waveshare implementation
touch screen shares spi bus and presumably works (no support in this code)
pbm display is close 😬
dogbert pbm files:
dogberts.zip
pulseview trace of spi startup sequence:
spi.zip
pulseview logic analyser:
https://sigrok.org/wiki/PulseView
main.py:
ili9486.py:
Beta Was this translation helpful? Give feedback.
All reactions