0. connect the ILI9341 display to the Raspberry Pi using the pin connection info shown below
Please Note: I have not tested the touchscreen yet, so feel free to not connect pins mentioned in line no. ∈ [2, 6]
1. enable SPI from raspi-config
2. do the change in /boot/config.txt to force enable HDMI ON as 1080p 16:9 display (needed to hot plug and play an HDMI monitor during radio operation)
# uncomment if HDMI display is not detected and composite is outputting
hdmi_force_hotplug=1
# uncomment to force a specific HDMI mode (this will force VGA)
hdmi_group=2
hdmi_mode=82
3. run the attached script (rpi-display.sh) as root using sudo
That’s it! You should now have a working dual-screen setup. You can run any application on the ILI9341 display now, as well as control the refresh rate, resolution, etc from /boot/config.txt itself!
P.S: Do note this implementation creates a completely separate screen for our X server to manage. As such, no window can be dragged from one screen to the other. The cursor can fly in and out of the screen freely though.
How to use the secondary display
After rebooting as the last step of the script, a secondary desktop should show up on the ILI9341 display.
To run an app on the secondary display (i.e. ILI9341 display), simply prepend the “DISPLAY=:0.1 ” string to the start of any command.
For example, to run a terminal window on the secondary display, run the following command (works just fine over an SSH connection too): –
$ DISPLAY=:0.1 lxterminal
NOTE: Mind the colon right after the equals sign!
IMPORTANT FIX
You will notice there are focus issues when trying to operate on the secondary display within the out-of-the-box Raspbian DE. This is a bug in lxde, so we can switch it for another lightweight DE at this point. For this, install XFCE4 using the following command:-
$ sudo apt-get install xfce4
This next command will switch over from the existing LXDE to the XFCE4 desktop environment :-
$ sudo update-alternatives --config x-session-manager
Finally, feel free to disable the display timeout by installing xfce4-power-manager using the following command :-
$ sudo apt-get install xfce4-power-manager
$ xfce4-power-manager -c