Switch between LCD and HDMI

Having trouble with your mintyPi build? Post your questions here!
Post Reply
joao
Posts: 36
Joined: Fri Jun 02, 2017 6:49 am
Been thanked: 18 times

Switch between LCD and HDMI

Post by joao » Fri Aug 25, 2017 6:55 am

Hi,

I was trying to switch between the LCD and HDMI with the correct resolution for each, so that I could have an external HDMI port in the mintyPi. Based on some other forum I was able to create a script with the command tvservice -n to check if HDMI is connected or not, and then use the correct config.txt file.
But now I have two issues that I would like to solve.
When in HDMI the TV blinks from time to time.
And also when in HDMI the LCD keeps the white light on and I would like to turn it off.
Any suggestions?

joao
Posts: 36
Joined: Fri Jun 02, 2017 6:49 am
Been thanked: 18 times

Re: Switch between LCD and HDMI

Post by joao » Fri Aug 25, 2017 10:23 am

The HDMI config_hdmi.txt file contains the following in the end:

# Enable audio (loads snd_bcm2835)
dtparam=audio=on
gpu_mem_256=128
gpu_mem_512=256
gpu_mem_1024=256
overscan_scale=1
#lcd_off

And the LCD config_lcd.txt file contains the following:

# Enable audio (loads snd_bcm2835)
dtparam=audio=on
gpu_mem_256=128
gpu_mem_512=256
gpu_mem_1024=256
overscan_scale=1
#lcd_on
dtparam=spi=on
disable_overscan=1
hdmi_cvt=640 480 60 1
hdmi_group=2
hdmi_mode=87

And the script that performs the change is the following:

#!/bin/bash
rm -f hdmi.name
tvservice -n 2> hdmi.name
if grep "No device present" hdmi.name; then
if ! grep "#lcd_on" /boot/config.txt; then
echo "reboot with LCD configuration"
sudo cp -f /boot/config_lcd.txt /boot/config.txt
sudo reboot -n
fi
else
if ! grep "#lcd_off" /boot/config.txt; then
echo "reboot with HDMI configuration"
sudo cp -f /boot/config_hdmi.txt /boot/config.txt
sudo reboot -n
fi
fi

This script is called by 10-retropie.sh

# Check display config
/home/pi/displayBoot/initDisplay.sh
sleep 5

# launch our autostart apps (if we are on the correct tty)
if [ "`tty`" = "/dev/tty1" ]; then
bash "/opt/retropie/configs/all/autostart.sh"
fi

The original forum was https://retropie.org.uk/forum/topic/422 ... n-lcd-hdmi

Any suggestions on how to improve this?

joao
Posts: 36
Joined: Fri Jun 02, 2017 6:49 am
Been thanked: 18 times

Re: Switch between LCD and HDMI

Post by joao » Sun Sep 03, 2017 6:43 am

It seems not a lot of interested parties on this subject :)
Nevertheless I was able to fix the issue with the white screen by moving the led pin to gpio 18 (pin 12). And now I can control it off/on with:
sudo sh -c "echo 1 > /sys/class/backlight/fb_ili9341/bl_power"
sudo sh -c "echo 0 > /sys/class/backlight/fb_ili9341/bl_power"

I also disconnect and connect the sound card depending if I'm using HDMI or LCD. The new script looks like this:

#!/bin/bash

# HDMI connection?

rm -f hdmi.name
tvservice -n 2> hdmi.name

if grep "No device present" hdmi.name; then
if ! grep "#lcd_on" /boot/config.txt; then
echo "reboot with LCD configuration"
sudo cp -f /home/pi/displayBoot/config_lcd.txt /boot/config.txt
sudo cp -f /home/pi/displayBoot/asound_lcd.conf /etc/asound.conf
sudo sh -c "echo 1 > /sys/class/backlight/fb_ili9341/bl_power"
sudo reboot -n
fi
else
if ! grep "#lcd_off" /boot/config.txt; then
echo "reboot with HDMI configuration"
sudo cp -f /home/pi/displayBoot/config_hdmi.txt /boot/config.txt
sudo cp -f /home/pi/displayBoot/asound_hdmi.conf /etc/asound.conf
sudo sh -c "echo 0 > /sys/class/backlight/fb_ili9341/bl_power"
sudo reboot -n
fi
fi

joao
Posts: 36
Joined: Fri Jun 02, 2017 6:49 am
Been thanked: 18 times

Re: Switch between LCD and HDMI

Post by joao » Wed Sep 13, 2017 6:31 am

The blink issue was just a question of power supply. All is working fine now. Just need to think on a way to have the HDMI port out of the tin.

User avatar
Helder
Trailblazer
Trailblazer
Posts: 2985
Joined: Thu May 05, 2016 8:33 am
Location: Rogers, AR
Has thanked: 1459 times
Been thanked: 3114 times

Re: Switch between LCD and HDMI

Post by Helder » Wed Sep 13, 2017 11:23 pm

Can you provide a script to install these modifications or the modified files so anyone can easily install these on their setup?
Chat with me and other members On Discord

Don't contact me about obtaining my board files (as you will not get them). If my Boards or PCB Kits are sold out, they will be restocked as soon as I can get them and there is demand for them. You can join the mailing list on my Website to be notified when they are available.


Helder's Game Tech Website

We will not support any cloned work so don't come to us with technical issues to resolve, go talk to the cloner for help.

joao
Posts: 36
Joined: Fri Jun 02, 2017 6:49 am
Been thanked: 18 times

Re: Switch between LCD and HDMI

Post by joao » Fri Sep 15, 2017 10:14 am

Hi,

I'm just doing my first steps on this but here you have the files I used.

The 10-retropie.sh file should replace the one under /etc/profile.d/10-retropie.sh

The displayBoot directory should be placed under /home/pi

Enjoy it.
displaySwitch.zip
display switch files
(7.51 KiB) Downloaded 363 times

joao
Posts: 36
Joined: Fri Jun 02, 2017 6:49 am
Been thanked: 18 times

Re: Switch between LCD and HDMI

Post by joao » Mon Sep 25, 2017 2:57 am

I see that now the new PCB includes the LCD backlight pin so this option can be easily implemented if the image or script from wermy include the activation for this.

The command line in setup.sh:
echo 'options fbtft_device name=fb_ili9341 gpios=reset:25,dc:24 speed=80000000 bgr=1 rotate=90 custom=1 verbose=0 fps=60' >> $fbtft_conf

Should be replace by:
echo 'options fbtft_device name=fb_ili9341 gpios=reset:25,dc:24,led:18 speed=80000000 bgr=1 rotate=90 custom=1 verbose=0 fps=60' >> $fbtft_conf

After this you can use the information available in this post to turn on/off the screeen.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest