This commit is contained in:
Clyde Stubbs 2023-09-27 09:25:14 +10:00 committed by GitHub
parent 86db559f6e
commit 5360e14a9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 47 additions and 7 deletions

View file

@ -131,7 +131,7 @@ esphome/components/i2s_audio/* @jesserockz
esphome/components/i2s_audio/media_player/* @jesserockz esphome/components/i2s_audio/media_player/* @jesserockz
esphome/components/i2s_audio/microphone/* @jesserockz esphome/components/i2s_audio/microphone/* @jesserockz
esphome/components/i2s_audio/speaker/* @jesserockz esphome/components/i2s_audio/speaker/* @jesserockz
esphome/components/ili9xxx/* @nielsnl68 esphome/components/ili9xxx/* @clydebarrow @nielsnl68
esphome/components/improv_base/* @esphome/core esphome/components/improv_base/* @esphome/core
esphome/components/improv_serial/* @esphome/core esphome/components/improv_serial/* @esphome/core
esphome/components/ina260/* @mreditor97 esphome/components/ina260/* @mreditor97

View file

@ -25,7 +25,7 @@ def AUTO_LOAD():
return [] return []
CODEOWNERS = ["@nielsnl68"] CODEOWNERS = ["@nielsnl68", "@clydebarrow"]
ili9XXX_ns = cg.esphome_ns.namespace("ili9xxx") ili9XXX_ns = cg.esphome_ns.namespace("ili9xxx")
ili9XXXSPI = ili9XXX_ns.class_( ili9XXXSPI = ili9XXX_ns.class_(
@ -42,6 +42,7 @@ MODELS = {
"ILI9341": ili9XXX_ns.class_("ILI9XXXILI9341", ili9XXXSPI), "ILI9341": ili9XXX_ns.class_("ILI9XXXILI9341", ili9XXXSPI),
"ILI9342": ili9XXX_ns.class_("ILI9XXXILI9342", ili9XXXSPI), "ILI9342": ili9XXX_ns.class_("ILI9XXXILI9342", ili9XXXSPI),
"ILI9481": ili9XXX_ns.class_("ILI9XXXILI9481", ili9XXXSPI), "ILI9481": ili9XXX_ns.class_("ILI9XXXILI9481", ili9XXXSPI),
"ILI9481-18": ili9XXX_ns.class_("ILI9XXXILI948118", ili9XXXSPI),
"ILI9486": ili9XXX_ns.class_("ILI9XXXILI9486", ili9XXXSPI), "ILI9486": ili9XXX_ns.class_("ILI9XXXILI9486", ili9XXXSPI),
"ILI9488": ili9XXX_ns.class_("ILI9XXXILI9488", ili9XXXSPI), "ILI9488": ili9XXX_ns.class_("ILI9XXXILI9488", ili9XXXSPI),
"ILI9488_A": ili9XXX_ns.class_("ILI9XXXILI9488A", ili9XXXSPI), "ILI9488_A": ili9XXX_ns.class_("ILI9XXXILI9488A", ili9XXXSPI),
@ -140,8 +141,6 @@ async def to_code(config):
rhs = [] rhs = []
for x in range(256): for x in range(256):
rhs.extend([HexInt(x), HexInt(x), HexInt(x)]) rhs.extend([HexInt(x), HexInt(x), HexInt(x)])
prog_arr = cg.progmem_array(config[CONF_RAW_DATA_ID], rhs)
cg.add(var.set_palette(prog_arr))
elif config[CONF_COLOR_PALETTE] == "IMAGE_ADAPTIVE": elif config[CONF_COLOR_PALETTE] == "IMAGE_ADAPTIVE":
cg.add(var.set_buffer_color_mode(ILI9XXXColorMode.BITS_8_INDEXED)) cg.add(var.set_buffer_color_mode(ILI9XXXColorMode.BITS_8_INDEXED))
from PIL import Image from PIL import Image
@ -178,6 +177,4 @@ async def to_code(config):
if rhs is not None: if rhs is not None:
prog_arr = cg.progmem_array(config[CONF_RAW_DATA_ID], rhs) prog_arr = cg.progmem_array(config[CONF_RAW_DATA_ID], rhs)
cg.add(var.set_palette(prog_arr)) cg.add(var.set_palette(prog_arr))
cg.add(var.set_data_rate(config[CONF_DATA_RATE]))
spi_data_rate = str(spi.SPI_DATA_RATE_OPTIONS[config[CONF_DATA_RATE]])
cg.add_define("ILI9XXXDisplay_DATA_RATE", cg.RawExpression(spi_data_rate))

View file

@ -59,6 +59,7 @@ void ILI9XXXDisplay::dump_config() {
if (this->is_18bitdisplay_) { if (this->is_18bitdisplay_) {
ESP_LOGCONFIG(TAG, " 18-Bit Mode: YES"); ESP_LOGCONFIG(TAG, " 18-Bit Mode: YES");
} }
ESP_LOGCONFIG(TAG, " Data rate: %dMHz", (unsigned) (this->data_rate_ / 1000000));
LOG_PIN(" Reset Pin: ", this->reset_pin_); LOG_PIN(" Reset Pin: ", this->reset_pin_);
LOG_PIN(" DC Pin: ", this->dc_pin_); LOG_PIN(" DC Pin: ", this->dc_pin_);
@ -387,6 +388,17 @@ void ILI9XXXILI9481::initialize() {
} }
} }
void ILI9XXXILI948118::initialize() {
this->init_lcd_(INITCMD_ILI9481_18);
if (this->width_ == 0) {
this->width_ = 320;
}
if (this->height_ == 0) {
this->height_ = 480;
}
this->is_18bitdisplay_ = true;
}
// 35_TFT display // 35_TFT display
void ILI9XXXILI9486::initialize() { void ILI9XXXILI9486::initialize() {
this->init_lcd_(INITCMD_ILI9486); this->init_lcd_(INITCMD_ILI9486);

View file

@ -120,6 +120,12 @@ class ILI9XXXILI9481 : public ILI9XXXDisplay {
void initialize() override; void initialize() override;
}; };
//----------- ILI9481 in 18 bit mode --------------
class ILI9XXXILI948118 : public ILI9XXXDisplay {
protected:
void initialize() override;
};
//----------- ILI9XXX_35_TFT rotated display -------------- //----------- ILI9XXX_35_TFT rotated display --------------
class ILI9XXXILI9486 : public ILI9XXXDisplay { class ILI9XXXILI9486 : public ILI9XXXDisplay {
protected: protected:

View file

@ -94,12 +94,36 @@ static const uint8_t PROGMEM INITCMD_ILI9481[] = {
ILI9XXX_IFCTR , 1, 0x83, ILI9XXX_IFCTR , 1, 0x83,
ILI9XXX_GMCTR ,12, 0x00, 0x26, 0x21, 0x00, 0x00, 0x1F, 0x65, 0x23, 0x77, 0x00, 0x0F, 0x00, ILI9XXX_GMCTR ,12, 0x00, 0x26, 0x21, 0x00, 0x00, 0x1F, 0x65, 0x23, 0x77, 0x00, 0x0F, 0x00,
ILI9XXX_IFMODE , 1, 0x00, // CommandAccessProtect ILI9XXX_IFMODE , 1, 0x00, // CommandAccessProtect
ILI9XXX_PTLAR , 4, 0, 0, 1, 0xDF,
0xE4 , 1, 0xA0, 0xE4 , 1, 0xA0,
ILI9XXX_MADCTL , 1, MADCTL_MV | MADCTL_BGR, // Memory Access Control
ILI9XXX_CSCON , 1, 0x01, ILI9XXX_CSCON , 1, 0x01,
ILI9XXX_PIXFMT, 1, 0x55, // 16 bit mode
ILI9XXX_INVON, 0,
ILI9XXX_DISPON, 0x80, // Set display on ILI9XXX_DISPON, 0x80, // Set display on
0x00 // end 0x00 // end
}; };
static const uint8_t PROGMEM INITCMD_ILI9481_18[] = {
ILI9XXX_SLPOUT , 0x80, // Exit sleep mode
ILI9XXX_PWSET , 3, 0x07, 0x41, 0x1D,
ILI9XXX_VMCTR , 3, 0x00, 0x1C, 0x1F,
ILI9XXX_PWSETN , 2, 0x01, 0x11,
ILI9XXX_PWCTR1 , 5, 0x10, 0x3B, 0x00, 0x02, 0x11,
ILI9XXX_VMCTR1 , 1, 0x03,
ILI9XXX_IFCTR , 1, 0x83,
ILI9XXX_GMCTR ,12, 0x00, 0x26, 0x21, 0x00, 0x00, 0x1F, 0x65, 0x23, 0x77, 0x00, 0x0F, 0x00,
ILI9XXX_IFMODE , 1, 0x00, // CommandAccessProtect
ILI9XXX_PTLAR , 4, 0, 0, 1, 0xDF,
0xE4 , 1, 0xA0,
ILI9XXX_MADCTL , 1, MADCTL_MX| MADCTL_BGR, // Memory Access Control
ILI9XXX_CSCON , 1, 0x01,
ILI9XXX_PIXFMT, 1, 0x66, // 18 bit mode
ILI9XXX_INVON, 0,
ILI9XXX_DISPON, 0x80, // Set display on
0x00 // end
};
static const uint8_t PROGMEM INITCMD_ILI9486[] = { static const uint8_t PROGMEM INITCMD_ILI9486[] = {
ILI9XXX_SLPOUT, 0x80, ILI9XXX_SLPOUT, 0x80,
ILI9XXX_PIXFMT, 1, 0x55, ILI9XXX_PIXFMT, 1, 0x55,

View file

@ -2972,6 +2972,7 @@ display:
model: TFT 2.4 model: TFT 2.4
cs_pin: GPIO5 cs_pin: GPIO5
dc_pin: GPIO4 dc_pin: GPIO4
color_palette: GRAYSCALE
reset_pin: GPIO22 reset_pin: GPIO22
lambda: |- lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height()); it.rectangle(0, 0, it.get_width(), it.get_height());