How to detect LCD

Viewed 17 times

A rPi3 B+ is Raspbian configured with a 3.5 Waveshare touch display HAT.

There are two commands that toggle between the HDMI output and the HDMI output.

git clone https://github.com/waveshare/LCD-show.git
cd LCD-show
./LCD35-show #reboots device and directs video to LCD
./LCD-hdmi   #reboots device and directs video to HDMI port 

The desired boot algorithm \ script is:

if LCD is detected
   if LCD-hdmi flag is true (Video currently configured for HDMI)
      set LCD-hdmi flag false
      set LCD35-show flag true
      execute ./LCD35-show  #reboot with LCD Driver
else if LCD is not Detected 
   if LCD35-show  flag is true (Video currently configure LCD display)
      set LCD35-show flag false
      set LCD-hdmi flag true
      execute ./LCD-hdmi    #reboot with HDMI driver

flags must be persistent (survive reboots).

How can the display be detected from the command line? Bonus round: complete the script.

  • (1) Do you mean to translate from python to bash? (2) Does this python statement work? “execute ./LCD-hdmi”? (3) WaveShare tells you how to toggle, but not to detect. Perhaps use SPI read to “ping” the ILI9486 LCD References: (a) Waveshare toggle between_LCD_and_HDMI_display waveshare.com/wiki/… (b) Artillery [ILI9341] 3.2″ LCD Touch Screen White Display and Driver Problem raspberrypi.stackexchange.com/questions/104600/…. Cheers. – tlfong01 1 hour ago    
  • Yes, if not using spi to ping the LCD, alternative is to Rpi GPIO command to write to GPIO pin of back lit to check the “white screen” (See my last reference above). Good luck. Cheers. – tlfong01 1 hour ago   
  • @tlfong01 Good to hear from you again. I was able to manually toggle screen output between the HDMI and touch display using BASH commands described in the OP. It would probably be simpler to keep everything in a BASH script that starts at boot time (if Python is required to perfom the task then that is fine). The first key step is to interrogate the GPIO to determine if the display is / is NOT present. You may recall from my other posting, that I am interested in building a thermostat with relays – gatorback 1 hour ago
  • @tlfong01 Can you write up an example in an Answer as to how you would ping the LCD? Thank you – gatorback 1 hour ago
  • Ah let me suggest how your can do it. (1) Find the device datasheet, and the register of the config register, or any register you can read the default contents, (2) Read that register using PSI read. If you can read what you expect, then the device is working. (3) The LCD controller chip I played with in the reference above is ILI9341. Yours might be ILI9486. (4) Let me see if I can find an example program. – tlfong01 16 mins ago   
  • I searched my junk bin and found the following SPI test program. (1) One ping device example is to SPI read the ADXL345’s ID register which has default ID byte “0x45”. I do have a couple of other examples in my answers to similar questions. My answers there are “pl;ug and play” and more or less newbie proof. This time my quick and dirty example is for ninjas: (1) penzu.com/p/926a24f6. The relevant function are sample outputs are towards the end, and highlighted in bright red. – tlfong01 6 mins ago   
  • (1) penzu.com/p/926a24f6. The sample output of reading ADXL345 ID Reg getting the ID byte 0x5e” is at the very top of the file, and the ping ADXL345 ID register function is towards the end, just now highlighted in bright red. Happy very long program listing reading ! Cheers.. – tlfong01 just now   Edit   

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: