Unit HyperPixel
Return to Unit Reference
Contents
[hide]Description
Pimoroni HyperPixel TFT Display Driver unit
The HyperPixel is a TFT display produced by Pimoroni for use with the Raspberry Pi. It uses the DPI (Display Parallel Interface) which is directly supported by the VideoCore GPU and means that unlike other TFT displays using SPI or similar interfaces it supports hardware accelerated graphics in the same way as HDMI or DSI displays.
The HyperPixel is available in several versions including a 4.0 inch rectangular, a 4.0 inch square and 2.1 inch round. Each version requires a slightly different set of instructions to initialize it and this unit provides the correct sequence for each of these displays.
To use this unit simply include it in your application and then call the function HyperPixelInitialize() as early as possible passing the appropriate model as the only parameter to the function. Once initialized successfully the HyperPixel display will be available via the standard framebuffer functions and also via the VC4 accelerated graphics options such as OpenVG, OpenGLES, OpenMAX and MMAL.
It is important to remember that no other devices should be enabled while using the HyperPixel display as it consumes almost all of the available GPIO pins. So it is not possible to use UART, I2C, SPI, PWM etc when the HyperPixel is installed.
The touch screen controller varies between models and this unit creates and initializes the appropriate one for the model selected. All touch screen devices are I2C based however as it is not possible to utilize the hardware I2C controller (see note above) a software I2C host is created to provide access to the touch screen.
The touch events generated from the device can be read from the normal touch or mouse API functions in much the same way as any other touch or mouse device.
In order to enable the HyperPixel display you need to add the appropriate settings to your config.txt file as follows:
For HyperPixel 4.0 Rectangular (800 x 480)
enable_dpi_lcd=1 dpi_group=2 dpi_mode=87 dpi_output_format=0x7f216 dpi_timings=480 0 10 16 59 800 0 15 113 15 0 0 0 60 0 32000000 6
For HyperPixel 4.0 Square (720 x 720)
enable_dpi_lcd=1 dpi_group=2 dpi_mode=87 dpi_output_format=0x7f226 dpi_timings=720 0 15 15 15 720 0 10 10 10 0 0 0 60 0 35113500 6
For HyperPixel 4.0 Square (2021 or later) (720 x 720)
enable_dpi_lcd=1 dpi_group=2 dpi_mode=87 dpi_output_format=0x5f026 dpi_timings=720 0 20 20 40 720 0 15 15 15 0 0 0 60 0 36720000 4
For HyperPixel 2.1 Round (480 x 480)
enable_dpi_lcd=1 dpi_group=2 dpi_mode=87 dpi_output_format=0x7f216 dpi_timings=480 0 10 16 55 480 0 15 60 15 0 0 0 60 0 19200000 6
The display can be rotated to the desired position by adding the display_lcd_rotate setting to the config.txt file as below, please see the official documentation at https://www.raspberrypi.com/documentation/computers/config_txt.html for more details.
No Rotation (Portrait)
display_lcd_rotate=0
Rotate 90 degrees clockwise (Landscape)
display_lcd_rotate=1
Rotate 180 degrees clockwise (Portrait)
display_lcd_rotate=2
Rotate 270 degrees clockwise (Landscape)
display_lcd_rotate=3
Horizontal flip
display_lcd_rotate=0x10000
Vertical flip
display_lcd_rotate=0x20000
To match the rotation of the touchscreen to the rotation of the display you must call the TouchDeviceControl() API function with the TOUCH_CONTROL_SET_ROTATION request and pass the appropriate touch rotation constant in argument1, eg TOUCH_ROTATION_180.
The touch device representing the touchscreen can be found by calling the API function TouchDeviceFindByDescription() and passing the appropriate description for your device.
For the HyperPixel 4.0 Rectangular the description will be "Goodix Touch Controller" and for the HyperPixel 4.0 Square and HyperPixel 2.1 Round the device can be located using the description "EDT FocalTech FT5x06 Touch Controller".
The touchscreen rotation values match with the display rotations as follows:
display_lcd_rotate=0 equals TOUCH_ROTATION_0 display_lcd_rotate=1 equals TOUCH_ROTATION_90 display_lcd_rotate=2 equals TOUCH_ROTATION_180 display_lcd_rotate=3 equals TOUCH_ROTATION_270
Constants
HYPERPIXEL*
HYPERPIXEL_GPIO_*
HYPERPIXEL_SPI_*
HYPERPIXEL_I2C_*
HYPERPIXEL_BACKLIGHT_*
HYPERPIXEL_TOUCH_*
Type definitions
HyperPixel specific types
Public variables
None defined
Function declarations
HyperPixel functions
function HyperPixelInitialize(Model:LongWord):LongWord;
HyperPixel helper functions
function HyperPixelSPISetup(Data:PHyperPixelData):LongWord;
function HyperPixelSPICleanup(Data:PHyperPixelData):LongWord;
procedure HyperPixelSPIWriteBit(Data:PHyperPixelData; Value:Byte);
procedure HyperPixelSPIWriteByte(Data:PHyperPixelData; Value:Byte);
procedure HyperPixelSPIWriteRegister(Data:PHyperPixelData; Reg,Value:Byte);
procedure HyperPixelSPISoftReset(Data:PHyperPixelData);
procedure HyperPixelSPISelectPage(Data:PHyperPixelData; Number:Byte);
procedure HyperPixelSPIWriteBits(Data:PHyperPixelData; Value,Count:Word);
procedure HyperPixelSPIWriteCommand(Data:PHyperPixelData; Command:Word);
Return to Unit Reference