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.

gatorback
  • 637
  • 1
  • 6
  • 20
  • (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 https://www.waveshare.com/wiki/3.5inch_RPi_LCD_(A)#Toggle_between_LCD_and_HDMI_display

    (b) Artillery [ILI9341] 3.2" LCD Touch Screen White Display and Driver Problem

    https://raspberrypi.stackexchange.com/questions/104600/artillery-ili9341-3-2-lcd-touch-screen-white-display-and-driver-problem. Cheers.

    – tlfong01 Feb 03 '20 at 02:54
  • 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 Feb 03 '20 at 03:10
  • @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 Feb 03 '20 at 03:10
  • @tlfong01 Can you write up an example in an Answer as to how you would ping the LCD? Thank you – gatorback Feb 03 '20 at 03:12
  • 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 Feb 03 '20 at 04:06
  • 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) https://penzu.com/p/926a24f6. The relevant function are sample outputs are towards the end, and highlighted in bright red. – tlfong01 Feb 03 '20 at 04:16
  • (1) https://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 Feb 03 '20 at 04:22
  • 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": https://chat.stackexchange.com/rooms/102745/discussion-between-tlfong01-and-aubrey-champagne. – tlfong01 Feb 03 '20 at 04:36
  • And this is the newbie friendly version of "How to ping MCP3xx2/4/8 ADC chips: https://penzu.com/p/79948cde, as discussed in the chat above. – tlfong01 Feb 03 '20 at 04:48

0 Answers0