User Tools

Site Tools


mmbasic:multiple_lcd_panel_displays

Multiple LCD panel displays

MMBasic on the Micromite can drive many 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 had 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 - the CS pin described in the LCD setup becomes sacrificed and un-used(able).

Here is a small video of the below code in action on a breadboard with a Micromite MkII 44pin.

As shown in the vid, 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 or the data you display in this way.

The Micromite needs to have the LCD options set at the command prompt as usual and the program initializes 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. This does mean that the reset pin designated in the in the OPTION LCDPANEL command (19 in this case) is sterilized from use (as well as CS) 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 have not tried as my requirement is simple display only.

Remember MMBasic speed restrictions i.e. it is not possible to drive any panel at a CPU speed of 10MHz or less.

' 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

  Pin(23)=1:SetPin 23,dout ' set both CS HI
  Pin(24)=1:SetPin 24,dout

  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 random stuff just to show the displays are independent
      Box 0, 0, MM.HRes-1, MM.VRes/2, 3, RGB(RED), RGB(Rnd*128,Rnd*128,Rnd*128)

      'show date and time on each display
      Text MM.HRes/2, MM.VRes/4, Time$, "CM" , 1, 4, RGB(CYAN), DBlue      
      Text Rnd*320, Rnd*240, "Disp"+Str$(n-22)+" "+Date$

      'more random stuff
      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
mmbasic/multiple_lcd_panel_displays.txt · Last modified: 2024/01/19 09:30 by 127.0.0.1