Difference between revisions of "Unit HyperPixel"

From Ultibo.org
Jump to: navigation, search
 
(13 intermediate revisions by the same user not shown)
Line 50: Line 50:
 
  dpi_output_format=0x7f216
 
  dpi_output_format=0x7f216
 
  dpi_timings=480 0 10 16 55 480 0 15 60 15 0 0 0 60 0 19200000 6
 
  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.
 
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
+
No Rotation (Portrait)
 
  display_lcd_rotate=0
 
  display_lcd_rotate=0
  
Rotate 90 degrees clockwise
+
Rotate 90 degrees clockwise (Landscape)
 
  display_lcd_rotate=1
 
  display_lcd_rotate=1
+
 
Rotate 180 degrees clockwise
+
Rotate 180 degrees clockwise (Portrait)
 
  display_lcd_rotate=2
 
  display_lcd_rotate=2
  
Rotate 270 degrees clockwise
+
Rotate 270 degrees clockwise (Landscape)
 
  display_lcd_rotate=3
 
  display_lcd_rotate=3
  
Line 70: Line 71:
 
Vertical flip
 
Vertical flip
 
  display_lcd_rotate=0x20000
 
  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 ===
 
=== Constants ===
 
----
 
----
  
''To be documented''
+
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''HyperPixel model''' <code> HYPERPIXEL* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>HYPERPIXEL40_RECTANGLE = 0;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>HYPERPIXEL40_SQUARE = 1;</code>
 +
| &nbsp;
 +
|-
 +
| <code>HYPERPIXEL40_SQUARE2021 = 2;</code>
 +
| &nbsp;
 +
|-
 +
| <code>HYPERPIXEL21_ROUND = 3;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''HyperPixel GPIO pins (All Models)''' <code> HYPERPIXEL_GPIO_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>HYPERPIXEL_GPIO_PIN_FUNCTION = GPIO_FUNCTION_ALT2;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>HYPERPIXEL_GPIO_PIN_PULL = GPIO_PULL_NONE;</code>
 +
| &nbsp;
 +
|-
 +
| <code>HYPERPIXEL_GPIO_PIN_COUNT = 22;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<code>HYPERPIXEL_GPIO_PINS:array[0..HYPERPIXEL_GPIO_PIN_COUNT - 1] of LongWord = (GPIO_PIN_0, GPIO_PIN_1, GPIO_PIN_2, GPIO_PIN_3, GPIO_PIN_4, GPIO_PIN_5, GPIO_PIN_6, GPIO_PIN_7, GPIO_PIN_8, GPIO_PIN_9, GPIO_PIN_12, GPIO_PIN_13, GPIO_PIN_14, GPIO_PIN_15, GPIO_PIN_16, GPIO_PIN_17, GPIO_PIN_20, GPIO_PIN_21, GPIO_PIN_22, GPIO_PIN_23, GPIO_PIN_24, GPIO_PIN_25);</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''HyperPixel SPI pins (All Models) (Used during initialization)''' <code> HYPERPIXEL_SPI_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>HYPERPIXEL_SPI_FUNCTION = GPIO_FUNCTION_OUT;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>HYPERPIXEL_SPI_PULL = GPIO_PULL_NONE;</code>
 +
| &nbsp;
 +
|-
 +
| <code>HYPERPIXEL_SPI_CLK = GPIO_PIN_27;</code>
 +
| &nbsp;
 +
|-
 +
| <code>HYPERPIXEL_SPI_MOSI = GPIO_PIN_26;</code>
 +
| &nbsp;
 +
|-
 +
| <code>HYPERPIXEL_SPI_CS = GPIO_PIN_18;</code>
 +
| &nbsp;
 +
|-
 +
| <code>HYPERPIXEL_SPI_DELAY = 100;</code>
 +
| Clock pulse time in microseconds
 +
|-
 +
| <code>HYPERPIXEL_SPI_WAIT = 120;</code>
 +
| Wait time in milliseconds before display on
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>HYPERPIXEL_SPI_CLK_ALT = GPIO_PIN_11;</code>
 +
| CLK Pin (Round model)
 +
|-
 +
| <code>HYPERPIXEL_SPI_MOSI_ALT = GPIO_PIN_10;</code>
 +
| MOSI Pin (Round model)
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>HYPERPIXEL_SPI_DELAY_ALT = 10;</code>
 +
| Clock pulse time in microseconds (Rectangle model)
 +
|-
 +
| <code>HYPERPIXEL_SPI_WAIT_ALT = 200;</code>
 +
| Wait time in milliseconds before display on (Rectangle model)
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''HyperPixel touch I2C pins (All Models) (Used to create a software I2C device)''' <code> HYPERPIXEL_I2C_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>HYPERPIXEL_I2C_SDA = GPIO_PIN_10;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>HYPERPIXEL_I2C_SCL = GPIO_PIN_11;</code>
 +
| &nbsp;
 +
|-
 +
| <code>HYPERPIXEL_I2C_DELAY = 4;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''HyperPixel backlight pins (All Models) (GPIO for backlight control)''' <code> HYPERPIXEL_BACKLIGHT_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>HYPERPIXEL_BACKLIGHT_FUNCTION = GPIO_FUNCTION_OUT;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>HYPERPIXEL_BACKLIGHT_PULL = GPIO_PULL_NONE;</code>
 +
| &nbsp;
 +
|-
 +
| <code>HYPERPIXEL_BACKLIGHT_PIN = GPIO_PIN_19;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''HyperPixel touch interrupt pins (All Models) (GPIO for touch event registration)''' <code> HYPERPIXEL_TOUCH_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>HYPERPIXEL_TOUCH_INTERRUPT_TRIGGER = GPIO_TRIGGER_FALLING;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>HYPERPIXEL_TOUCH_INTERRUPT_FUNCTION = GPIO_FUNCTION_IN;</code>
 +
| &nbsp;
 +
|-
 +
| <code>HYPERPIXEL_TOUCH_INTERRUPT_PULL = GPIO_PULL_UP;</code>
 +
| &nbsp;
 +
|-
 +
| <code>HYPERPIXEL_TOUCH_INTERRUPT_PIN = GPIO_PIN_27;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
=== Type definitions ===
 
=== Type definitions ===
 
----
 
----
  
''To be documented''
+
 
 +
'''HyperPixel specific types'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PHyperPixelData = ^THyperPixelData;</code>
 +
 
 +
<code>THyperPixelData = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Software SPI Data''
 +
|-
 +
| <code>Device:PGPIODevice;</code>
 +
| The GPIO device to use
 +
|-
 +
| <code>FSEL:LongWord;</code>
 +
| The GPIO function select value
 +
|-
 +
| <code>PULL:LongWord;</code>
 +
| The GPIO pull select value
 +
|-
 +
| <code>CLK:LongWord;</code>
 +
| The CLK pin for software SPI
 +
|-
 +
| <code>MOSI:LongWord;</code>
 +
| The MOSI pin for software SPI
 +
|-
 +
| <code>CS:LongWord;</code>
 +
| The CS pin for software SPI
 +
|-
 +
| <code>Wait:LongWord;</code>
 +
| Wait time in milliseconds before display on
 +
|-
 +
| <code>Delay:LongWord;</code>
 +
| Clock delay time in microseconds
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
=== Public variables ===
 
=== Public variables ===
 
----
 
----
  
''To be documented''
+
''None defined''
  
 
=== Function declarations ===
 
=== Function declarations ===
 
----
 
----
  
''To be documented''
 
  
 +
'''HyperPixel functions'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function HyperPixelInitialize(Model:LongWord):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Initialize an attached HyperPixel display including GPIO pin configuration</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Model
 +
| The model of display to be initialized (eg HYPERPIXEL40_SQUARE)
 +
|-
 +
! Return
 +
| ERROR_SUCCESS on successful completion or another error code on failure
 +
|-
 +
! Note
 +
| No attempt is made to determine if the model specified matches with the attached display. It is the users responsibility to specify the correct model.
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
 +
'''HyperPixel helper functions'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function HyperPixelSPISetup(Data:PHyperPixelData):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Setup the software SPI communication used to initialize the HyperPixel display</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Data
 +
| A pointer to a THyperPixelData structure containing the configuration
 +
|-
 +
! Return
 +
| ERROR_SUCCESS on successful completion or another error code on failure
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function HyperPixelSPICleanup(Data:PHyperPixelData):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Cleanup the software SPI after HyperPixel initialization</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Data
 +
| A pointer to the THyperPixelData structure used to configure the SPI
 +
|-
 +
! Return
 +
| ERROR_SUCCESS on successful completion or another error code on failure
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">procedure HyperPixelSPIWriteBit(Data:PHyperPixelData; Value:Byte);</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Write a single bit to the software SPI</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Data
 +
| A pointer to the THyperPixelData structure used to configure the SPI
 +
|-
 +
! Value
 +
| The bit value to write (0 or 1)
 +
|-
 +
! Note
 +
| Used primarily for HyperPixel 4.0 Rectangle
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">procedure HyperPixelSPIWriteByte(Data:PHyperPixelData; Value:Byte);</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Write a byte to the software SPI</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Data
 +
| A pointer to the THyperPixelData structure used to configure the SPI
 +
|-
 +
! Value
 +
| The byte value to write
 +
|-
 +
! Note
 +
| Used primarily for HyperPixel 4.0 Rectangle
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">procedure HyperPixelSPIWriteRegister(Data:PHyperPixelData; Reg,Value:Byte);</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Perform a register select followed by a register write using the software SPI</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Data
 +
| A pointer to the THyperPixelData structure used to configure the SPI
 +
|-
 +
! Reg
 +
| The register to be selected
 +
|-
 +
! Value
 +
| The byte value to write
 +
|-
 +
! Note
 +
| Used primarily for HyperPixel 4.0 Rectangle
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">procedure HyperPixelSPISoftReset(Data:PHyperPixelData);</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Perform a software reset of the HyperPixel display</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Data
 +
| A pointer to the THyperPixelData structure used to configure the SPI
 +
|-
 +
! Note
 +
| Used primarily for HyperPixel 4.0 Rectangle
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">procedure HyperPixelSPISelectPage(Data:PHyperPixelData; Number:Byte);</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Perform a page select operation to select a specific configuration page</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Data
 +
| A pointer to the THyperPixelData structure used to configure the SPI
 +
|-
 +
! Number
 +
| The page number to select
 +
|-
 +
! Note
 +
| Used primarily for HyperPixel 4.0 Rectangle
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">procedure HyperPixelSPIWriteBits(Data:PHyperPixelData; Value,Count:Word);</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Write a sequence of bits to the software SPI</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Data
 +
| A pointer to the THyperPixelData structure used to configure the SPI
 +
|-
 +
! Value
 +
| The value containing the bits to be written
 +
|-
 +
! Count
 +
| The number of bits to write
 +
|-
 +
! Note
 +
| Used primarily for HyperPixel 2.1 Round and 4.0 Square
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">procedure HyperPixelSPIWriteCommand(Data:PHyperPixelData; Command:Word);</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Write a command to the software SPI</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Data
 +
| A pointer to the THyperPixelData structure used to configure the SPI
 +
|-
 +
! Command
 +
| The command to be written
 +
|-
 +
! Note
 +
| Used primarily for HyperPixel 2.1 Round and 4.0 Square
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
Return to [[Unit_Reference|Unit Reference]]
 
Return to [[Unit_Reference|Unit Reference]]

Latest revision as of 05:25, 13 September 2022

Return to Unit Reference


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 model HYPERPIXEL*
HYPERPIXEL40_RECTANGLE = 0;  
HYPERPIXEL40_SQUARE = 1;  
HYPERPIXEL40_SQUARE2021 = 2;  
HYPERPIXEL21_ROUND = 3;  


HyperPixel GPIO pins (All Models) HYPERPIXEL_GPIO_*
HYPERPIXEL_GPIO_PIN_FUNCTION = GPIO_FUNCTION_ALT2;  
HYPERPIXEL_GPIO_PIN_PULL = GPIO_PULL_NONE;  
HYPERPIXEL_GPIO_PIN_COUNT = 22;  
HYPERPIXEL_GPIO_PINS:array[0..HYPERPIXEL_GPIO_PIN_COUNT - 1] of LongWord = (GPIO_PIN_0, GPIO_PIN_1, GPIO_PIN_2, GPIO_PIN_3, GPIO_PIN_4, GPIO_PIN_5, GPIO_PIN_6, GPIO_PIN_7, GPIO_PIN_8, GPIO_PIN_9, GPIO_PIN_12, GPIO_PIN_13, GPIO_PIN_14, GPIO_PIN_15, GPIO_PIN_16, GPIO_PIN_17, GPIO_PIN_20, GPIO_PIN_21, GPIO_PIN_22, GPIO_PIN_23, GPIO_PIN_24, GPIO_PIN_25);  


HyperPixel SPI pins (All Models) (Used during initialization) HYPERPIXEL_SPI_*
HYPERPIXEL_SPI_FUNCTION = GPIO_FUNCTION_OUT;  
HYPERPIXEL_SPI_PULL = GPIO_PULL_NONE;  
HYPERPIXEL_SPI_CLK = GPIO_PIN_27;  
HYPERPIXEL_SPI_MOSI = GPIO_PIN_26;  
HYPERPIXEL_SPI_CS = GPIO_PIN_18;  
HYPERPIXEL_SPI_DELAY = 100; Clock pulse time in microseconds
HYPERPIXEL_SPI_WAIT = 120; Wait time in milliseconds before display on
 
HYPERPIXEL_SPI_CLK_ALT = GPIO_PIN_11; CLK Pin (Round model)
HYPERPIXEL_SPI_MOSI_ALT = GPIO_PIN_10; MOSI Pin (Round model)
 
HYPERPIXEL_SPI_DELAY_ALT = 10; Clock pulse time in microseconds (Rectangle model)
HYPERPIXEL_SPI_WAIT_ALT = 200; Wait time in milliseconds before display on (Rectangle model)


HyperPixel touch I2C pins (All Models) (Used to create a software I2C device) HYPERPIXEL_I2C_*
HYPERPIXEL_I2C_SDA = GPIO_PIN_10;  
HYPERPIXEL_I2C_SCL = GPIO_PIN_11;  
HYPERPIXEL_I2C_DELAY = 4;  


HyperPixel backlight pins (All Models) (GPIO for backlight control) HYPERPIXEL_BACKLIGHT_*
HYPERPIXEL_BACKLIGHT_FUNCTION = GPIO_FUNCTION_OUT;  
HYPERPIXEL_BACKLIGHT_PULL = GPIO_PULL_NONE;  
HYPERPIXEL_BACKLIGHT_PIN = GPIO_PIN_19;  


HyperPixel touch interrupt pins (All Models) (GPIO for touch event registration) HYPERPIXEL_TOUCH_*
HYPERPIXEL_TOUCH_INTERRUPT_TRIGGER = GPIO_TRIGGER_FALLING;  
HYPERPIXEL_TOUCH_INTERRUPT_FUNCTION = GPIO_FUNCTION_IN;  
HYPERPIXEL_TOUCH_INTERRUPT_PULL = GPIO_PULL_UP;  
HYPERPIXEL_TOUCH_INTERRUPT_PIN = GPIO_PIN_27;  


Type definitions



HyperPixel specific types

PHyperPixelData = ^THyperPixelData;

THyperPixelData = record

Software SPI Data
Device:PGPIODevice; The GPIO device to use
FSEL:LongWord; The GPIO function select value
PULL:LongWord; The GPIO pull select value
CLK:LongWord; The CLK pin for software SPI
MOSI:LongWord; The MOSI pin for software SPI
CS:LongWord; The CS pin for software SPI
Wait:LongWord; Wait time in milliseconds before display on
Delay:LongWord; Clock delay time in microseconds


Public variables


None defined

Function declarations



HyperPixel functions

function HyperPixelInitialize(Model:LongWord):LongWord;
Description: Initialize an attached HyperPixel display including GPIO pin configuration
Model The model of display to be initialized (eg HYPERPIXEL40_SQUARE)
Return ERROR_SUCCESS on successful completion or another error code on failure
Note No attempt is made to determine if the model specified matches with the attached display. It is the users responsibility to specify the correct model.


HyperPixel helper functions

function HyperPixelSPISetup(Data:PHyperPixelData):LongWord;
Description: Setup the software SPI communication used to initialize the HyperPixel display
Data A pointer to a THyperPixelData structure containing the configuration
Return ERROR_SUCCESS on successful completion or another error code on failure


function HyperPixelSPICleanup(Data:PHyperPixelData):LongWord;
Description: Cleanup the software SPI after HyperPixel initialization
Data A pointer to the THyperPixelData structure used to configure the SPI
Return ERROR_SUCCESS on successful completion or another error code on failure


procedure HyperPixelSPIWriteBit(Data:PHyperPixelData; Value:Byte);
Description: Write a single bit to the software SPI
Data A pointer to the THyperPixelData structure used to configure the SPI
Value The bit value to write (0 or 1)
Note Used primarily for HyperPixel 4.0 Rectangle


procedure HyperPixelSPIWriteByte(Data:PHyperPixelData; Value:Byte);
Description: Write a byte to the software SPI
Data A pointer to the THyperPixelData structure used to configure the SPI
Value The byte value to write
Note Used primarily for HyperPixel 4.0 Rectangle


procedure HyperPixelSPIWriteRegister(Data:PHyperPixelData; Reg,Value:Byte);
Description: Perform a register select followed by a register write using the software SPI
Data A pointer to the THyperPixelData structure used to configure the SPI
Reg The register to be selected
Value The byte value to write
Note Used primarily for HyperPixel 4.0 Rectangle


procedure HyperPixelSPISoftReset(Data:PHyperPixelData);
Description: Perform a software reset of the HyperPixel display
Data A pointer to the THyperPixelData structure used to configure the SPI
Note Used primarily for HyperPixel 4.0 Rectangle


procedure HyperPixelSPISelectPage(Data:PHyperPixelData; Number:Byte);
Description: Perform a page select operation to select a specific configuration page
Data A pointer to the THyperPixelData structure used to configure the SPI
Number The page number to select
Note Used primarily for HyperPixel 4.0 Rectangle


procedure HyperPixelSPIWriteBits(Data:PHyperPixelData; Value,Count:Word);
Description: Write a sequence of bits to the software SPI
Data A pointer to the THyperPixelData structure used to configure the SPI
Value The value containing the bits to be written
Count The number of bits to write
Note Used primarily for HyperPixel 2.1 Round and 4.0 Square


procedure HyperPixelSPIWriteCommand(Data:PHyperPixelData; Command:Word);
Description: Write a command to the software SPI
Data A pointer to the THyperPixelData structure used to configure the SPI
Command The command to be written
Note Used primarily for HyperPixel 2.1 Round and 4.0 Square


Return to Unit Reference