Setting up a status display
As part of the Hangar Control project, I would like to be able to provide pilots and operations staff the ability to see the status of all the hangars. The Raspberry Pi 7" Touch Display makes a perfect candidate for this. As delivered, there is no enclosure for the display so we are left to build or buy something suitable. There are many fine examples of 3D-printable designs, but I do not have a 3D printer so I decided to purchase one. I chose a case from The Pi Hut https://thepihut.com/collections/raspberry-pi-screens/products/raspberry-pi-official-7-touchscreen-case for less than $20 USD, including shipping. Installing the the display is easy, but I did have a problem with the USB power adapter. The opening on the case is too small to accommodate the majority of connectors that I had -- Even those that ship with RPi's from various sources. Not to be thwarted, I simply used a dremel tool to enlarge the opening.
Once the display was enclosed and the power connected, I booted the the RPi only to discover that the display was presenting everything "upside down". The designers of the case chose to orient the Raspberry Pi such that the HDMI and power connectors were pointing up. Unlike your iPad or phone, the display does not automatically adjust itself based on the orientation of the display. You'll find many attempts to resolve this issue, but the most concise and efficient, performance-wise, is:
sudo nano /boot/config.txt
Navigate to the bottom of the file and add...
# rotate the display (and touchscreen)
lcd_rotate=2
Use "control-x" to save the changes and then reboot...
sudo shutdown -r now
Full Screen Browser Kiosk
Now that we have a touchscreen display ready for mounting on the wall, we need to set it up such that the status of HangarControl is always available. We are going to do this with a bit of X11 display alchemy. I was hoping to be able to be able to simply launch a browser from a script and supply a few command line parameters to force it into full screen mode and hide its various decorations and navigation menus. Alas, this was not to be. In the end, I decided on a dash of alchemy.
Be Aware!
This is not a solution for a "hardened" kiosk as one might release to the general public. It is intended as an easy-to-use display for a targeted and (mostly) trustworthy audience.
Install System Packages
sudo apt-get install epiphany-browser x11-xserver-utils xautomation unclutter
Package | Purpose |
---|---|
epiphany-browser | Web browser. By default, it ships with raspian and its ilk. I just included it here for completeness. |
x11-server-utils | This package provides a miscellaneous assortment of X Server utilities that ship with the X Window System. |
xautomation | A set of command lines programs to control X and do "visual scraping" to find things on the screen. The control interface allows mouse movement, clicking, button up/down, key up/down, etc. |
unclutter | Remove the cursor image from the screen so that it does not obstruct the area you are looking at after it has not moved for a given time. |
Launch the browser and set full screen mode
Create a script using your favorite editor and enter its contents as follows:
pi@raspberrypi:~ $ nano fullscreen.sh
#!/bin/bash
url=${1:-"http://hangarcontrol.com"}
sudo -u pi epiphany-browser -a -i --profile ~/.config $url --display=:0 &
sleep 5s;
xte "key F11" -x:0
Make the file executable
pi@raspberrypi:~ $ chmod +rx fullscreen.sh
Go ahead and test the script from the command line:
pi@raspberrypi:~ $ ./fullscreen.sh
You will, most likely, see some warning messages on the screen. I ignored them as they do not impact the operation of the kiosk, nor will they be seen during the course of normal operations.
(epiphany-browser:1007): WARNING **: Error caching form data: Cannot autolaunch D-Bus without X11 $DISPLAY
(epiphany-browser:1007): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(epiphany-browser:1007): Wnck-WARNING **: Unhandled action type _OB_WM_ACTION_UNDECORATE
(epiphany-browser:1007): Wnck-WARNING **: Unhandled action type _OB_WM_ACTION_UNDECORATE
(epiphany-browser:1007): Wnck-WARNING **: Unhandled action type _OB_WM_ACTION_UNDECORATE
(epiphany-browser:1007): Wnck-WARNING **: Unhandled action type _OB_WM_ACTION_UNDECORATE
Regardless, your RPi touchscreen display should present your web page and nothing else.
Automatically launch the browser with system startup
The final step is have the RPi boot right into kiosk mode. Depending on your use, you can choose whether or not the display should "go blank" after a period of not being used.
pi@raspberrypi:~ $ nano .config/lxsession/LXDE-pi/autostart
If you do not want the screensaver to be active:
Remove this line:
@xscreensaver -no-splash
Add these lines (turn off screensave, disable energy star power management, and do not blank screen, respectively):
@xset s off
@xset -dpms
@xset s noblank
Regardless of whether you have the screensaver enabled, we need to launch the web browser and place it in full screen mode. Add the final line to the end of the file.
@/home/pi/fullscreen.sh
When you reboot, your screen should appear something like:
That wraps up this installment. I hope you are able to use the information presented to setup your own dedicated Raspberry Pi Information Kiosk.
- Rick