The first peripheral we'll take a look at is the HDMI monitor, connected to the Raspberry Pi. As connecting an HDMI monitor to the board is extremely simple it's surprisingly difficult to find information on the Internet about how to solve issues and setup the monitor visualisation that best reflects our needs, so this is actually a great starting place for us.
What Your Need for HDMI on Raspberry Pi
As the Raspberry Pi includes a standard, full-size HDMI connector (as opposed to the smaller, micro-HDMI connectors that are starting to appear on similar devices) the only thing you need is a cable like the one shown below.
Ok, so there's nothing easier than connecting the monitor to the Raspberry PI, yes? Well, almost.
Standard Screen Configuration on Raspberry Pi
There's no standard, default configuration that relates to a Raspberry Pi's screen, and this can confuse new users. As a matter of fact, there are two important factors that influence the screen characteristics.
The first is the display memory. In the Raspberry Pi (all models) the video memory is a part of the system memory (the RAM) that's shared to manage the graphical display. This means that any memory space we reserve for the display means the less system RAM we have (and vice-versa). This is a parameter to take in account when obtaining the best results we need from the user interface; keeping sufficient memory to run the system and the applications.
Note: As almost all the same things run well on the Raspberry Pi 2 and the previous models with only the half of the memory available (the Pi 2 has 1GB of RAM against the 512MB of the other models) on the Pi 2 we are free to be more tolerant when reserving video memory.
My suggestion for a better optimisation is to start reserving an initial amount of 64MB for the GPU memory (the Graphic Processing Unit) and eventually increasing this value if we need higher resolution images. The tests done in several working conditions show better graphic results without compromising the processor speed and capabilities suggests that it's possible to share up to 128MB of RAM for the GPU on a Raspberry PI 2 (1/4 of the entire RAM in the previous models!).
The easiest way to configure the GPU memory is through th raspi-config utility. The images below shows the menu sequence to set the desired GPU memory in the system.
Note: It is possible to set any amount of memory but it is the worth testing the suggestions of the script screen, selecting multiples of 16MB of RAM for the better management of the GPU.
From a terminal, launch the command:
From the main menu select Advanced Options.
Then select Memory Split.
Finally, select the desired amount of memory and confirm with the <Ok> button.
HDMI Audio on Raspberry Pi
The Raspberry Pi includes a good quality stereo audio Jack (output only). Due to several potential issues, most depending on the other peripherals connected to the board, it's not unusual that the audio quality decreases at times, producing a worse sound than expected.
However, from the Advanced Options menu it's possible to configure the audio output, forcing the sound sent to via the HDMI output instead of the 3.5mm Jack.
Also in the case where the display is not needed (which occurs in lot of portable projects) or, for example, we are using the PiFace CAD or the 2.4" Raspberry Pi Touch Panel , we can still take advantage of the quality of the HDMI audio using a specific HDMI audio cable, as shown in the example below.
Fine-tuning the Screen Resolution
We have at least two reasons to fine-tune the screen resolution in the Raspberry Pi settings; the first is that there are HDMI screens with different aspect-ratios, and the second is that we need to change the screen resolution depending on the kind of use, the display size etc.
Those who are used to working with the PC know that these parameters are set up and/or detected when the system starts, and in most cases part of the settings are done by changing some BIOS parameters. Other settings - inside a predefined range - can be changed further with proper screen configuration programs like those in Ubuntu desktop and Windows.
As the Raspberry Pi does not have a conventional BIOS, most of the configuration parameters, including the screen settings, are loaded by the GPU before the kernel starts from a simple text file named config.txt stored in the system folder /boot
Note: the raspi-config utility script we have used above to set the audio channel or the GPU's dedicated RAM make automatic changes to this configuration file, but we can also edit the file directly.
The /boot/config.txt file doesn't just contain the graphic display and screen settings, but a lot of other useful information to tailor the behaviour of our system when it starts; in particular for the screen, we can set the resolution, size, aspect ratio, and scan frequency.
Take a look at the following group of settings from the config.txt file (some settings are generated automatically by the NOOBS while installing the operating system):
# NOOBS Auto-generated Settings: hdmi_force_hotplug=1 config_hdmi_boost=4 overscan_left=24 overscan_right=24 overscan_top=16 overscan_bottom=16 disable_overscan=0 start_x=0 gpu_mem=128 core_freq=250 sdram_freq=400 over_voltage=0 dtparam=spi=on dtparam=i2c0=on dtparam=i2c_arm=on
The format of the file is really simple to read and with a minimum of experience, and also to change without damaging the Raspberry Pi's performance. The character '#' is used for a comment line while every parameter is set in the format; <parameter>=<value>
Yes, just as in the unbelievable Windows .ini files and some other settings in the Linux environment. So, the only thing we should know is what is the exact meaning of these parameters to set the values in a consistent way. Some parameters are numeric (with a range of accepted values) and some parameters are boolean (can assume only the value yes or no).
Before Changing the config.txt Settings
First of all, temporarily disable the automatic graphic desktop when the system starts with the raspi-config configuration script as shown in the following images:
After setting the text console at start up, the system needs to reboot.
This operation is for preserving the automatic desktop start up if we see that any settings have gone wrong and the display is unreadable. In this configuration after the system boots we only see the Login prompt; after logging in to launch the graphic desktop we should launch the command startx
After every change to the display settings, we reboot and if, after launching the startx command the desktop is unreadable, we can simply roll back the settings to the last correct value.
Display Setup Parameters
To correctly manage the display settings we should know the exact aspect ratio and scan frequency of the monitor we will use. The following settings shows an example of the standard PAL settings for Europe on a 1024x768 resolution monitor.
# Set sdtv mode to PAL (as used in Europe) sdtv_mode=2 # Force the monitor to HDMI mode so that sound will be sent over HDMI cable hdmi_drive=2 # Set monitor mode to DMT hdmi_group=2 # Set monitor resolution to 1024x768 XGA 60 Hz (HDMI_DMT_XGA_60) hdmi_mode=16 # Make display smaller to stop text spilling off the screen overscan_left=20 overscan_right=12 overscan_top=10 overscan_bottom=10
A full, comprehensive and detailed look at all the parameters we can set for the best screen performance is described in the attached document RpiConfig, from elinux.org
An Overview on the Next Posts
What you will see soon in this series:
#3 Kivy: an open source solution for the User Interaction
How to install and use Kivy, a powerful python framework on the Raspberry PI for the best User Interaction on small touch screen devices..
#4 An introductory approach to wired and wireless networking
There are more options than simply plugging the LAN cable in the Ethernet port of the Raspberry PI. In this post we'll see how the Raspberry Pi can be a flexible networking device, acting as bridge, access point, wireless device and more.
#5 The Raspberry Pi camera beyond the webcam limits
Thanks to the power of Python and the specific characteristics of the Pi Camera it's possible to specialise the Raspberry Pi as a video/photo station: shooting, filming, image processing for a lot of possible applications; from photography to security, from stop-motion to the time-lapse filming.
#6 Lirc and IR controller: extending the limits of keyboard and mouse
With a very simple hardware approach we introduce the first non-conventional peripheral connection. Thanks to the Linux lirc library we can use a simplified HID (Human Interface Device) - a TV infrared control - to manage programs, device behaviour, and more.
#7 Enhancing our Pi projects with the Pi touchscreen
We will see how we can setup and integrate in our projects the Raspberry Pi 2.4" touch screen device.
#8 Enhancing our Pi projects with the PiFaceCAD LCD display
When a simple message is sufficient to control the Raspberry Pi behaviour but some control buttons would be useful, the PiFaceCAD (Control and Display) is the ideal device, which can be stacked on our Raspberry Pi for mobile, battery-powered applications.
#8 A multi-sensor system with the Raspberry PI Sense HAT
Coming soon ...