Uncategorized

How to detect LCD

Asked 
Viewed 21 times
1

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 2 hours 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 2 hours 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 2 hours ago
  • @tlfong01 Can you write up an example in an Answer as to how you would ping the LCD? Thank you – gatorback 2 hours 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 1 hour 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 1 hour 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 1 hour ago   
  • My file above actually has another example of “pinging” the MCP3008/MCP3208. It uses the “read back after write” a register (SPI loopback 3 bytes,not necessary the ID register which has none). In this case, I just do the real MCP3008 ADC operation, and see if results is not zero. Cheers. Reference: Chat Record on How to Ping MCP3008/MCP3208″: chat.stackexchange.com/rooms/102745/…. – tlfong01 53 mins ago    
  • And this is the newbie friendly version of “How to ping MCP3xx2/4/8 ADC chips: penzu.com/p/79948cde, as discussed in the chat above. – tlfong01 40 mins ago    

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 )

Google photo

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

Twitter picture

You are commenting using your Twitter 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: