support rotated ILI9341 (ILI9342) (#3526)

Co-authored-by: Samuel Sieb <samuel@sieb.net>
This commit is contained in:
Samuel Sieb 2022-06-07 03:42:13 -07:00 committed by GitHub
parent 612822490b
commit dd470d4197
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 0 deletions

View file

@ -24,6 +24,7 @@ ili9341 = ili9341_ns.class_(
) )
ILI9341M5Stack = ili9341_ns.class_("ILI9341M5Stack", ili9341) ILI9341M5Stack = ili9341_ns.class_("ILI9341M5Stack", ili9341)
ILI9341TFT24 = ili9341_ns.class_("ILI9341TFT24", ili9341) ILI9341TFT24 = ili9341_ns.class_("ILI9341TFT24", ili9341)
ILI9341TFT24R = ili9341_ns.class_("ILI9341TFT24R", ili9341)
ILI9341Model = ili9341_ns.enum("ILI9341Model") ILI9341Model = ili9341_ns.enum("ILI9341Model")
ILI9341ColorMode = ili9341_ns.enum("ILI9341ColorMode") ILI9341ColorMode = ili9341_ns.enum("ILI9341ColorMode")
@ -31,6 +32,7 @@ ILI9341ColorMode = ili9341_ns.enum("ILI9341ColorMode")
MODELS = { MODELS = {
"M5STACK": ILI9341Model.M5STACK, "M5STACK": ILI9341Model.M5STACK,
"TFT_2.4": ILI9341Model.TFT_24, "TFT_2.4": ILI9341Model.TFT_24,
"TFT_2.4R": ILI9341Model.TFT_24R,
} }
ILI9341_MODEL = cv.enum(MODELS, upper=True, space="_") ILI9341_MODEL = cv.enum(MODELS, upper=True, space="_")
@ -60,6 +62,8 @@ async def to_code(config):
lcd_type = ILI9341M5Stack lcd_type = ILI9341M5Stack
if config[CONF_MODEL] == "TFT_2.4": if config[CONF_MODEL] == "TFT_2.4":
lcd_type = ILI9341TFT24 lcd_type = ILI9341TFT24
if config[CONF_MODEL] == "TFT_2.4R":
lcd_type = ILI9341TFT24R
rhs = lcd_type.new() rhs = lcd_type.new()
var = cg.Pvariable(config[CONF_ID], rhs) var = cg.Pvariable(config[CONF_ID], rhs)

View file

@ -263,5 +263,13 @@ void ILI9341TFT24::initialize() {
this->fill_internal_(Color::BLACK); this->fill_internal_(Color::BLACK);
} }
// 24_TFT rotated display
void ILI9341TFT24R::initialize() {
this->init_lcd_(INITCMD_TFT);
this->width_ = 320;
this->height_ = 240;
this->fill_internal_(Color::BLACK);
}
} // namespace ili9341 } // namespace ili9341
} // namespace esphome } // namespace esphome

View file

@ -12,6 +12,7 @@ namespace ili9341 {
enum ILI9341Model { enum ILI9341Model {
M5STACK = 0, M5STACK = 0,
TFT_24, TFT_24,
TFT_24R,
}; };
enum ILI9341ColorMode { enum ILI9341ColorMode {
@ -102,5 +103,12 @@ class ILI9341TFT24 : public ILI9341Display {
public: public:
void initialize() override; void initialize() override;
}; };
//----------- ILI9341_24_TFT rotated display --------------
class ILI9341TFT24R : public ILI9341Display {
public:
void initialize() override;
};
} // namespace ili9341 } // namespace ili9341
} // namespace esphome } // namespace esphome