|
SatCat5
|
Display device driver for the ILI9341.
The ILI9341 is an ASIC for driving 320x240 TFT LCD displays. It uses an SPI interface to update an internal frame buffer. Other interface options are not supported by this driver.
The ILI9341 ASIC is used in several off-the-shelf display modules:
This driver supports all API methods, including scrolling viewports. Due to the limited SPI bandwidth, a complete screen refresh takes at least 122 msec. As a result, this gui::Display driver must always be used with a buffered gui::Canvas object.
The SPI controller is required to drive the "DCX" pin. The ILI9341 uses this to distinguish commands from data, deasserting DCX for the first byte in each SPI transaction.
The complete ISI9341 datasheet can be found on the Adafruit website.
Startup sequence and color definitions are adapted from the Adafruit ILI9341 Arduino Library, which uses the MIT license.
Definition at line 42 of file spi_ili9341.h.
#include <spi_ili9341.h>
Public Member Functions | |
| Ili9341 (satcat5::cfg::SpiGeneric *spi, u8 devidx, u8 madctl=ADAFRUIT_ROT0) | |
| Constructor links to the specified SPI interface. More... | |
| bool | busy () const |
| Busy with initialization or a previous command? | |
| bool | invert (bool inv) |
| Invert entire display. More... | |
| void | reset () |
| Initiate software reset. | |
| u16 | scroll_pos () const |
| Current scroll position. | |
| bool | viewport (u16 top, u16 size) |
| Configure the scrolling viewport: More... | |
| void | timer_once (unsigned msec) |
| Configure a one-time notification after X milliseconds. | |
| void | timer_every (unsigned msec) |
| Configure a repeating notification every X milliseconds. | |
| void | timer_stop () |
| Stop all future notifications. | |
| unsigned | timer_interval () const |
| Accessor for recurring timer interval, if one is set. | |
| unsigned | timer_remaining () const |
| Accessor for time to next event, if one is set. | |
| u16 | height () const |
| Total size of the display, in pixels. | |
| u16 | width () const |
| Total size of the display, in pixels. | |
Static Public Member Functions | |
| static unsigned | count_timer () |
| Count all objects of this type, including idle timers. | |
Static Public Attributes | |
| static constexpr satcat5::gui::LogColors | DARK_THEME |
| Recommended colors for dark theme (white text on black). More... | |
| static constexpr satcat5::gui::LogColors | LIGHT_THEME |
| Recommended colors for light theme (black text on white). More... | |
| static constexpr u8 | MADCTL_MY = 0x80 |
| Constants for the MADCTL register (Section 8.2.29). More... | |
| static constexpr u8 | MADCTL_MX = 0x40 |
| Constants for the MADCTL register (Section 8.2.29). More... | |
| static constexpr u8 | MADCTL_MV = 0x20 |
| Constants for the MADCTL register (Section 8.2.29). More... | |
| static constexpr u8 | MADCTL_ML = 0x10 |
| Constants for the MADCTL register (Section 8.2.29). More... | |
| static constexpr u8 | MADCTL_BGR = 0x08 |
| Constants for the MADCTL register (Section 8.2.29). More... | |
| static constexpr u8 | MADCTL_MH = 0x04 |
| Constants for the MADCTL register (Section 8.2.29). More... | |
| static constexpr u8 | ADAFRUIT_ROT0 = MADCTL_BGR | MADCTL_MX |
| Adafruit panels all use BGR mode with MH = 0. More... | |
| static constexpr u8 | ADAFRUIT_ROT90 = MADCTL_BGR | MADCTL_MV |
| Adafruit panels all use BGR mode with MH = 0. More... | |
| static constexpr u8 | ADAFRUIT_ROT180 = MADCTL_BGR | MADCTL_MY |
| Adafruit panels all use BGR mode with MH = 0. More... | |
| static constexpr u8 | ADAFRUIT_ROT270 = MADCTL_BGR | MADCTL_MX | MADCTL_MY | MADCTL_MV |
| Adafruit panels all use BGR mode with MH = 0. More... | |
| static constexpr u16 | COLOR_BLACK = 0x0000 |
| Constant definitions for 16-bit color mode. | |
| static constexpr u16 | COLOR_NAVY = 0x000F |
| Constant definitions for 16-bit color mode. | |
| static constexpr u16 | COLOR_DARKGREEN = 0x03E0 |
| Constant definitions for 16-bit color mode. | |
| static constexpr u16 | COLOR_DARKCYAN = 0x03EF |
| Constant definitions for 16-bit color mode. | |
| static constexpr u16 | COLOR_MAROON = 0x7800 |
| Constant definitions for 16-bit color mode. | |
| static constexpr u16 | COLOR_PURPLE = 0x780F |
| Constant definitions for 16-bit color mode. | |
| static constexpr u16 | COLOR_OLIVE = 0x7BE0 |
| Constant definitions for 16-bit color mode. | |
| static constexpr u16 | COLOR_LIGHTGREY = 0xC618 |
| Constant definitions for 16-bit color mode. | |
| static constexpr u16 | COLOR_DARKGREY = 0x7BEF |
| Constant definitions for 16-bit color mode. | |
| static constexpr u16 | COLOR_BLUE = 0x001F |
| Constant definitions for 16-bit color mode. | |
| static constexpr u16 | COLOR_GREEN = 0x07E0 |
| Constant definitions for 16-bit color mode. | |
| static constexpr u16 | COLOR_CYAN = 0x07FF |
| Constant definitions for 16-bit color mode. | |
| static constexpr u16 | COLOR_RED = 0xF800 |
| Constant definitions for 16-bit color mode. | |
| static constexpr u16 | COLOR_MAGENTA = 0xF81F |
| Constant definitions for 16-bit color mode. | |
| static constexpr u16 | COLOR_YELLOW = 0xFFE0 |
| Constant definitions for 16-bit color mode. | |
| static constexpr u16 | COLOR_WHITE = 0xFFFF |
| Constant definitions for 16-bit color mode. | |
| static constexpr u16 | COLOR_ORANGE = 0xFD20 |
| Constant definitions for 16-bit color mode. | |
| static constexpr u16 | COLOR_GRELLOW = 0xAFE5 |
| Constant definitions for 16-bit color mode. | |
| static constexpr u16 | COLOR_PINK = 0xFC18 |
| Constant definitions for 16-bit color mode. | |
Protected Member Functions | |
| bool | draw (const satcat5::gui::Cursor &cursor, const satcat5::gui::DrawCmd &cmd) override |
| Draw pixels to the screen at the designated location. More... | |
| bool | scroll (s16 rows) override |
| Optional: Advance the predefined viewport by N pixels. More... | |
| void | spi_done (unsigned nread, const u8 *rbytes) override |
| void | timer_event () override |
| Child class MUST override this method. | |
| bool | in_viewport (u16 row) const |
| void | draw_next () |
| void | init_next () |
| bool | spi_cmd (u8 len, const u8 *cmd, Ili9341 *callback) |
| bool | spi_madctl () |
| bool | spi_vscrdef () |
| void | try_twidth (u16 width) |
Protected Attributes | |
| satcat5::cfg::SpiGeneric *const | m_spi |
| satcat5::gui::Cursor | m_cursor |
| satcat5::gui::DrawCmd | m_draw_cmd |
| const u8 | m_devidx |
| const u8 | m_madctl |
| u16 | m_init_step |
| u16 | m_scroll |
| u16 | m_viewtop |
| u16 | m_viewsize |
| u16 | m_draw_step |
| u16 | m_draw_done |
| u16 | m_tile_col |
| u16 | m_tile_row |
| u16 | m_tile_width |
| u16 | m_tile_height |
| const u16 | m_height |
| Total size of the display, in pixels. More... | |
| const u16 | m_width |
Private Member Functions | |
| void | query (unsigned elapsed_msec) |
Private Attributes | |
| satcat5::poll::Timer * | m_next |
| unsigned | m_trem |
| unsigned | m_tnext |
| Ili9341::Ili9341 | ( | satcat5::cfg::SpiGeneric * | spi, |
| u8 | devidx, | ||
| u8 | madctl = ADAFRUIT_ROT0 |
||
| ) |
Constructor links to the specified SPI interface.
SPI rate is controlled by parent, recommend 10 Mbps. A separate GPO pin is required for the D/CX signal.
Definition at line 112 of file spi_ili9341.cc.
|
overrideprotectedvirtual |
Draw pixels to the screen at the designated location.
Child class MUST implement this method. Returns false if the command should be repeated.
Implements satcat5::gui::Display.
Definition at line 162 of file spi_ili9341.cc.
| bool Ili9341::invert | ( | bool | inv | ) |
Invert entire display.
Definition at line 138 of file spi_ili9341.cc.
|
overrideprotectedvirtual |
Optional: Advance the predefined viewport by N pixels.
Positive values scroll down, wrapping upper rows to the bottom of viewport. Negative values scroll up. Child class MAY implement this method if applicable. Returns false if the command should be repeated.
Reimplemented from satcat5::gui::Display.
Definition at line 194 of file spi_ili9341.cc.
| bool Ili9341::viewport | ( | u16 | top, |
| u16 | size | ||
| ) |
Configure the scrolling viewport:
Definition at line 150 of file spi_ili9341.cc.
|
staticconstexpr |
Adafruit panels all use BGR mode with MH = 0.
Use the MX, MY, and MV bits to set orientation.
Definition at line 64 of file spi_ili9341.h.
|
static |
Adafruit panels all use BGR mode with MH = 0.
Use the MX, MY, and MV bits to set orientation.
Definition at line 66 of file spi_ili9341.h.
|
static |
Adafruit panels all use BGR mode with MH = 0.
Use the MX, MY, and MV bits to set orientation.
Definition at line 67 of file spi_ili9341.h.
|
static |
Adafruit panels all use BGR mode with MH = 0.
Use the MX, MY, and MV bits to set orientation.
Definition at line 65 of file spi_ili9341.h.
|
staticconstexpr |
Recommended colors for dark theme (white text on black).
Definition at line 123 of file spi_ili9341.h.
|
staticconstexpr |
Recommended colors for light theme (black text on white).
Definition at line 132 of file spi_ili9341.h.
|
protectedinherited |
Total size of the display, in pixels.
The child must set these parameters in the constructor.
Definition at line 135 of file gui_display.h.
|
static |
Constants for the MADCTL register (Section 8.2.29).
This sets the panel type and panel rotation.
Definition at line 56 of file spi_ili9341.h.
|
static |
Constants for the MADCTL register (Section 8.2.29).
This sets the panel type and panel rotation.
Definition at line 57 of file spi_ili9341.h.
|
static |
Constants for the MADCTL register (Section 8.2.29).
This sets the panel type and panel rotation.
Definition at line 55 of file spi_ili9341.h.
|
static |
Constants for the MADCTL register (Section 8.2.29).
This sets the panel type and panel rotation.
Definition at line 54 of file spi_ili9341.h.
|
static |
Constants for the MADCTL register (Section 8.2.29).
This sets the panel type and panel rotation.
Definition at line 53 of file spi_ili9341.h.
|
staticconstexpr |
Constants for the MADCTL register (Section 8.2.29).
This sets the panel type and panel rotation.
Definition at line 52 of file spi_ili9341.h.