Skip to content

Commit

Permalink
Merge pull request letscontrolit#5079 from tonhuisman/feature/P095-ad…
Browse files Browse the repository at this point in the history
…d-working-support-for-ili9488

[P095] Add support for ILI9486/ILI9488 Displays
  • Loading branch information
TD-er authored Jul 10, 2024
2 parents 0a45bd6 + e8eeda4 commit 2c80c74
Show file tree
Hide file tree
Showing 15 changed files with 1,814 additions and 229 deletions.
77 changes: 50 additions & 27 deletions docs/source/Plugin/P095.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ The text on most displays is somewhat confusing, as not the usual SPI names are
3V3 --- VCC (most displays only support 3.3V)
GND --- GND
MOSI --> SDA/SDI
MISO --> SDO/DO (optional, not used)
CLK --> SCL/SCK
(gpio) --> DC
(gpio) --> CS
Expand All @@ -68,23 +69,35 @@ Device configuration
.. image:: P095_DeviceConfiguration.png
:alt: Device configuration

* **Name** A unique name should be entered here.
* **Name**: A unique name should be entered here.

* **Enabled** The device can be disabled or enabled. When not enabled the device should not use any resources.
* **Enabled**: The device can be disabled or enabled. When not enabled the device should not use any resources.

Actuator
^^^^^^^^

* **GPIO -> TFT CS** Select the GPIO pin to use for the ``CS`` connection. If the display doesn't have a ``CS`` connection it can be set to *None*.
* **GPIO -> TFT DC** The GPIO pin to use for the ``DC`` connection (Data/Command).
* **GPIO -> TFT RST** Select the GPIO pin to use for the ``RES`` (reset) connection. If the display doesn't have a ``RES`` (or RST) connection, or no free pin is available, it can be set to *None*. If it is set to None, for proper operation it may need too be wired to the Reset connection on the ESP, so the device is initialized correctly.
* **GPIO -> Backlight (optional)** Select the GPIO pin to use for controlling the backlight. To save power, the backlight can be dimmed, or turned off if the display is turned off. If set to *None*, usually the max. brightness is used for the backlight.
* **Backlight percentage** The backlight can be controlled via PWM modulation on the Backlight (BLK) pin of the display. This is set as a percentage between 1 and 100.
* **Display button** A GPIO pin can be configured to wake the display on demand. This, combined with the **Display Timeout** setting, can preserve the lifetime of the display, and save some power.
* **Inversed Logic** When checked, reverses the pin-state action of the **Display button** gpio. This allows an external circuit, f.e. an IR sensor, that may provide a *high* signal when activated, to wake the display.
* **Display Timeout** Select the timeout in seconds to turn off the display after the last update or wake-up. Only used if the **Display button** is *also* configured.
* **TFT Display model** Select the hardware model that is connected. Currently there are only preset resolutions available.
* **Invert display** Default value for Invert display, some displays have foreground and background colors swapped (f.e. M5Stack Core2 using ILI9342C), this option is applied at plugin initialization.
* **GPIO -> TFT CS**: Select the GPIO pin to use for the ``CS`` connection. If the display doesn't have a ``CS`` connection it can be set to *None*.

* **GPIO -> TFT DC**: The GPIO pin to use for the ``DC`` connection (Data/Command).

* **GPIO -> TFT RST**: Select the GPIO pin to use for the ``RES`` (reset) connection. If the display doesn't have a ``RES`` (or RST) connection, or no free pin is available, it can be set to *None*. If it is set to None, for proper operation it may need too be wired to the Reset connection on the ESP, so the device is initialized correctly.

Device Settings
^^^^^^^^^^^^^^^

* **GPIO -> Backlight (optional)**: Select the GPIO pin to use for controlling the backlight. To save power, the backlight can be dimmed, or turned off if the display is turned off. If set to *None*, usually the max. brightness is used for the backlight, but sometimes the BL/LED pin of the display has to be connected to ``VCC`` to get the content visible.

* **Backlight percentage**: The backlight can be controlled via PWM modulation on the Backlight (BLK) pin of the display. This is set as a percentage between 1 and 100.

* **Display button**: A GPIO pin can be configured to wake the display on demand. This, combined with the **Display Timeout** setting, can preserve the lifetime of the display, and save some power.

* **Inversed Logic**: When checked, reverses the pin-state action of the **Display button** gpio. This allows an external circuit, f.e. an IR sensor, that may provide a *high* signal when activated, to wake the display.

* **Display Timeout**: Select the timeout in seconds to turn off the display after the last update or wake-up. Only used if the **Display button** is *also* configured.

* **TFT Display model**: Select the hardware model that is connected. Currently there are only preset resolutions available.

* **Invert display**: Default value for Invert display, some displays have foreground and background colors swapped (f.e. M5Stack Core2 using ILI9342C and some ILI9486/ILI9488 models), this option is applied at plugin initialization.

Available options:

Expand All @@ -94,10 +107,12 @@ Available options:
.. warning::
The **ILI9481** display controller does have issues when rotating, by using the ``<trigger>,rot,<n>`` command, to change the display orientation after some content is already displayed on the screen (content may move, rotate and/or mirror unexpectedly). It is advised to clear the screen after changing the rotation setting.

.. note:: ILI9486 displays tested so far (sourced from Aliexpress) either are *compatible* with ILI9488 or **are** ILI9488 displays, that's why they share the same entry in the list. If you find an ILI9486 display that doesn't work with this setting, please raise an issue in ESPEasy Github Issues list, so this can be adjusted.

Layout
^^^^^^^^

* **Rotation** Depending on how the display is to be mounted/installed, it may be needed to rotate the content, or with a non-square resolution, to use the display in *Landscape* layout instead of the default *Portrait*.
* **Rotation**: Depending on how the display is to be mounted/installed, it may be needed to rotate the content, or with a non-square resolution, to use the display in *Landscape* layout instead of the default *Portrait*.

Available options:

Expand All @@ -120,13 +135,18 @@ Available options:

Default setting is *Continue to next line*.

* **Font scaling** The scaling factor for the currently active font. Select a factor between 1 and 10.
* **Default font**: If fonts are available in the build (excluded from some builds because of .bin size issues), the default font at initialization can be selected. The names/numbers that can be used in the ``<trigger>,font,<fontname|fontnr>`` are shown in the combobox, and documented below in the **AdafruitGFX_Helper** documentation. The font numbers aren't consecutive if all fonts aren't included, to keep them consistent across builds.

.. image:: P095_DefaultFontOptions.png
:alt: Default font

* **Font scaling**: The scaling factor for the currently active font. Select a factor between 1 and 10.

* **Show splash on start** When available, and enabled, will show an ESPEasy & plugin name text-splash during start of the plugin. If also some content is configured, this will be written over the splash, as that is not cleared after being displayed.
* **Show splash on start**: When available, and enabled, will show an ESPEasy & plugin name text-splash during start of the plugin. If also some content is configured, this will be written over the splash, as that is not cleared after being displayed.

* **Clear display on exit** When checked, will clear the display when the task is disabled, either from settings or via the ``TaskDisable`` command. The screen will be turned off, and when a backlight pin is configured, also the backlight is turned off.
* **Clear display on exit**: When checked, will clear the display when the task is disabled, either from settings or via the ``TaskDisable`` command. The screen will be turned off, and when a backlight pin is configured, also the backlight is turned off.

* **Write Command trigger** The command to handle any commands for this device can be selected here. This can make the commands compatible with other (tft) displays, using the same command structure via the ESPEasy Adafruit Graphics helper class.
* **Write Command trigger**: The command to handle any commands for this device can be selected here. This can make the commands compatible with other (tft) displays, using the same command structure via the ESPEasy Adafruit Graphics helper class.

Available options:

Expand All @@ -142,19 +162,20 @@ Available options:

The command is handled non-case sensitive. See below for available commands and subcommands.

* **Wake display on receiving text** When checked, the display will be enabled once any content is written to the screen, either triggered by the Interval, or from a command. Default checked.
* **Wake display on receiving text**: When checked, the display will be enabled once any content is written to the screen, either triggered by the Interval, or from a command. Default checked.

* **Text Coordinates in col/row** When checked, the coordinates for the ``txp``, ``txz`` and ``txtfull`` subcommands will be handled in cursor columns & rows, instead of pixels. Column and row are calculated from the current font size and font scaling settings.
* **Text Coordinates in col/row**: When checked, the coordinates for the ``txp``, ``txz`` and ``txtfull`` subcommands will be handled in cursor columns & rows, instead of pixels. Column and row are calculated from the current font size and font scaling settings.

* **Use -1px offset for txp & txtfull** For backward compatibility with the previous, non-AdafruitGFX_helper based, plugin implementation, that used 0-based coordinates, an offset of -1 pixel can be applied to the ``txp``, ``txz`` and ``txtfull`` subcommands. This option is enabled by default.
* **Use -1px offset for txp & txtfull**: For backward compatibility with the previous, non-AdafruitGFX_helper based, plugin implementation, that used 0-based coordinates, an offset of -1 pixel can be applied to the ``txp``, ``txz`` and ``txtfull`` subcommands. This option is enabled by default.

* **Background-fill for text** When checked, for any text-line sent to the screen, the entire background (including top and bottom lines) will have the provided background color, *unless* transparent is used (Background color == Foreground color). Default checked.
* **Background-fill for text**: When checked, for any text-line sent to the screen, the entire background (including top and bottom lines) will have the provided background color, *unless* transparent is used (Background color == Foreground color). Default checked.

Content
^^^^^^^^

* **Foreground color**
* **Background color**
* **Foreground color**:

* **Background color**:

These are the default colors, used to display the content as configured below (if any). The background color is also used as the Clear screen color.

Expand All @@ -166,22 +187,22 @@ Colors can be specified in 3 ways:

If the Foreground and Background colors are the same, the background color will become ``transparent``. If the Forground color is empty, as a default ``white`` will be set.

* **Line 1..24** Predefined content can be specified. The number of lines available depends on the size of the display, the font used, the font scaling that is set and the selected rotation.
* **Line 1..24**: Predefined content can be specified. The number of lines available depends on the size of the display, the font used, the font scaling that is set and the selected rotation.

The usual variables, like ``[Taskname#Valuename]``, or ``%v1%``, system variables, formulas and functions can be used.

Input length is limited to 60 characters per line. If a longer calculated text is needed for a line, then it should be set from the rules or from an external source via http commands.

Next to Line 24, the remaining capacity in characters is displayed.

The total combination of lines * input length can not exceed 1000 characters (sized dynamically), as there is limited storage per task available for these settings. An error message will be shown after (trying to) save the settings, **any excess content will be discarded!**
The total combination of lines * input length can not exceed 5192 characters (1000 on some builds) (sized dynamically), as there is limited storage per task available for these settings. An error message will be shown after (trying to) save the settings, **any excess content will be discarded!**

Example:

.. image:: P095_SaveError.png
:alt: Save error

* **Interval** By default, Interval will be set to 0. If set to a non-zero value, the pre-configured content will be updated automatically using that interval (seconds). Depending on the **Text print Mode** setting, content that may have been draw from rules or external commands, may be erased.
* **Interval**: By default, Interval will be set to 0. If set to a non-zero value, the pre-configured content will be updated automatically using that interval (seconds). Depending on the **Text print Mode** setting, content that may have been draw from rules or external commands, may be erased.

Values
^^^^^^
Expand Down Expand Up @@ -209,6 +230,8 @@ Change log
.. versionchanged:: 2.0
...

|added| 2020-04-20 Initially added
|added| 2024-07-07 Add support for ILI9486/ILI9488 displays.

|added| 2022-04-23 Rewrite of the plugin based on AdafruitGFX_helper, udated documentation based on shared settings with :ref:`P116_page` and AdafruitGFX_helper

|added| 2020-04-20 Initially added
Binary file added docs/source/Plugin/P095_DefaultFontOptions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/Plugin/P095_DeviceConfiguration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/Plugin/P095_TFTDisplayModelOptions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
116 changes: 0 additions & 116 deletions lib/Adafruit_ILI9341/Adafruit_ILI9341.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,82 +448,6 @@ static const uint8_t PROGMEM initcmd_9481_CMI8[] = { // ILI9481 CMI8 (TFT_eSPI I

// clang-format on

#ifdef ILI9341_ENABLE_ILI948X

// clang-format off
static const uint8_t PROGMEM initcmd_9486[] = { // ILI9486
ILI9341_SLPOUT, 0x80, // Exit Sleep
ILI9341_PIXFMT, 1, 0x55, // Pixel format 0x55=16bit, 0x66=18bit
ILI9341_PWCTR3, 1, 0x44, // Power control3
ILI9341_VMCTR1, 4, 0x00, 0x00, 0x00, 0x00, // VCM control
ILI9341_GMCTRP1, 15, 0x0F, 0x1F, 0x1c, 0x0C, 0x0F, 0x08, 0x48, 0x98, 0x37, 0x0A, 0x13, 0x04, 0x11, 0x0D, 0x00,
ILI9341_GMCTRN1, 15, 0x0F, 0x32, 0x2E, 0x0B, 0x0D, 0x05, 0x47, 0x75, 0x37, 0x06, 0x10, 0x03, 0x24, 0x20, 0x00,
ILI9341_INVOFF, 0,
ILI9341_MADCTL, 1, 0x48, // Memory Access Control
ILI9341_DISPON, 0x80, // Display on
0x00 // End of list
};

// clang-format on

// clang-format off
static const uint8_t PROGMEM initcmd_9488[] = { // ILI9488
// Set gamma
ILI9341_GMCTRP1, 15, 0x00, 0x03, 0x09, 0x08, 0x16, 0x0A,
0x3F, 0x78, 0x4C, 0x09, 0x0A, 0x08, 0x16, 0x1A,
0x0F,

// Set gamma
ILI9341_GMCTRN1, 15, 0x00, 0x16, 0x19, 0x03, 0x0F, 0x05,
0x32, 0x45, 0x46, 0x04, 0x0E, 0x0D, 0x35, 0x37,
0x0F,

// Power control VRH[5:0]
ILI9341_PWCTR1, 2, 0x17, 0x15,

// Power control SAP[2:0];BT[3:0]
ILI9341_PWCTR2, 1, 0x41,

// VCM control
ILI9341_VMCTR1, 3, 0x00, 0x12, 0x80,

// Memory access Control
ILI9341_MADCTL, 1, 0x48,

// Pixel format 0x55=16bit, 0x66=18bit
ILI9341_PIXFMT, 1, 0x55,

// Interface control Mode
0xB0, 1, 0x80,

// Frame rate
ILI9341_FRMCTR1, 1, 0xA0,

// Display onversion control
ILI9341_INVCTR, 1, 0x02,

// Display function control
ILI9341_DFUNCTR, 2, 0x02, 0x02,

// Disable 24 bit data
0xE9, 1, 0x00,

// Adjust control
0xF7, 4, 0xA9, 0x51, 0x2C, 0x82,

// Exit sleep
ILI9341_SLPOUT, 0x80,

// Display on
ILI9341_DISPON, 0x80,

// End of list
0x00
};
#endif // ifdef ILI9341_ENABLE_ILI948X

// clang-format on

/**************************************************************************/

/*!
Expand Down Expand Up @@ -578,14 +502,6 @@ void Adafruit_ILI9341::begin(uint32_t freq) {
case ILI_TYPE_9481_CMI8: // ILI9481 CMI8
addr = initcmd_9481_CMI8;
break;
#ifdef ILI9341_ENABLE_ILI948X
case ILI_TYPE_9486: // ILI9486
addr = initcmd_9486;
break;
case ILI_TYPE_9488: // ILI9488
addr = initcmd_9488;
break;
#endif // ifdef ILI9341_ENABLE_ILI948X
default:
addr = initcmd;
break;
Expand Down Expand Up @@ -637,14 +553,6 @@ void Adafruit_ILI9341::setRotation(uint8_t m) {
case ILI_TYPE_9341: // ILI9341
// m = (MADCTL_MX | MADCTL_BGR);
// break;
#ifdef ILI9341_ENABLE_ILI948X
case ILI_TYPE_9486: // ILI9486
// m = (MADCTL_MX | MADCTL_BGR);
// break;
case ILI_TYPE_9488: // ILI9488
// m = (MADCTL_MX | MADCTL_BGR);
// break;
#endif // ifdef ILI9341_ENABLE_ILI948X
default:
m = (MADCTL_MX | MADCTL_BGR);
break;
Expand All @@ -671,14 +579,6 @@ void Adafruit_ILI9341::setRotation(uint8_t m) {
case ILI_TYPE_9341: // ILI9341
// m = (MADCTL_MV | MADCTL_BGR);
// break;
#ifdef ILI9341_ENABLE_ILI948X
case ILI_TYPE_9486: // ILI9486
// m = (MADCTL_MV | MADCTL_BGR);
// break;
case ILI_TYPE_9488: // ILI9488
// m = (MADCTL_MV | MADCTL_BGR);
// break;
#endif // ifdef ILI9341_ENABLE_ILI948X
default:
m = (MADCTL_MV | MADCTL_BGR);
break;
Expand All @@ -705,14 +605,6 @@ void Adafruit_ILI9341::setRotation(uint8_t m) {
case ILI_TYPE_9341: // ILI9341
// m = (MADCTL_MY | MADCTL_BGR);
// break;
#ifdef ILI9341_ENABLE_ILI948X
case ILI_TYPE_9486: // ILI9486
// m = (MADCTL_MY | MADCTL_BGR);
// break;
case ILI_TYPE_9488: // ILI9488
// m = (MADCTL_MY | MADCTL_BGR);
// break;
#endif // ifdef ILI9341_ENABLE_ILI948X
default:
m = (MADCTL_MY | MADCTL_BGR);
break;
Expand All @@ -739,14 +631,6 @@ void Adafruit_ILI9341::setRotation(uint8_t m) {
case ILI_TYPE_9341: // ILI9341
// m = (MADCTL_MX | MADCTL_MY | MADCTL_MV | MADCTL_BGR);
// break;
#ifdef ILI9341_ENABLE_ILI948X
case ILI_TYPE_9486: // ILI9486
// m = (MADCTL_MX | MADCTL_MY | MADCTL_MV | MADCTL_BGR);
// break;
case ILI_TYPE_9488: // ILI9488
// m = (MADCTL_MX | MADCTL_MY | MADCTL_MV | MADCTL_BGR);
// break;
#endif // ifdef ILI9341_ENABLE_ILI948X
default:
m = (MADCTL_MX | MADCTL_MY | MADCTL_MV | MADCTL_BGR);
break;
Expand Down
6 changes: 0 additions & 6 deletions lib/Adafruit_ILI9341/Adafruit_ILI9341.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
#include <Adafruit_SPITFT_Macros.h>
#include <SPI.h>

// #define ILI9341_ENABLE_ILI948X ///< Enable ILI9486 and ILI9488 support, MUST reflect a similar #define in P095_data_struct.h !

#define ILI9341_TFTWIDTH 240 ///< ILI9341 max TFT width
#define ILI9341_TFTHEIGHT 320 ///< ILI9341 max TFT height

Expand Down Expand Up @@ -138,10 +136,6 @@
#define ILI_TYPE_9481_RGB 7
#define ILI_TYPE_9481_CMI7 8
#define ILI_TYPE_9481_CMI8 9
#ifdef ILI9341_ENABLE_ILI948X
# define ILI_TYPE_9486 10
# define ILI_TYPE_9488 11
#endif // ifndef ILI9341_ENABLE_ILI948X

/**************************************************************************/

Expand Down
Loading

0 comments on commit 2c80c74

Please sign in to comment.