Page History: Multiple LCD panel displays
Compare Page Revisions
Page Revision: 2017/08/08 09:54
MMBasic on the Micromite can natively drive a number of common LCD panel types, these can really bring a spark of panache to a project and are cheaply available on electronics components outlets/tat-bazaars at around the £5 (US$6, AU$8, e6) mark.
I have a requirement for such a display but it needs to be long rather than big due to restrictions on the space available. I decided to try stacking two 2.8" colour TFTs side by side, but would it be possible to drive them from a single Micromite?
In the breadboard knock-up, I handle the CS pins of each display individually. This requires two extra outputs and the code switches to the relevant display immediately before doing anything on it.
Here is a small
video of the below code in action on a breadboard with a Micromite MkII 44pin.
Currently the displays are quite simplistic as this is only a proof of concept. I took the familiar test program from the Micromite manual and tweaked it to hold the relevant switching and some additional scribble to demonstrate the displays are independent, but it is essentially the same. Really, there is no practical limit to the number of LCDs you could drive in this way.
The Micromite needs to have the LCD options set at the command prompt as usual and the program initialises each of the LCD panels with the GUI RESET command so they play nicely. I also tied the LCD reset pins to VCC to prevent the GUI RESET commands fighting. You would probably be better off tying them to the master reset or to another output pin and controlling them manually too. This does mean that the reset pin designated in the in the OPTION LCDPANEL command (19 in this case) is sterilised from use so choose a mundane pin with low features. MMBasic has no idea that its "goal-posts" are being moved - this is likely to interfere with the more complex LCD Panel stuff like buttons etc.
If you are careful with the CS activity, there is no reason to lose any functionality - even when reading from the panels - MISO is tri-stated by the slave(s) until CS goes lo (make sure you don't have both lo simultaneously) but you should be able to read from the displays too - even BLIT commands should work but I am yet to try. To minimise the control pins, you can use a simple selector and a single hi/lo selector for the displays as shown below. This could be expanded very easily to 16 displays(!) with something like a 74HC154.
Update: This method and the below prog do not work at 10MHz or less. The first display initialises and then the 'mite hangs (haven't worked out why, probably timing but as I don't need a slow device it isn't a problem - for me @48MHz ;) so I most likely won't be putting too much effort into solving this. It works fine at 20MHz and the current consumption measured on an inline USB thingie (with LCD backlight power feed through a 100R resistor to both) is 40mA at 48MHz droping to 20mA at 20MHz
' set the display properties at the command prompt:
' OPTION LCDPANEL ILI9341, orientation, D/C pin, reset pin [,CS pin]
' OPTION LCDPANEL ILI9341,RL,15,19,21
Dim n As Integer
SetPin 23,dout: Pin(23)=1 ' set both CS HI
SetPin 24,dout: Pin(24)=1
Pin(23)=0:GUI reset lcdpanel:Pin(23)=1)' reset each display in turn CS LO -> RESET -> CS HI
Pin(24)=0:GUI reset lcdpanel:Pin(24)=1)
'Const DBlue = RGB(0, 0, 128) ' A dark blue colour
Colour RGB(white), RGB(BLACK) ' Set the default colours
Font 1,2 ' Set the default font
Do
For n=23 To 24 ' easy way to get the CS pins for each display
Pin(n)=0 ' CS LO
'draw some stuff
Box 0, 0, MM.HRes-1, MM.VRes/2, 3, RGB(RED), RGB(Rnd*128,Rnd*128,Rnd*128)
Text MM.HRes/2, MM.VRes/4, Time$, "CM" , 1, 4, RGB(CYAN), DBlue
'Text MM.HRes/2, MM.VRes*3/4, "Disp"+Str$(n-22)+" "+Date$, "CM"
Text Rnd*320, Rnd*240, "Disp"+Str$(n-22)+" "+Date$
Circle Rnd*320,Rnd*240,Rnd*100
Box Rnd*320,Rnd*240,Rnd*320,Rnd*240,3, RGB(Rnd*128,Rnd*128,Rnd*128)
Pin(n)=1' CS HI
Next
Loop