Raspberry Pi - Info ---------------------------------------------------------------------- Table of content * Which Raspberry Pi do I have? * Enable/disable Desktop GUI * tslib * Install and configure tslib for Raspberry Pi * Framebuffer * Raspberry Pi 4 with 4K HDMI display * Support physical keyboard * Set input devices in service file (if need) * Install VNC server for Raspberry Pi (TightVNC) * Network Settings Raspberry Pi ---------------------------------------------------------------------- Which Raspberry Pi do I have? Raspberry Pi 2, 3 or 4 $ cat /proc/device-tree/model Raspberry Pi 2 Model B Rev 1.1 Raspberry Pi 3 Model B Rev 1.2 Raspberry Pi 4 Model B Rev 1.1 $ cat /proc/cpuinfo Hardware : BCM2708 (Raspberry Pi 1, 1 x ARMv6 rev 7, v6l, 700 MHz) Hardware : BCM2709 (Raspberry Pi 2, 4 x ARMv7 rev 5, v7l, 900 MHz) Hardware : BCM2835 (Raspberry Pi 3, 4 x ARMv7 rev 4, v7l, 1.2 GHz) Hardware : BCM2711 (Raspberry Pi 4, 4 x ARMv7 rev 3, v7l, 1.5 GHz) $ gpio -v Raspberry Pi Details: Type: Model 2, Revision: 1.1, Memory: 1024MB, Maker: Sony (Pi 2) Type: Pi 3, Revision: 02, Memory: 1024MB, Maker: Embest (Pi 3) Type: Unknown17, Revision: 01, Memory: 0MB, Maker: Sony (Pi 4) To find out which distribution is installed, call the following command $ cat /etc/os-release ---------------------------------------------------------------------- Enable/disable Desktop GUI? $ sudo raspi-config Disable > Boot options > B1 Console Text console, requiring user to login Or System Options > Boot / Auto Login > B1 Console Text console, requiring user to login Enable > Boot options > B4 Desktop Autologin Desktop GUI, automatically logged in as 'pi' user Or System Options > Boot / Auto Login > B4 Desktop Autologin Desktop GUI, automatically logged in as 'pi' user ---------------------------------------------------------------------- tslib To find out which device is used for the touch screen $ sudo cat /dev/input/event0 and touch the screen, if nothing happen try another device Check if touchscreen is set up as framebuffer device 0 (/dev/fb0) $ cat /dev/zero > /dev/fb0 Will turn your little screen black (and give you an error message to go with it, free of charge, naturally). $ sudo apt-get install libts-bin This will create a configuration file, /etc/ts.conf, In order to use ts_calibrate and ts_test, you need to set environment variables. $ export TSLIB_TSDEVICE=/dev/input/event0 $ export TSLIB_FBDEVICE=/dev/fb0 $ ts_calibrate Or with sudo and with all env. variables $ sudo TSLIB_FBDEVICE=/dev/fb0 TSLIB_TSDEVICE=/dev/input/event0 TSLIB_CALIBFILE=/etc/pointercal TSLIB_CONFFILE=/etc/ts.conf TSLIB_PLUGINDIR=/usr/local/lib/ts ts_calibrate On error $ sudo ts_calibrate ts_setup: No such file or directory Create the link /dev/input/ts with the input device of your touchscreen $ sudo ln -s /dev/input/event0 /dev/input/ts Or specify the input device of the touchscreen $ export TSLIB_TSDEVICE=/dev/input/event0 $ sudo ts_calibrate ---------------------------------------------------------------------- Install and configure tslib for Raspberry Pi Ref: https://github.com/raysan5/raylib/wiki/Install-and-configure-Touchscreen-Drivers-(RPi) sudo apt-get install automake libtool sudo apt-get install ts-lib sudo apt-get install cmake git clone git://github.com/kergoth/tslib.git cd tslib mkdir build cd build cmake ../ make sudo make install --- Disable the installed libts* libraries sudo mkdir /usr/lib/arm-linux-gnueabihf/libts-disabled sudo mv /usr/lib/arm-linux-gnueabihf/libts* /usr/lib/arm-linux-gnueabihf/libts-disabled/ to make sure the new library is available: sudo cp -P /usr/local/lib/libts* /lib/arm-linux-gnueabihf/ ls -al /lib/arm-linux-gnueabihf/libts.so* lrwxrwxrwx 1 root root 10 Dec 3 14:31 /lib/arm-linux-gnueabihf/libts.so -> libts.so.0 lrwxrwxrwx 1 root root 15 Dec 3 14:31 /lib/arm-linux-gnueabihf/libts.so.0 -> libts.so.0.10.0 -rw-r--r-- 1 root root 19884 Dec 3 14:31 /lib/arm-linux-gnueabihf/libts.so.0.10.0 --- Check ts.conf file $ cat /etc/ts.conf My configuration for Raspberry Pi 2 Model B (RS Designspark) module_raw input module pthres pmin=1 module variance delta=30 module dejitter delta=100 module linear But the default configuration seems also to work fine module_raw input module median depth=3 module dejitter delta=100 module linear -- Calibrate touch (disable Desktop GUI first) $ touch /home/pi/pointercal $ TSLIB_FBDEVICE=/dev/fb0 TSLIB_TSDEVICE=/dev/input/event0 TSLIB_CALIBFILE=/home/pi/pointercal TSLIB_CONFFILE=/etc/ts.conf TSLIB_PLUGINDIR=/usr/local/lib/ts ts_calibrate $ sudo cp /home/pi/pointercal /etc/pointercal My configuration TSLIB_CONSOLEDEVICE=none TSLIB_FBDEVICE=/dev/fb0 TSLIB_TSDEVICE=/dev/input/event0 TSLIB_CALIBFILE=/etc/pointercal TSLIB_CONFFILE=/etc/ts.conf TSLIB_PLUGINDIR=/usr/local/lib/ts -------------------------------------------------------------------------------- Framebuffer ----------- We can Change color depth in /boot/config.txt (but it doesn't work in Raspberry Pi 4) framebuffer_depth=32 framebuffer_ignore_alpha=1 Otherwise, use fbset (-i to get more info) $ fbset -depth 32 (or 16) $ fbset -depth 16 -rgba 5/11,6/5,5/0,0/0 $ fbset -depth 32 -rgba 8/16,8/8,8/0,8/24 Change display mode with settings defined in /etc/fb.modes list modes like 1024x768: $ cat /etc/fb.modes |grep -A5 1024x768- $ fbset -fb /dev/fb0 1024x768-60 $ export FRAMEBUFFER=/dev/fb0 See man pages for more detail https://manpages.debian.org/stretch/fbset/fbset.1.en.html -------------------------------------------------------------------------------- Raspberry Pi 4 with 4K HDMI display How to change the display framebuffer settings from 4K to FHD (1920x1080) Change the config.txt file and reboot $ sudo nano /boot/config.txt # Remove disable_overscan, otherwise borders are out of the screen #disable_overscan=1 # Configuration of framebuffer width and height seem to be ignored framebuffer_width=1920 framebuffer_height=1080 # hdmi_group=1 (CEA), hdmi_mode=5 (1080i-60Hz) hdmi_group=1 hdmi_mode=5 hdmi_drive=2 --------------------------------------------- With HDMI CVT (doesn't work on every display) # hdmi_cvt= # aspect ratio 1=4:3, 2=14:9, 3=16:9, 4=5:4, 5=16:10, 6=15:9 hdmi_cvt=1920 1080 60 3 0 0 0 hdmi_group=2 hdmi_mode=87 hdmi_drive=2 For details: https://www.raspberrypi.org/documentation/configuration/config-txt/video.md -------------------------------------------------------------------------------- Support physical keyboard The keyboard device is automatically detected by the MicroBrowser. To check what kind of input devices are connected on my Raspberry Pi $ cat /proc/bus/input/devices I: Bus=0003 Vendor=0603 Product=00f2 Version=0110 N: Name="NOVATEK USB Keyboard" P: Phys=usb-3f980000.usb-1.2/input0 S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/0003:0603:00F2.0001/input/input0 U: Uniq= H: Handlers=sysrq kbd event0 B: PROP=0 B: EV=120013 B: KEY=10000 7 ff9f207a c14057ff febeffdf ffefffff ffffffff fffffffe B: MSC=10 B: LED=1f I: ... Here, the input device with 'EV=120013' is a Keyboard and 'Handlers=... event0' gives the name of input device: /dev/input/event0 To specify another device, use the environment variable "KBD_DEVICE", like that: $ export KBD_DEVICE=/dev/input/event2 -------------------------------------------------------------------------------- Set input devices in service file (if need): File: ./MicroBrowser/install/systemd/microbrowser.service [Service] WorkingDirectory=/home/pi/MicroBrowser Environment=TSLIB_TSDEVICE=/dev/input/event0 Environment=KBD_DEVICE=/dev/input/event1 ExecStart=/home/pi/MicroBrowser/MicroBrowser ... -------------------------------------------------------------------------------- VNC: Remote access a Raspberry Pi 1) TightVNC Server https://iotdesignpro.com/projects/setup-raspberry-pi-remote-desktop-using-tightvnc $ sudo apt-get update && sudo apt-get upgrade (tbd?) $ sudo apt-get install tightvncserver $ vncserver To check the successful installation of Tight VNC, type the command "vncserver" in the command prompt. On running this command for the first time you will be asked to set new VNC password for accessing the Raspberry Pi using TightVNC. This password can be different from username "pi". The default port is 5901 and use SSH tunneling on port 22, with username pi, the default password is raspberry Other way to start the VNC server with 16 bpp 565, 800x480 $ vncserver :1 -depth 16 -pixelformat rgb565 $ vncserver :1 -geometry 800×480 -depth 16 -pixelformat rgb565 See log file (press Ctrl+X to stop) $ tail -f .vnc/raspberrypi\:1.log To start VNC at boot time, edit crontab with the following command (use nano as editor) $ sudo crontab -e And add the following line: @reboot su - pi -c '/usr/bin/tightvncserver :1' Press Ctrl+X and Y (Yes) to save it 2) MicroBrowser VNC Client Download and install the MicroBrowser for your platform and contact us to activate the service https://ininet.ch/public/MicroBrowser/ $ ./MicroBrowser vnc://192.168.1.123/ -------------------------------------------------------------------------------- Network Settings Raspberry Pi How to read the IP address and how to set static IP address on Raspberry Pi? Default is DHCP enabled. To change the IP address of the Raspberry Pi, you can either use the GUI of the Rasbian OS, with Desktop. Or you can always change the network settings in the configuration file "dhcpcd.conf" 1) Rasbian Desktop (start with HDMI display) Read the IP address obtained by the DHCP server, in the top-right corner (mouse over and wait for a popup) with a right mouse click you can change the Ethernet settings, enable WiFi or not, change the IP either for WiFi or Ethernet eth0, ... 2) Linux terminal Type ifconfig on the console to find out the IP address of all the ethernet and WiFi adapters How to set static IP address of the Ethernet eth0 interface ? Add following lines in the end of the configuration file: /etc/dhcpcd.conf $ sudo nano /etc/dhcpcd.conf ... # Custom static IP address for eth0. interface eth0 static ip_address=192.168.1.123/24 static routers=192.168.1.1 static domain_name_servers=192.168.1.1 And reboot. -------------------------------------------------------------------------------- (c) 2018-2022 iniNet Solutions GmbH, Fichtenhagstrasse 2, Muttenz (Switzerland) 2022.07.08/JF