Raspberry Pi Official LCD Screen "or" HDMI Option
-
I have a Raspberry Pi 3 and an Official Raspberry Pi 7" LCD Screen running Retropie 4.1.3 updated over time..
Everything boots up and runs on the LCD no problem, but I would like the HDMI to have priority over the LCD when a HDMI cable is plugged in.EX:
No HDMI = Only LCD Screen
HDMI Plugged in = HDMI Screen and no LCD ScreenHow do I do this?
P.S. This is my first post :)
-
Hello,
I got a little script who can do this.
When raspberry boot, He check if a hdmi screen is connected and change config.txt with a spécific config.txt file. After this, he reboot the pi with the good config file.Note : when he check config.txt, the script check the string : "hdmi_drive=2" to see if you're in HDMI configuration and "lcd_rotate=2" for LCD configuration.
So, you must have hdmi_drive=2 in config_hdmi.txt and lcd_rotate=2 in config_lcd.txt.
You can also change the script.Note 2 : I use a different configuration of alsa when I use my LCD screen, so I do the same things with "/usr/share/alsa/alsa.conf". You can delete alsa instruction if you want.
You need 3 file :
- the script
- a config_hdmi.txt with hdmi configuration
- a config_lcd.txt with.. LCD configuration
Script :
#!/usr/bin/env bash #HDMI connection? rm -f hdmi.name tvservice -n 2>hdmi.name HDMI_NAME=`cat hdmi.name` echo $HDMI_NAME if [ "$HDMI_NAME" == "[E] No device present" ]; then LCD_ON=`cat /boot/config.txt | grep "hdmi_drive=2"` if [ $LCD_ON == "hdmi_drive=2" ]; then echo "reboot avec la configuration LCD" sudo rm -f /boot/config.txt sudo cp /boot/config_lcd.txt /boot/config.txt sudo cp /usr/share/alsa/alsa.conf.lcd /usr/share/alsa/alsa.conf sudo reboot -n fi else HDMI_ON=`cat /boot/config.txt | grep "lcd_rotate=2"` echo $HDMI_ON if [ $HDMI_ON == "lcd_rotate=2" ]; then echo "reboot avec la configuration HDMI" sudo rm -f /boot/config.txt sudo cp /boot/config_hdmi.txt /boot/config.txt sudo cp /usr/share/alsa/alsa.conf.hdmi /usr/share/alsa/alsa.conf sudo reboot -n fi fi
Write and put config_hdmi.txt and config_lcd.txt on /boot (and save your config.txt)
Copy script on your pi. You can create it on /home/pi/initDisplay. Name it "initDisplay.sh" and use chmod command to set it on "executable mode" :sudo chmod 777 initDisplay.sh
(Maybe you have to create a empty file : hdmi.name, I don't remember)
You can test script with :
/home/pi/initDisplay/initdisplay.sh
If you want run it at pi boot, just add it on :
/etc/profil.d/10-*****.shadd this before emulstation instruction :
/home/pi/displayBoot/initDisplay.sh sleep 5
It's early morning here, I hope you will understand my english ^^
-
Does this still work with the latest RetroPie? And if so, could you list the instructions in a little more specific form please? Thank you!
-
I'm having trouble when adding the script when SSHing into my RetroPi. I type in cd /home/pi then vi initDisplay.sh and then I type the whole script from up above but it does not let me save or anything else. There are no options for anything! Please help!
-
@vinniesims said in Raspberry Pi Official LCD Screen "or" HDMI Option:
Please help!
Do you know how to use
vi
? If not, then usenano
instead. -
anyone get this running?
First issues I ran into was the script wouldn't run. I made it on windows 10 using Notepad ++. How I got it to work was by installing dos2unix by doing the following:
sudo apt-get install dos2unix
then I converted the script file by doing the following:
sudo dos2unix /home/pi/initDisplay/initDisplay.sh
Problem now is if I power up the Pi with an HDMI cord attached the LCD display is flipped. If I run the script again it returns:
device_name=SNY-SONY_TV__00 #lcd_rotate=2
Without an HDMI plugged in the LCD is right side up. If I run the script again it returns:
[E] No device present
so the script is running but is not outputting the the TV. Now the TV detects the input and says raspberry but remains black.
Edit:
Remembered hearing about the display that only one can be on at a time so I fixed it by adding:
ignore_lcd=1
to the "config_hdmi.txt" file now turns off the LCD and switches to the TV.
-
Also there is a typo in the original post. When you edit the /etc/profile.d/10-*****.sh, it should be:
# switch between LCD and HDMI /home/pi/initDisplay/initDisplay.sh sleep 5
instead of /home/pi/displayBoot/initDisplay.sh
-
Hi all, sorry for dragging up an old thread. Has anyone got this to work on the latest Retropie image (4.7.1)? I had it installed on an old 4.4 image working absolutely fine, thought I would update to latest image 4.7.1 followed all the same steps (actually copied what was written in the old image that worked) in relation to detecting hdmi. But I can’t get it to work in 4.7.1, it always defaults into hdmi and cannot get itself back into lcd when you don’t have an hdmi cable installed. I often see ‘Unk-Comp-Dev’ in the text when booting rather than ‘[E] No Device Present]. Wondering if the updated Retropie version somehow recognizes the LCD screen differently which is preventing this script from working? It seems to always boot into hdmi like it always thinks something is plugged in when it’s not.
Any help to get it working would be much appreciated!
Thanks!
Ok found a solution in another thread no longer need a script to do what I need just a simple addition to the config.txt file, all sorted! Thanks!
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.