Difference between revisions of "Unit PiTFT28"
(16 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
---- | ---- | ||
− | The Adafruit PiTFT 2.8" LCD is a 320 x 240 pixel TFT with resistive touchscreen using an ILITEK ILI9340 driver and a STMicroelectronics | + | '''Adafruit PiTFT 2.8" LCD Driver unit''' |
− | + | ||
− | + | The Adafruit PiTFT 2.8" and PiTFT 3.2" LCD is a 320 x 240 pixel TFT with resistive touchscreen using an ILITEK ILI9340 driver and a STMicroelectronics STMPE610 resistive touchscreen controller. There is also a version available that includes a capacitive touchscreen using the Focaltech FT6236 controller. | |
+ | This unit ties together the various components needed to make one of these boards work with Ultibo by finding the correct SPI or I2C device, creating the STMPE610 or FT6236 Touch device, creating the ILI9340 Framebuffer device and registering all of it with the correct parameters for the Adafruit board. | ||
+ | |||
Details: | Details: | ||
− | + | ||
'''ILI9340''' | '''ILI9340''' | ||
Line 16: | Line 18: | ||
Height: 320 | Height: 320 | ||
− | |||
SPI Mode: 0 | SPI Mode: 0 | ||
Line 23: | Line 24: | ||
SPI Chip Select: SPI_CS_0 | SPI Chip Select: SPI_CS_0 | ||
− | |||
DC GPIO: GPIO_PIN_25 (Pull: GPIO_PULL_NONE) | DC GPIO: GPIO_PIN_25 (Pull: GPIO_PULL_NONE) | ||
Line 31: | Line 31: | ||
Backlight GPIO: GPIO_PIN_2 (STMPE GPIO) | Backlight GPIO: GPIO_PIN_2 (STMPE GPIO) | ||
− | + | '''STMPE (Resistive touch)''' | |
− | + | ||
Chip: STMPE_CHIP_610 | Chip: STMPE_CHIP_610 | ||
− | |||
SPI Mode: 0 | SPI Mode: 0 | ||
Line 43: | Line 41: | ||
SPI Chip Select: SPI_CS_1 | SPI Chip Select: SPI_CS_1 | ||
− | |||
IRQ GPIO: GPIO_PIN_24 (Trigger: GPIO_TRIGGER_FALLING)(Pull: GPIO_PULL_UP) | IRQ GPIO: GPIO_PIN_24 (Trigger: GPIO_TRIGGER_FALLING)(Pull: GPIO_PULL_UP) | ||
− | + | '''FT6236 (Capacitive touch)''' | |
+ | |||
+ | I2C Address: 0x38 | ||
+ | |||
+ | IRQ GPIO: GPIO_PIN_24 (Trigger: GPIO_TRIGGER_FALLING)(Pull: GPIO_PULL_UP) | ||
+ | |||
'''Switches''' | '''Switches''' | ||
Line 60: | Line 62: | ||
---- | ---- | ||
− | '' | + | |
+ | <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;">'''PiTFT28 specific constants''' <code> PITFT28_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>PITFT28_FRAMEBUFFER_DESCRIPTION = 'Adafruit PiTFT 2.8" LCD';</code> | ||
+ | | Description of PiTFT28 device | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>PITFT28_SIGNATURE = $AF000028;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>PITFT28_SCREEN_WIDTH = 240;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>PITFT28_SCREEN_HEIGHT = 320;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </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;">'''PiTFT28 GPIO''' <code> PITFT28_LCD_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>PITFT28_LCD_DC = GPIO_PIN_25;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>PITFT28_TOUCH_IRQ = GPIO_PIN_24;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>NAPITFT28_LCD_BL = GPIO_PIN_2;</code> | ||
+ | | STMPE GPIO | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
=== Type definitions === | === Type definitions === | ||
---- | ---- | ||
− | '' | + | |
+ | '''PiTFT28 specific types''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PPiTFT28LCD = ^TPiTFT28LCD;</code> | ||
+ | |||
+ | <code>TPiTFT28LCD = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>Signature:LongWord;</code> | ||
+ | | Signature for entry validation | ||
+ | |- | ||
+ | | <code>Rotation:LongWord;</code> | ||
+ | | Framebuffer rotation (eg FRAMEBUFFER_ROTATION_180) | ||
+ | |- | ||
+ | | <code>SPI:PSPIDevice;</code> | ||
+ | | SPI device for this display | ||
+ | |- | ||
+ | | <code>I2C:PI2CDevice;</code> | ||
+ | | I2C device for this display | ||
+ | |- | ||
+ | | <code>GPIO:PGPIODevice;</code> | ||
+ | | GPIO device for this display | ||
+ | |- | ||
+ | | <code>Touch:PTouchDevice;</code> | ||
+ | | Touch (STMPE or FT6236) device for this display | ||
+ | |- | ||
+ | | <code>Backlight:PGPIODevice;</code> | ||
+ | | Backlight GPIO (STMPE) device for this display | ||
+ | |- | ||
+ | | <code>Framebuffer:PFramebufferDevice;</code> | ||
+ | | Framebuffer (ILI9340) device for this display | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
=== Public variables === | === Public variables === | ||
---- | ---- | ||
− | '' | + | |
+ | '''PiTFT28 specific variables''' | ||
+ | |||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>PITFT28_SPI_DEVICE:String = 'SPI0';</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>PITFT28_LCD_CHIPSELECT:Word = SPI_CS_0;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>PITFT28_TOUCH_CHIPSELECT:Word = SPI_CS_1;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>PITFT28_I2C_DEVICE:String = 'I2C0';</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | ||
+ | |- | ||
+ | | <code>PITFT28_TOUCH_ADDRESS:Word = $38;</code> | ||
+ | | style="width: 40%;"| | ||
+ | |- | ||
+ | |} | ||
+ | <br /> | ||
=== Function declarations === | === Function declarations === | ||
---- | ---- | ||
− | |||
+ | '''Initialization 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;">procedure PiTFT28Init;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Initialize the PiTFT28 unit and parameters</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Note | ||
+ | | Called only during system startup | ||
+ | |- | ||
+ | |} | ||
+ | </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 PiTFT28Start(Rotation:LongWord; const Device:String; DisplaySelect,TouchSelect:Word):THandle; inline;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Start the PiTFT28 driver and register the Touch, Backlight (GPIO) and Framebuffer devices associated with the display</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Rotation | ||
+ | | The rotation of the display (eg FRAMEBUFFER_ROTATION_180) | ||
+ | |- | ||
+ | ! Device | ||
+ | | The SPI device that the ILI9340 and STMPE610 devices are connected to | ||
+ | |- | ||
+ | ! DisplaySelect | ||
+ | | The SPI chip select of the ILI9340 LCD controller | ||
+ | |- | ||
+ | ! TouchSelect | ||
+ | | The SPI chip select of the STMPE610 touch controller | ||
+ | |- | ||
+ | ! Return | ||
+ | | The handle of the PiTFT28 on success or INVALID_HANDLE_VALUE on failure | ||
+ | |- | ||
+ | ! Note | ||
+ | | This function will be called during startup if the parameter PITFT28_AUTOSTART is True | ||
+ | Can be called multiple times to support more than one PiTFT LCD display | ||
+ | |- | ||
+ | ! Note | ||
+ | | Replaced by PiTFT28ResistiveStart to accommodate capacitive display option | ||
+ | |- | ||
+ | |} | ||
+ | </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 PiTFT28ResistiveStart(Rotation:LongWord; const Device:String; DisplaySelect,TouchSelect:Word):THandle;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Start the PiTFT28 driver and register the resistive Touch, Backlight (GPIO) and Framebuffer devices associated with the display</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Rotation | ||
+ | | The rotation of the display (eg FRAMEBUFFER_ROTATION_180) | ||
+ | |- | ||
+ | ! Device | ||
+ | | The SPI device that the ILI9340 and STMPE610 devices are connected to | ||
+ | |- | ||
+ | ! DisplaySelect | ||
+ | | The SPI chip select of the ILI9340 LCD controller | ||
+ | |- | ||
+ | ! TouchSelect | ||
+ | | The SPI chip select of the STMPE610 touch controller | ||
+ | |- | ||
+ | ! Return | ||
+ | | The handle of the PiTFT28 on success or INVALID_HANDLE_VALUE on failure | ||
+ | |- | ||
+ | ! Note | ||
+ | | This function will be called during startup if the parameter PITFT28_AUTOSTART is True | ||
+ | Can be called multiple times to support more than one PiTFT LCD display | ||
+ | |- | ||
+ | |} | ||
+ | </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 PiTFT28CapacitiveStart(Rotation:LongWord; const SPIDevice,I2CDevice:String; DisplaySelect,TouchAddress:Word):THandle;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Start the PiTFT28 driver and register the capacitive Touch and Framebuffer devices associated with the display</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Rotation | ||
+ | | The rotation of the display (eg FRAMEBUFFER_ROTATION_180) | ||
+ | |- | ||
+ | ! SPIDevice | ||
+ | | The SPI device that the ILI9340 device is connected to | ||
+ | |- | ||
+ | ! I2CDevice | ||
+ | | The I2C device that the FT6236 device is connected to | ||
+ | |- | ||
+ | ! DisplaySelect | ||
+ | | The SPI chip select of the ILI9340 LCD controller | ||
+ | |- | ||
+ | ! TouchAddress | ||
+ | | The I2C address of the FT6236 touch controller | ||
+ | |- | ||
+ | ! Return | ||
+ | | The handle of the PiTFT28 on success or INVALID_HANDLE_VALUE on failure | ||
+ | |- | ||
+ | ! Note | ||
+ | | This function will be called during startup if the parameter PITFT28_AUTOSTART is True | ||
+ | Can be called multiple times to support more than one PiTFT LCD display | ||
+ | |- | ||
+ | |} | ||
+ | </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 PiTFT28Stop(Handle:THandle):Boolean;</pre> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Stop the PiTFT28 driver and deregister the Touch, Backlight (GPIO) and Framebuffer devices associated with the display</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! Handle | ||
+ | | The handle of the PiTFT28 or INVALID_HANDLE_VALUE for the default display | ||
+ | |- | ||
+ | ! Return | ||
+ | | True if completed or False on failure | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
Return to [[Unit_Reference|Unit Reference]] | Return to [[Unit_Reference|Unit Reference]] |
Latest revision as of 05:08, 13 September 2022
Return to Unit Reference
Description
Adafruit PiTFT 2.8" LCD Driver unit
The Adafruit PiTFT 2.8" and PiTFT 3.2" LCD is a 320 x 240 pixel TFT with resistive touchscreen using an ILITEK ILI9340 driver and a STMicroelectronics STMPE610 resistive touchscreen controller. There is also a version available that includes a capacitive touchscreen using the Focaltech FT6236 controller.
This unit ties together the various components needed to make one of these boards work with Ultibo by finding the correct SPI or I2C device, creating the STMPE610 or FT6236 Touch device, creating the ILI9340 Framebuffer device and registering all of it with the correct parameters for the Adafruit board.
Details:
ILI9340
Width: 240
Height: 320
SPI Mode: 0
SPI Frequency: 32000000
SPI Chip Select: SPI_CS_0
DC GPIO: GPIO_PIN_25 (Pull: GPIO_PULL_NONE)
RST GPIO: GPIO_PIN_UNKNOWN
Backlight GPIO: GPIO_PIN_2 (STMPE GPIO)
STMPE (Resistive touch)
Chip: STMPE_CHIP_610
SPI Mode: 0
SPI Frequency: 500000
SPI Chip Select: SPI_CS_1
IRQ GPIO: GPIO_PIN_24 (Trigger: GPIO_TRIGGER_FALLING)(Pull: GPIO_PULL_UP)
FT6236 (Capacitive touch)
I2C Address: 0x38
IRQ GPIO: GPIO_PIN_24 (Trigger: GPIO_TRIGGER_FALLING)(Pull: GPIO_PULL_UP)
Switches
SW1 GPIO: GPIO_PIN_22
SW2 GPIO: GPIO_PIN_27
SW3 GPIO: GPIO_PIN_17
SW4 GPIO: GPIO_PIN_23
Constants
PITFT28_*
PITFT28_FRAMEBUFFER_DESCRIPTION = 'Adafruit PiTFT 2.8" LCD';
|
Description of PiTFT28 device |
PITFT28_SIGNATURE = $AF000028;
|
|
PITFT28_SCREEN_WIDTH = 240;
|
|
PITFT28_SCREEN_HEIGHT = 320;
|
PITFT28_LCD_*
PITFT28_LCD_DC = GPIO_PIN_25;
|
|
PITFT28_TOUCH_IRQ = GPIO_PIN_24;
|
|
NAPITFT28_LCD_BL = GPIO_PIN_2;
|
STMPE GPIO |
Type definitions
PiTFT28 specific types
PPiTFT28LCD = ^TPiTFT28LCD;
TPiTFT28LCD = record
Signature:LongWord;
|
Signature for entry validation |
Rotation:LongWord;
|
Framebuffer rotation (eg FRAMEBUFFER_ROTATION_180) |
SPI:PSPIDevice;
|
SPI device for this display |
I2C:PI2CDevice;
|
I2C device for this display |
GPIO:PGPIODevice;
|
GPIO device for this display |
Touch:PTouchDevice;
|
Touch (STMPE or FT6236) device for this display |
Backlight:PGPIODevice;
|
Backlight GPIO (STMPE) device for this display |
Framebuffer:PFramebufferDevice;
|
Framebuffer (ILI9340) device for this display |
Public variables
PiTFT28 specific variables
PITFT28_SPI_DEVICE:String = 'SPI0';
|
PITFT28_LCD_CHIPSELECT:Word = SPI_CS_0;
|
PITFT28_TOUCH_CHIPSELECT:Word = SPI_CS_1;
|
PITFT28_I2C_DEVICE:String = 'I2C0';
|
PITFT28_TOUCH_ADDRESS:Word = $38;
|
Function declarations
Initialization functions
procedure PiTFT28Init;
Note | Called only during system startup |
---|
function PiTFT28Start(Rotation:LongWord; const Device:String; DisplaySelect,TouchSelect:Word):THandle; inline;
Rotation | The rotation of the display (eg FRAMEBUFFER_ROTATION_180) |
---|---|
Device | The SPI device that the ILI9340 and STMPE610 devices are connected to |
DisplaySelect | The SPI chip select of the ILI9340 LCD controller |
TouchSelect | The SPI chip select of the STMPE610 touch controller |
Return | The handle of the PiTFT28 on success or INVALID_HANDLE_VALUE on failure |
Note | This function will be called during startup if the parameter PITFT28_AUTOSTART is True
Can be called multiple times to support more than one PiTFT LCD display |
Note | Replaced by PiTFT28ResistiveStart to accommodate capacitive display option |
function PiTFT28ResistiveStart(Rotation:LongWord; const Device:String; DisplaySelect,TouchSelect:Word):THandle;
Rotation | The rotation of the display (eg FRAMEBUFFER_ROTATION_180) |
---|---|
Device | The SPI device that the ILI9340 and STMPE610 devices are connected to |
DisplaySelect | The SPI chip select of the ILI9340 LCD controller |
TouchSelect | The SPI chip select of the STMPE610 touch controller |
Return | The handle of the PiTFT28 on success or INVALID_HANDLE_VALUE on failure |
Note | This function will be called during startup if the parameter PITFT28_AUTOSTART is True
Can be called multiple times to support more than one PiTFT LCD display |
function PiTFT28CapacitiveStart(Rotation:LongWord; const SPIDevice,I2CDevice:String; DisplaySelect,TouchAddress:Word):THandle;
Rotation | The rotation of the display (eg FRAMEBUFFER_ROTATION_180) |
---|---|
SPIDevice | The SPI device that the ILI9340 device is connected to |
I2CDevice | The I2C device that the FT6236 device is connected to |
DisplaySelect | The SPI chip select of the ILI9340 LCD controller |
TouchAddress | The I2C address of the FT6236 touch controller |
Return | The handle of the PiTFT28 on success or INVALID_HANDLE_VALUE on failure |
Note | This function will be called during startup if the parameter PITFT28_AUTOSTART is True
Can be called multiple times to support more than one PiTFT LCD display |
function PiTFT28Stop(Handle:THandle):Boolean;
Handle | The handle of the PiTFT28 or INVALID_HANDLE_VALUE for the default display |
---|---|
Return | True if completed or False on failure |
Return to Unit Reference