mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
Merge pull request #5350 from tonhuisman/feature/P095-add-ili9342-variants
[P095] Add ILI9342 display variants
This commit is contained in:
@@ -97,18 +97,22 @@ Device Settings
|
||||
|
||||
* **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:
|
||||
|
||||
.. image:: P095_TFTDisplayModelOptions.png
|
||||
:alt: TFT Display model options
|
||||
|
||||
The available options here depend on the build used, as some are only available on ESP32 because they won't fit in an ESP8266 build.
|
||||
|
||||
Some of the display controllers need the **Invert display** setting checked to show the correct colors.
|
||||
|
||||
.. 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.
|
||||
|
||||
* **Invert display**: When checked will Invert display colors, as some displays have foreground and background colors swapped (f.e. M5Stack Core2 using ILI9342C, some ILI9342 CYD (Cheap Yellow Display) boards, and some ILI9486/ILI9488 models), this option is applied at plugin initialization.
|
||||
|
||||
Layout
|
||||
^^^^^^^^
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 62 KiB |
@@ -238,6 +238,83 @@ static const uint8_t PROGMEM initcmd_9342[] = { // ILI9342
|
||||
|
||||
// clang-format on
|
||||
|
||||
#ifdef ESP32
|
||||
// clang-format off
|
||||
static const uint8_t PROGMEM initcmd_9342_2[] = { // ILI9342_2 (CYD/Adafruit)
|
||||
0xEF, 3, 0x03, 0x80, 0x02,
|
||||
0xCF, 3, 0x00, 0xC1, 0x30,
|
||||
0xED, 4, 0x64, 0x03, 0x12, 0x81,
|
||||
0xE8, 3, 0x85, 0x00, 0x78,
|
||||
0xCB, 5, 0x39, 0x2C, 0x00, 0x34, 0x02,
|
||||
0xF7, 1, 0x20,
|
||||
0xEA, 2, 0x00, 0x00,
|
||||
ILI9341_PWCTR1, 1, 0x23, // Power control VRH[5:0]
|
||||
ILI9341_PWCTR2, 1, 0x10, // Power control SAP[2:0];BT[3:0]
|
||||
ILI9341_VMCTR1, 2, 0x2B, 0x2B, // VCM control
|
||||
ILI9341_VMCTR2, 1, 0xC0, // VCM control2
|
||||
ILI9341_MADCTL, 1, (MADCTL_MX | MADCTL_BGR), // Memory Access Control
|
||||
ILI9341_VSCRSADD, 1, 0x00, // Vertical scroll zero
|
||||
ILI9341_PIXFMT, 1, 0x55,
|
||||
ILI9341_FRMCTR1, 2, 0x00, 0x1B,
|
||||
ILI9341_DFUNCTR, 3, 0x08, 0x82, 0x27, // Display Function Control
|
||||
0xF2, 1, 0x00, // 3Gamma Function Disable
|
||||
ILI9341_GAMMASET, 1, 0x01, // Gamma curve selected
|
||||
ILI9341_GMCTRP1, 15, 0x0F, 0x31, 0x2B, 0x0C, 0x0E,
|
||||
0x08,
|
||||
0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E,
|
||||
0x09, 0x00, //
|
||||
// Set
|
||||
// Gamma
|
||||
ILI9341_GMCTRN1, 15, 0x00, 0x0E, 0x14, 0x03, 0x11,
|
||||
0x07,
|
||||
0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31,
|
||||
0x36, 0x0F, // Set Gamma
|
||||
ILI9341_SLPOUT, 0x80, // Exit Sleep
|
||||
ILI9341_DISPON, 0x80, // Display on
|
||||
0x00 // End of list
|
||||
};
|
||||
|
||||
// clang-format on
|
||||
// clang-format off
|
||||
static const uint8_t PROGMEM initcmd_9342_3[] = { // ILI9342_3 (CYD/Bodmer)
|
||||
0xEF, 3, 0x03, 0x80, 0x02,
|
||||
0xCF, 3, 0x00, 0xC1, 0x30,
|
||||
0xED, 4, 0x64, 0x03, 0x12, 0x81,
|
||||
0xE8, 3, 0x85, 0x00, 0x78,
|
||||
0xCB, 5, 0x39, 0x2C, 0x00, 0x34, 0x02,
|
||||
0xF7, 1, 0x20,
|
||||
0xEA, 2, 0x00, 0x00,
|
||||
ILI9341_PWCTR1, 1, 0x10, // Power control VRH[5:0]
|
||||
ILI9341_PWCTR2, 1, 0x00, // Power control SAP[2:0];BT[3:0]
|
||||
ILI9341_VMCTR1, 2, 0x30, 0x30, // VCM control
|
||||
ILI9341_VMCTR2, 1, 0xB7, // VCM control2
|
||||
ILI9341_MADCTL, 1, (MADCTL_BGR), // Memory Access Control
|
||||
// ILI9341_VSCRSADD, 1, 0x00, // Vertical scroll zero
|
||||
ILI9341_PIXFMT, 1, 0x55,
|
||||
ILI9341_FRMCTR1, 2, 0x00, 0x1A,
|
||||
ILI9341_DFUNCTR, 3, 0x08, 0x82, 0x27, // Display Function Control
|
||||
0xF2, 1, 0x00, // 3Gamma Function Disable
|
||||
ILI9341_GAMMASET, 1, 0x01, // Gamma curve selected
|
||||
ILI9341_GMCTRP1, 15, 0x0F, 0x2A, 0x28, 0x08, 0x0E,
|
||||
0x08,
|
||||
0x54, 0xA9, 0x43, 0x0A, 0x0F, 0x00, 0x00,
|
||||
0x00, 0x00, //
|
||||
// Set
|
||||
// Gamma
|
||||
ILI9341_GMCTRN1, 15, 0x00, 0x15, 0x17, 0x07, 0x11,
|
||||
0x06,
|
||||
0x2B, 0x56, 0x3C, 0x05, 0x10, 0x0F, 0x3F,
|
||||
0x3F, 0x0F, // Set Gamma
|
||||
ILI9341_PASET, 4, 0x00, 0x00, 0x01, 0x3F,
|
||||
ILI9341_CASET, 4, 0x00, 0x00, 0x00, 0xEF,
|
||||
ILI9341_SLPOUT, 0x80, // Exit Sleep
|
||||
ILI9341_DISPON, 0x80, // Display on
|
||||
0x00 // End of list
|
||||
};
|
||||
|
||||
// clang-format on
|
||||
#endif // ifdef ESP32
|
||||
|
||||
// clang-format off
|
||||
static const uint8_t PROGMEM initcmd_9481[] = { // ILI9481
|
||||
ILI9341_SLPOUT, 0x80, // Exit Sleep
|
||||
@@ -478,6 +555,14 @@ void Adafruit_ILI9341::begin(uint32_t freq) {
|
||||
case ILI_TYPE_9342: // ILI9342 M5STACK
|
||||
addr = initcmd_9342;
|
||||
break;
|
||||
#ifdef ESP32
|
||||
case ILI_TYPE_9342_2: // ILI9342 CYD/Adafruit
|
||||
addr = initcmd_9342_2;
|
||||
break;
|
||||
case ILI_TYPE_9342_3: // ILI9342 CYD/Bodmer
|
||||
addr = initcmd_9342_3;
|
||||
break;
|
||||
#endif // ifdef ESP32
|
||||
case ILI_TYPE_9481: // ILI9481
|
||||
addr = initcmd_9481;
|
||||
break;
|
||||
@@ -540,6 +625,9 @@ void Adafruit_ILI9341::setRotation(uint8_t m) {
|
||||
case ILI_TYPE_9342: // ILI9342 M5STACK
|
||||
m = (MADCTL_MY | MADCTL_MV | MADCTL_BGR);
|
||||
break;
|
||||
case ILI_TYPE_9342_2: // ILI9342 CYD/Adafruit
|
||||
m = (MADCTL_BGR);
|
||||
break;
|
||||
case ILI_TYPE_9481: // ILI9481
|
||||
case ILI_TYPE_9481_CPT29: // ILI9481 CPT29
|
||||
case ILI_TYPE_9481_PVI35: // ILI9481 PVI35
|
||||
@@ -551,6 +639,7 @@ void Adafruit_ILI9341::setRotation(uint8_t m) {
|
||||
m = (MADCTL_SS | MADCTL_BGR);
|
||||
break;
|
||||
case ILI_TYPE_9341: // ILI9341
|
||||
case ILI_TYPE_9342_3: // ILI9342 CYD/Bodmer
|
||||
// m = (MADCTL_MX | MADCTL_BGR);
|
||||
// break;
|
||||
default:
|
||||
@@ -577,6 +666,8 @@ void Adafruit_ILI9341::setRotation(uint8_t m) {
|
||||
// m = (MADCTL_MV | MADCTL_BGR);
|
||||
// break;
|
||||
case ILI_TYPE_9341: // ILI9341
|
||||
case ILI_TYPE_9342_2: // ILI9342 CYD/Adafruit
|
||||
case ILI_TYPE_9342_3: // ILI9342 CYD/Bodmer
|
||||
// m = (MADCTL_MV | MADCTL_BGR);
|
||||
// break;
|
||||
default:
|
||||
@@ -603,6 +694,8 @@ void Adafruit_ILI9341::setRotation(uint8_t m) {
|
||||
m = (MADCTL_GS | MADCTL_BGR);
|
||||
break;
|
||||
case ILI_TYPE_9341: // ILI9341
|
||||
case ILI_TYPE_9342_2: // ILI9342 CYD/Adafruit
|
||||
case ILI_TYPE_9342_3: // ILI9342 CYD/Bodmer
|
||||
// m = (MADCTL_MY | MADCTL_BGR);
|
||||
// break;
|
||||
default:
|
||||
@@ -629,6 +722,8 @@ void Adafruit_ILI9341::setRotation(uint8_t m) {
|
||||
m = (MADCTL_SS | MADCTL_GS | MADCTL_MV | MADCTL_BGR);
|
||||
break;
|
||||
case ILI_TYPE_9341: // ILI9341
|
||||
case ILI_TYPE_9342_2: // ILI9342 CYD/Adafruit
|
||||
case ILI_TYPE_9342_3: // ILI9342 CYD/Bodmer
|
||||
// m = (MADCTL_MX | MADCTL_MY | MADCTL_MV | MADCTL_BGR);
|
||||
// break;
|
||||
default:
|
||||
|
||||
@@ -128,6 +128,8 @@
|
||||
|
||||
#define ILI_TYPE_9341 0 // MUST match with enum class ILI9xxx_type_e in P095_data_struct.h !
|
||||
#define ILI_TYPE_9342 1
|
||||
#define ILI_TYPE_9342_2 12 // !! ONLY enabled on ESP32 for size reasons !!
|
||||
#define ILI_TYPE_9342_3 13 // !! ONLY enabled on ESP32 for size reasons !!
|
||||
#define ILI_TYPE_9481 2
|
||||
#define ILI_TYPE_9481_CPT29 3
|
||||
#define ILI_TYPE_9481_PVI35 4
|
||||
|
||||
+10
-2
@@ -229,6 +229,10 @@ boolean Plugin_095(uint8_t function, struct EventStruct *event, String& string)
|
||||
const __FlashStringHelper *hardwareTypes[] = {
|
||||
ILI9xxx_type_toString(ILI9xxx_type_e::ILI9341_240x320),
|
||||
ILI9xxx_type_toString(ILI9xxx_type_e::ILI9342_240x320),
|
||||
# if P095_ENABLE_ILI9342_2
|
||||
ILI9xxx_type_toString(ILI9xxx_type_e::ILI9342_CYD_AF_240x320),
|
||||
ILI9xxx_type_toString(ILI9xxx_type_e::ILI9342_CYD_BD_240x320),
|
||||
# endif // if P095_ENABLE_ILI9342_2
|
||||
ILI9xxx_type_toString(ILI9xxx_type_e::ILI9481_320x480),
|
||||
ILI9xxx_type_toString(ILI9xxx_type_e::ILI9481_CPT29_320x480),
|
||||
ILI9xxx_type_toString(ILI9xxx_type_e::ILI9481_PVI35_320x480),
|
||||
@@ -246,6 +250,10 @@ boolean Plugin_095(uint8_t function, struct EventStruct *event, String& string)
|
||||
constexpr int hardwareOptions[] = {
|
||||
static_cast<int>(ILI9xxx_type_e::ILI9341_240x320),
|
||||
static_cast<int>(ILI9xxx_type_e::ILI9342_240x320),
|
||||
# if P095_ENABLE_ILI9342_2
|
||||
static_cast<int>(ILI9xxx_type_e::ILI9342_CYD_AF_240x320),
|
||||
static_cast<int>(ILI9xxx_type_e::ILI9342_CYD_BD_240x320),
|
||||
# endif // if P095_ENABLE_ILI9342_2
|
||||
static_cast<int>(ILI9xxx_type_e::ILI9481_320x480),
|
||||
static_cast<int>(ILI9xxx_type_e::ILI9481_CPT29_320x480),
|
||||
static_cast<int>(ILI9xxx_type_e::ILI9481_PVI35_320x480),
|
||||
@@ -262,8 +270,8 @@ boolean Plugin_095(uint8_t function, struct EventStruct *event, String& string)
|
||||
};
|
||||
constexpr size_t optionCount = NR_ELEMENTS(hardwareOptions);
|
||||
const FormSelectorOptions selector(optionCount,
|
||||
hardwareTypes,
|
||||
hardwareOptions);
|
||||
hardwareTypes,
|
||||
hardwareOptions);
|
||||
selector.addFormSelector(
|
||||
F("TFT display model"),
|
||||
F("dsptype"),
|
||||
|
||||
@@ -9,6 +9,10 @@ const __FlashStringHelper* ILI9xxx_type_toString(const ILI9xxx_type_e& device) {
|
||||
switch (device) {
|
||||
case ILI9xxx_type_e::ILI9341_240x320: return F("ILI9341 240 x 320px");
|
||||
case ILI9xxx_type_e::ILI9342_240x320: return F("ILI9342 240 x 320px (M5Stack)");
|
||||
# if P095_ENABLE_ILI9342_2
|
||||
case ILI9xxx_type_e::ILI9342_CYD_AF_240x320: return F("ILI9342 240 x 320px (CYD-1)");
|
||||
case ILI9xxx_type_e::ILI9342_CYD_BD_240x320: return F("ILI9342 240 x 320px (CYD-2)");
|
||||
# endif // if P095_ENABLE_ILI9342_2
|
||||
case ILI9xxx_type_e::ILI9481_320x480: return F("ILI9481 320 x 480px");
|
||||
case ILI9xxx_type_e::ILI9481_CPT29_320x480: return F("ILI9481 320 x 480px (CPT29)");
|
||||
case ILI9xxx_type_e::ILI9481_PVI35_320x480: return F("ILI9481 320 x 480px (PVI35)");
|
||||
@@ -39,6 +43,10 @@ void ILI9xxx_type_toResolution(const ILI9xxx_type_e& device,
|
||||
switch (device) {
|
||||
case ILI9xxx_type_e::ILI9341_240x320:
|
||||
case ILI9xxx_type_e::ILI9342_240x320:
|
||||
# if P095_ENABLE_ILI9342_2
|
||||
case ILI9xxx_type_e::ILI9342_CYD_AF_240x320:
|
||||
case ILI9xxx_type_e::ILI9342_CYD_BD_240x320:
|
||||
# endif // if P095_ENABLE_ILI9342_2
|
||||
x = 240;
|
||||
y = 320;
|
||||
break;
|
||||
@@ -180,7 +188,7 @@ bool P095_data_struct::plugin_init(struct EventStruct *event) {
|
||||
log += F("in");
|
||||
}
|
||||
log += strformat(F("valid, display: %s, commands: %s/%s"),
|
||||
String(ILI9xxx_type_toString(_displayType)).c_str(),
|
||||
FsP(ILI9xxx_type_toString(_displayType)),
|
||||
_commandTrigger.c_str(),
|
||||
_commandTriggerCmd.c_str());
|
||||
addLogMove(LOG_LEVEL_INFO, log);
|
||||
|
||||
@@ -22,6 +22,10 @@
|
||||
# define P095_ENABLE_ILI948X 0 // Not enabled for limited buildsizes
|
||||
# endif // if defined(LIMIT_BUILD_SIZE) && P095_ENABLE_ILI948X && !defined(PLUGIN_BUILD_CUSTOM)
|
||||
|
||||
# if !defined(P095_ENABLE_ILI9342_2) && defined(ESP32)
|
||||
# define P095_ENABLE_ILI9342_2 1
|
||||
# endif // if !defined(P095_ENABLE_ILI9342_2) && defined(ESP32)
|
||||
|
||||
# if P095_ENABLE_ILI948X
|
||||
# include <ILI9488.h> // Specific behavior: ILI9488 needs 24 bit colors in SPI mode
|
||||
# endif // if P095_ENABLE_ILI948X
|
||||
@@ -97,6 +101,10 @@ enum class ILI9xxx_type_e : uint8_t {
|
||||
// ILI9486_320x480 = 10u,
|
||||
ILI9488_320x480 = 11u, // Uses a separate library for having a 16 bit data interface
|
||||
# endif // if P095_ENABLE_ILI948X
|
||||
# if P095_ENABLE_ILI9342_2
|
||||
ILI9342_CYD_AF_240x320 = 12u,
|
||||
ILI9342_CYD_BD_240x320 = 13u,
|
||||
# endif // if P095_ENABLE_ILI9342_2
|
||||
};
|
||||
|
||||
enum class P095_CommandTrigger : uint8_t {
|
||||
|
||||
Reference in New Issue
Block a user