This module provides a device-level API for ILI9341-driven TFT displays over the 4-wire serial (SPI) interface: SCK/MOSI/MISO/CS carried by the SPI bus itself, plus a separate /DC (data/command select) GPIO this driver toggles around each command, and an optional /RESET GPIO for boards that don't generate reset on their own.
More...
This module provides a device-level API for ILI9341-driven TFT displays over the 4-wire serial (SPI) interface: SCK/MOSI/MISO/CS carried by the SPI bus itself, plus a separate /DC (data/command select) GPIO this driver toggles around each command, and an optional /RESET GPIO for boards that don't generate reset on their own.
- Note
- The device handle passed to dev_ili9341_init() must already be open at the controller's required SPI mode. This driver only issues transfers on it; it does not open or configure the bus itself.
◆ dev_ili9341_default_config()
Fill an ILI9341 config struct with safe defaults.
- Parameters
-
| config | Config structure to initialize. |
◆ dev_ili9341_deinit()
Deinitialize an ILI9341 handle.
- Parameters
-
Passing NULL is safe and is a no-op.
◆ dev_ili9341_init()
Initialize an ILI9341-driven display over SPI.
- Parameters
-
| device | SPI device handle from hw_spi_init() / hw_spi_init_default() / hw_spi_init_device(), already open at hw_spi_mode_3. |
| dc_pin | GPIO handle for /DC (data/command select). Required - the 4-wire serial protocol has no way to convey this otherwise. |
| rst_pin | Optional GPIO handle for /RESET. Pass NULL on boards that generate reset on their own (see the module-level note above); the panel is then reset via its software-reset command instead. |
| config | Optional pointer to initialization options. Pass NULL to use default values. |
- Returns
- ILI9341 handle, or
NULL on failure - including an config->rotation other than 0, 90, 180, or 270.
◆ dev_ili9341_size()
Get the display size at the configured rotation.
- Parameters
-
| ili9341 | ILI9341 handle. |
| out_size | Output destination for the display size. Left unmodified if ili9341 is invalid. |
◆ dev_ili9341_write()
Write a rectangular block of pixels.
- Parameters
-
| ili9341 | ILI9341 handle. |
| origin | Top-left corner to write to, within the current rotation's bounds. |
| bitmap | Source bitmap. Must be PIX_FMT_RGB565, with each pixel already stored big-endian (MSB first) - the byte order the wire protocol itself requires. This function sends bitmap->data as-is with no per-pixel conversion, so a bitmap built with native multi-byte writes (e.g. uint16_t pixels[i] = 0xF800) on a little-endian host must be byte-swapped by the caller first. bitmap->stride is honored, so the source need not be tightly packed. |
- Return values
-
| true | Write succeeded. |
| false | The handle is invalid, bitmap is NULL or not PIX_FMT_RGB565, or the rectangle falls outside the current rotation's bounds. |