LCD 3.5 touch screen compartilhado com HDMI

24 views
Skip to first unread message

André Luis

unread,
Sep 1, 2017, 3:34:39 PM9/1/17
to Raspberry Pi Brasil
Achei isso bem interessante e gostaria de compartilhar, Pois pode ser útil para alguém. Comprei uma tela LCD 3.5 touch screen para Raspiberry PI 3 no mercado livre e existem muitos tutorias ensinando como instalar:

http://blog.temisnet.com.br/lcd35/

Entretanto eu procurei uma forma incomum de utilizá-la: Compartilhando a tela com uma saída HDMI, assim estendendo o para duas telas ou duas área de trabalho. Como por exemplo:

https://www.youtube.com/watch?v=d2ouG1VmD88

https://www.youtube.com/watch?v=zzugiINb3Zo

Sendo assim poder ser usado com alguma aplicação mostrando dados de monitoramento ou um controle a parte.

Primeiro de tudo é instalar um sistema para seu raspiberry Pi 2 ou 3, eu recomento o Jessie, embora possa ser usado wheely:

https://www.raspberrypi.org/downloads/

A seguir é instalar o drive da LCD touch screen, lembrando que usei o 3.5 GPIO (a piorzinha ;) ), pois exitem as versões DSI e HDMI. Acredito que de pra usar da mesma forma com DSI (https://www.raspberrypi.org/blog/the-eagerly-awaited-raspberry-pi-display/) , porém não encontrei informações adicionais. A versão HDMI fica impraticável esse método,  somente é possível com uma placa de extensão de vídeo USB, como é mostrado nesse vídeo:

https://www.youtube.com/watch?v=dTcU5YSq-Ww

Próximo passo é editar o arquivo  /usr/share/X11/xorg.conf.d/99-fbturbo.conf,  Usei o tutorial do site:

https://www.raspberrypi.org/forums/viewtopic.php?f=45&t=180857#p1153325

Meu 99-fbturbo.conf:

 Section "Device"
        Identifier      "FBDEV 0"
        Driver          "fbturbo"
        Option          "fbdev" "/dev/fb1"
EndSection

Section "Device"
        Identifier      "FBDEV 1"
        Driver          "fbturbo"
        Option          "fbdev" "/dev/fb0"
EndSection

Section "Screen"
        Identifier      "VGA"
        Device          "FBDEV 0"
        Monitor         "Monitor name 0"
EndSection

Section "Screen"
        Identifier      "HDMI"
        Device          "FBDEV 1"
        Monitor         "Monitor name 1"
EndSection

Section "ServerLayout"
        Identifier      "Default Layout"
        Screen          0 "VGA"
        Screen          1 "HDMI" RightOf "VGA"
#       Option         "Xinerama" "1"  # some raspbian doesn't work
EndSection


OBS.:  a opção "Xinerama" habilita a transição de janelas entre os monitores, acredito ser desnecessária para aplicação. Entretanto na versão do Jessie 2017-08-16 não funciona, testei com a versão wheely e funcionou todavia esta verão  S.O. é adaptada para PI 3 o que comigo não funcionou o WIFI.

Execute o comando para reiniciar o lightdm:
sudo service lightdm  restart

A partir daqui se você ver o HDMI e tela 
LCD 3.5 touch screen funcionando junto, mas existe um problema o touch para de funcionar e começa a executar a partir do segundo monitor, não é um bug pois o xorg reconhece como se o touch está associado a tamanho total dos dois monitores.  Contudo exite uma pessoa que me ajudo a solucionar esse problema:

https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=91764&start=125#p885835


Criar uma arquivo
~/.config/autostart/10-desktopmgr-autostart.desktop para executar o script ao iniciar o lightdm:

[Desktop Entry]
Encoding=UTF-8
Name=Desktop autostart for secondary display
Comment=Start the LXDE environment on secondary display
Exec=/home/pi/desktopmgr.sh
OnlyShowIn=LXDE

Script
desktopmgr.sh:

#!/bin/bash
#
# Start the LXDE desktop environment on the secondary display in a Dual-Head setup, where Xinerama is OFF.
#

export SECONDARY_DISPLAY=:0.1
export LXDE_CONF_DIR=LXDE_01            # Directory under ~/.config/pcmanfm/ with LXDE configuration for this desktop.
export OPENBOX_CONFIG=$HOME/.config/openbox/lxde_01-rc.xml

#xsetroot -display ${SECONDARY_DISPLAY} -solid thistle # For debug. If the secondary screen changes colour, we know that this script is running.

# Start a window manager.
DISPLAY=${SECONDARY_DISPLAY} openbox --config-file ${OPENBOX_CONFIG} &

# Start the desktop environment (wallpaper and desktop icons). It is actually the file manager pcmanfm that manages the desktop, when started with its --desktop option.
#
# Alas, there is a bug in pcmanfm.
# It won't start on DISPLAY :0.1 if there already is another pcmanfm running on the main DISPLAY :0.0
# It seems like it only checks if it already is running on the same X server,
# not taking the possible multiple displays on that server into consideration.
# Workaround by using the DISPLAY environment variable to point to a non-existing DISPLAY :9.0, where it does its check-if-i-am-already-running
# and using the --display argument to point out the real DISPLAY we want it running on.

DISPLAY=:9.0 pcmanfm --display=${SECONDARY_DISPLAY} --desktop  --profile LXDE &

# Start a terminal in the lower left corner of the display.
cd $HOME    # To make the terminal open in our home directory.
xterm -bg LightGoldenrodYellow -fg black -geometry +0-0 -display :0.1 &

# A clock is always nice to have.
DISPLAY=${SECONDARY_DISPLAY} xclock  -geometry +150+10 &

# Shrink the touch area. By default the Adafruit touchscreen will map to the entire X server screen area (both displays.)
# We need to shrink the touch area into a rectangle which is smaller than the total screen.
#
# The below transformation is for an Adafruit PiTFT 320x240 monitor to the left of a 1680x1050 monitor. The two monitors are aligned at the bottom edges.
# The touch area is shrunk to only encompass the Adafruit monitor.
# If your setup differs at all from the above, you have to recalculate the transformation.
# All the nitty, gritty details at https://wiki.archlinux.org/index.php/Calibrating_Touchscreen
# You have to "sudo apt-get install xinput" for the next line to work...

xinput set-prop "stmpe-ts" --type=float "Coordinate Transformation Matrix" 0.21 0 0 0 0.31 0 0 0 1

Execute o comando para reiniciar o lightdm:
sudo service lightdm  restart

E assim provavelmente
LCD 3.5 touch screen irá funcionar de boa, caso ainda esteja descalibrada execute xinput_calibrator, instale caso não exista no seu sistema:

sudo apt install xinput_calibrator

OBS.:  o comando
xinput set-prop que limita a area do touch para  tela pequena, caso vc mude a resolução do HDMI ela tem que ser alterada

use o site como referencia: https://wiki.archlinux.org/index.php/Calibrating_Touchscreen , mude "stmpe-ts" de acordo com drive do seu touch.

Os arquivos estão em anexo caso precisem...



Obrigo André Luis.

desktopmgr.sh
desktopmgr-autostart.desktop
99-fbturbo.conf
Auto Generated Inline Image 1
Auto Generated Inline Image 2

Marcus Brasizza

unread,
Sep 1, 2017, 3:55:20 PM9/1/17
to Raspberry Pi Brasil
Poxa que demais! parabens e obrigado pelo share

--
Você recebeu essa mensagem porque está inscrito no grupo "Raspberry Pi Brasil" dos Grupos do Google.
Para cancelar inscrição nesse grupo e parar de receber e-mails dele, envie um e-mail para raspberry-pi-br...@googlegroups.com.
Para mais opções, acesse https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages