bbeemer
Posts: 73
Joined: Sun Nov 16, 2014 5:50 am
Location: Iowa, US

Re: Dual screen HDMI and 2.8 PiTFT

Tue Dec 30, 2014 11:43 pm

DirkS wrote:What happens when you use 'con2fbmap 1 1' on the command line (doesn't matter if HDMI plugged in or not).
I can switch console from HDMI to pitft by using 'con2fbmap 1 x' (x=0 for hdmi, 1 for pitft).
While on the login screen I can only see that by the appearing / disappearing cursor at the login prompt.
I tried this (con2fbmap 1 1) from the lxterm (on the desktop) and nothing happened, but then I saw you were using the term "command line" and decided to try it from the non desktop command line so I did a ctrl+alt+F2 then a ctrl+alt+F1 to get to the original command line.
As soon as I hit the ctrl+alt+F1 it switched to the TFT, from the TFT a con2fbmap 1 0 switches it back to the HDMI.
I can switch back and forth at will and like you say only the blinking cursor shows which is currently active.
but it wont switch during boot.

DirkS
Posts: 9873
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 12:07 am

but it wont switch during boot.
Do you let the Pi boot to the gui or to the console (login prompt)?

BTW: my /etc/rc.local now looks like this:

Code: Select all

echo "is it HDMI or DVI?" > /home/pi/tft.log
/usr/bin/tvservice -s >> /home/pi/tft.log
if (/usr/bin/tvservice -s | /bin/egrep 'HDMI|DVI') ; then
    echo "HDMI / DVI screen" >> /home/pi/tft.log
    # below setting is default
    # con2fbmap 1 0
else
    echo "switch on PiTFT" >> /home/pi/tft.log
    con2fbmap 1 1
fi

bbeemer
Posts: 73
Joined: Sun Nov 16, 2014 5:50 am
Location: Iowa, US

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 12:13 am

DirkS wrote:
but it wont switch during boot.
Do you let the Pi boot to the gui or to the console (login prompt)?
To the gui
BTW: my /etc/rc.local now looks like this:

Code: Select all

echo "is it HDMI or DVI?" > /home/pi/tft.log
/usr/bin/tvservice -s >> /home/pi/tft.log
if (/usr/bin/tvservice -s | /bin/egrep 'HDMI|DVI') ; then
    echo "HDMI / DVI screen" >> /home/pi/tft.log
    # below setting is default
    # con2fbmap 1 0
else
    echo "switch on PiTFT" >> /home/pi/tft.log
    con2fbmap 1 1
fi
I don't have the con2fbmap 1 0 commented out, will change it, reboot and get back to you.

bbeemer
Posts: 73
Joined: Sun Nov 16, 2014 5:50 am
Location: Iowa, US

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 12:20 am

No change from before.

DirkS
Posts: 9873
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 1:49 am

The 'boot to gui' makes it harder. It starts a daemon / service and setting anything in rc.local does not have an effect.
I'm trying out a few things (based on http://www.raspberrypi.org/forums/viewt ... p?p=485302) but I only have partial success.
I think I have to sleep on this one ;)

Gr.
Dirk.

bbeemer
Posts: 73
Joined: Sun Nov 16, 2014 5:50 am
Location: Iowa, US

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 3:18 am

DirkS wrote:The 'boot to gui' makes it harder. It starts a daemon / service and setting anything in rc.local does not have an effect.
I'm trying out a few things (based on http://www.raspberrypi.org/forums/viewt ... p?p=485302) but I only have partial success.
I think I have to sleep on this one ;)

Gr.
Dirk.
I had partial success by setting raspi-config to boot to console and putting sartx in rc.local, with HDMI plugged in I got a GUI but no icons and the changes to font size/color I had previously made had gone back to default.
With the HDMI unplugged I got an error displayed on the TFT, not sure what all it said because it scrolled off the screen and had a lot of word wrapping etc.
With the startx commented out I can now switch based on whether or not the HDMI is plugged in.
Now just need to get the gui working.
In the end I do want to have the desktop especially on the TFT since it is to be a portable unit and will not have a mouse or keyboard.
Some sleep sounds good, talk to you in the morning.

DirkS
Posts: 9873
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 11:51 am

I think I also got it working with 'start to gui'. Got that last night actually, but I want to double check and write it up properly.
I'm also trying to get one solution for both modes (start to console and gui), which I think is possible but have to test that first.

bbeemer
Posts: 73
Joined: Sun Nov 16, 2014 5:50 am
Location: Iowa, US

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 12:12 pm

DirkS wrote:I think I also got it working with 'start to gui'. Got that last night actually, but I want to double check and write it up properly.
I'm also trying to get one solution for both modes (start to console and gui), which I think is possible but have to test that first.
Sounds great, standing by.

DirkS
Posts: 9873
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 2:01 pm

Ok... I still it's an ugly hack, but it seems to be working for me :)

I created 2 files. I put both in folder /home/pi/scripts (I use this for all my scripts)
First thing you need is a file with the X framebuffer info:

Code: Select all

Section "Device"
  Identifier "pitft"
  Driver "fbdev"
  Option "fbdev" "/dev/fb1"
EndSection
I named it '99-fbdev.conf'.
Second file, 'screen.sh':

Code: Select all

#!/bin/bash

echo "is it HDMI or DMT?" > /home/pi/tft.log
/usr/bin/tvservice -s >> /home/pi/tft.log
if (/usr/bin/tvservice -s | /bin/egrep 'HDMI|DVI') ; then
    echo "HDMI / DVI screen" >> /home/pi/tft.log
    if [ -f  /usr/share/X11/xorg.conf.d/99-fbdev.conf ]; then
      rm /usr/share/X11/xorg.conf.d/99-fbdev.conf
    fi
    con2fbmap 1 0
else
    echo "switch on PiTFT" >> /home/pi/tft.log
    cp /home/pi/scripts/99-fbdev.conf /usr/share/X11/xorg.conf.d/
    con2fbmap 1 1
fi
Make it executable with 'chnod +x screen.sh'

Now edit /etc/rc.local:
Insert this before 'exit 0':

Code: Select all

. /home/pi/scripts/screen.sh
(that's a dot and a space at the start of the line.

Last file to change is the one that's used for 'start to gui'

Code: Select all

sudo nano /etc/init.d/lightdm
Near the top you'll find a line starting with 'test -x'.
Insert the same as in rc.local just after this line.

If all goes well both start to gui and a startx should automatically use the correct screen.
Because it's made executable you can also run it from the command line with 'sudo screen.sh'

It may look a bit odd that the same stuff is added in both files. Problem is that if you put it just in rc.local it's not picked up when using start to gui.
And of course if you start to console the lightdm script is not used...

That's it...

Gr.
Dirk.

bbeemer
Posts: 73
Joined: Sun Nov 16, 2014 5:50 am
Location: Iowa, US

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 4:33 pm

I copy and pasted everything so I don't think I made any typos but...
Booting to console, TFT won't work.
Booting to console, HDMI works, but gives this error just before the login:
/etc/rc.local: 8: /home/pi/scripts/screen.sh: Syntax error: "then" unexpected (expecting "fi")
[FAIL] startpar: service(s) returned failure: rc.local ... failed!

I commented out the last "then" and got a file not found error in the same place as above.
Commented out the first "then" and got 3 file not found errors (/home/pi/scripts/screen.sh)

When we get this working I will post a final setup post with links to the piitft image, script and manual setup pages and all steps to set this up then edit the op to add something like "SOLVED -- if you want to go straight to the solution go here "link to final post", and would like for you to error check it for me.
Last edited by bbeemer on Wed Dec 31, 2014 6:04 pm, edited 1 time in total.

DirkS
Posts: 9873
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 5:39 pm

Did you copy / paste the code?
Try dos2unix on screen.sh to 'sanitise' it.
You may have to install it first

Code: Select all

sudo apt-get install dos2unix
dos2unix screen.sh
Also double check that the paths are correct (I assume the '/home/oi' above is a typo) and that the 2 files are in the ~/scripts directory (of course you can choose a different location).

Gr.
Dirk.

bbeemer
Posts: 73
Joined: Sun Nov 16, 2014 5:50 am
Location: Iowa, US

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 6:24 pm

DirkS wrote:Did you copy / paste the code?
Yes I copied it from a browser on the pi and pasted it into leafpad, I even copy pasted the filenames

Code: Select all

Try dos2unix on screen.sh to 'sanitise' it.
You may have to install it first
[code]sudo apt-get install dos2unix
dos2unix screen.sh
I will give it a try but it was never on a dos machine on my end...
Sanitizing did not work.
Also double check that the paths are correct (I assume the '/home/oi' above is a typo) and that the 2 files are in the ~/scripts directory (of course you can choose a different location).
Yes that was a typo when I read it from the pi and typed it on my laptop.
Yes I realize I could put it in any location but would have to change the referencing lines to match, but just for ease of doing and troubleshooting I put them in /home/pi/scripts.

DirkS
Posts: 9873
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 7:06 pm

Do you get any messages if you run 'sudo ./screen.sh from the scripts directory'?

bbeemer
Posts: 73
Joined: Sun Nov 16, 2014 5:50 am
Location: Iowa, US

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 7:24 pm

DirkS wrote:Do you get any messages if you run 'sudo ./screen.sh from the scripts directory'?
Yes, 5 messages:
./screen.sh: line 7: $'\302\240': command not found
same thing for lines 8, 9, 10, 11

User avatar
ragnarjensen
Posts: 332
Joined: Wed May 15, 2013 6:13 pm
Location: Stockholm, Sweden
Contact: Website

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 7:35 pm

\302\240 is a non-breaking space in the Unicode character set.
Quite common when you copy text from web pages.
Does Leafpad save in Unicode by default? Try another editor?
--
Ragnar

bbeemer
Posts: 73
Joined: Sun Nov 16, 2014 5:50 am
Location: Iowa, US

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 7:53 pm

ragnarjensen wrote:\302\240 is a non-breaking space in the Unicode character set.
Quite common when you copy text from web pages.
Does Leafpad save in Unicode by default? Try another editor?
--
Ragnar
I'm not sure what it uses by default but I use it all the time when changing /etc/rc.local etc. so...
used "save as" which gives the option to change the code set, I used utf-8 - LF (this was the default in save as) but it did not help.

User avatar
ragnarjensen
Posts: 332
Joined: Wed May 15, 2013 6:13 pm
Location: Stockholm, Sweden
Contact: Website

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 8:05 pm

OK, looking at the HTML source of this forum page, it seems it's the forum's CODE box that introduces the non-breaking spaces.
Try the nano editor instead of Leafpad.
--
Ragnar
Last edited by ragnarjensen on Wed Dec 31, 2014 8:29 pm, edited 1 time in total.

bbeemer
Posts: 73
Joined: Sun Nov 16, 2014 5:50 am
Location: Iowa, US

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 8:11 pm

bbeemer wrote:
ragnarjensen wrote:\302\240 is a non-breaking space in the Unicode character set.
Quite common when you copy text from web pages.
Does Leafpad save in Unicode by default? Try another editor?
--
Ragnar
I'm not sure what it uses by default but I use it all the time when changing /etc/rc.local etc. so...
used "save as" which gives the option to change the code set, I used utf-8 - LF (this was the default in save as) but it did not help.
Ok I got it cleaned up with notepad++ on my laptop, now 'sudo ./screen.sh' gives the following:
./screen.sh: 1: ./screen.sh: #!/bin/bash: not found
./screen.sh: 1: ./screen.sh: Syntax error: "then" unexpected (expecting "fi")

User avatar
ragnarjensen
Posts: 332
Joined: Wed May 15, 2013 6:13 pm
Location: Stockholm, Sweden
Contact: Website

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 8:27 pm

That is typical when you have MS-DOS line endings - CR + LF.
Sanitize with dos2unix.
--
Ragnar

bbeemer
Posts: 73
Joined: Sun Nov 16, 2014 5:50 am
Location: Iowa, US

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 8:40 pm

ragnarjensen wrote:That is typical when you have MS-DOS line endings - CR + LF.
Sanitize with dos2unix.
--
Ragnar
Ok now it is:

Code: Select all

./screen.sh: 1: ./screen.sh: line 8: Syntax error near unexpected token 'then'
./screen.sh: 1: ./screen.sh: line 8: `    if [ -f /usr/share/X11/xorg.conf.d/99-fbdev.conf ] ; then'

User avatar
ragnarjensen
Posts: 332
Joined: Wed May 15, 2013 6:13 pm
Location: Stockholm, Sweden
Contact: Website

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 8:53 pm

You still have some crud in it. I can't tell what...
--
Ragnar

User avatar
ragnarjensen
Posts: 332
Joined: Wed May 15, 2013 6:13 pm
Location: Stockholm, Sweden
Contact: Website

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 8:57 pm

Get it here:

Code: Select all

wget http://www.jensenjensen.com/screen.sh
--
Ragnar

bbeemer
Posts: 73
Joined: Sun Nov 16, 2014 5:50 am
Location: Iowa, US

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 9:51 pm

ragnarjensen wrote:Get it here:

Code: Select all

wget http://www.jensenjensen.com/screen.sh
--
Ragnar
Thanks Ragnar the file worked.

It will now boot to the console on either screen, but booting to GUI does not work on either screen, they go black.
I had to ctr+alt+F2 then ctrl+alt+F1 to get back to the console.

DirkS
Posts: 9873
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 10:01 pm

bbeemer wrote:It will now boot to the console on either screen, but booting to GUI does not work on either screen, they go black.
I had to ctr+alt+F2 then ctrl+alt+F1 to get back to the console.
Did you make the change to /etc/init.d/lightdm as suggested?
The top of that file should look like this:

Code: Select all

#! /bin/sh
### BEGIN INIT INFO
# Provides:          lightdm
# Should-Start:      console-screen kbd acpid dbus hal consolekit
# Required-Start:    $local_fs $remote_fs x11-common
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Light Display Manager
# Description:       Debian init script for the Light Display Manager
### END INIT INFO
#
# Author:       Yves-Alexis Perez <[email protected]> using gdm script from
#               Ryan Murray <[email protected]>
#
set -e

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/lightdm

test -x $DAEMON || exit 0

. /home/pi/scripts/screen.sh

if [ -r /etc/default/locale ]; then
  . /etc/default/locale
  export LANG LANGUAGE
fi
So only the line with 'screen.sh' added.

Gr.
Dirk.

bbeemer
Posts: 73
Joined: Sun Nov 16, 2014 5:50 am
Location: Iowa, US

Re: Dual screen HDMI and 2.8 PiTFT

Wed Dec 31, 2014 10:21 pm

DirkS wrote:
bbeemer wrote:It will now boot to the console on either screen, but booting to GUI does not work on either screen, they go black.
I had to ctr+alt+F2 then ctrl+alt+F1 to get back to the console.
Did you make the change to /etc/init.d/lightdm as suggested?
The top of that file should look like this:

Code: Select all

#! /bin/sh
### BEGIN INIT INFO
# Provides:          lightdm
# Should-Start:      console-screen kbd acpid dbus hal consolekit
# Required-Start:    $local_fs $remote_fs x11-common
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Light Display Manager
# Description:       Debian init script for the Light Display Manager
### END INIT INFO
#
# Author:       Yves-Alexis Perez <[email protected]> using gdm script from
#               Ryan Murray <[email protected]>
#
set -e

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/lightdm

test -x $DAEMON || exit 0

. /home/pi/scripts/screen.sh

if [ -r /etc/default/locale ]; then
  . /etc/default/locale
  export LANG LANGUAGE
fi
So only the line with 'screen.sh' added.

Gr.
Dirk.
I was sure that I made that change but when I checked it was not there.
I fixed that and did raspi-config, changed to boot to desktop and get:
booting to TFT I get the console and it says:

Starting dphys-swapfile swapfile setup . ... (the rest goes off screen)
want /var/swap=100MByte, checking existi ...
done.

No command prompt.

I cant make much of it myself.

Booting to the HDMI gives me the desktop (GUI)

Return to “Interfacing (DSI, CSI, I2C, etc.)”