mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-06 04:48:27 +02:00
336c2d34e6
* - Removed cleaning the screen twice. \Should be handled by `DisplayBuffer::init_internal_();` - Made ili9341::initalize() protected and renamed \ it to ili9341::initalize(). - ili9341::initalize() should only init the display \ and set the width and heigth. * removed to much * clang format fixes * removing trailing underscors for protected virtual methods * removed the "override" on display() * clang fixes * restored old changes * Renamed the ili9341 platform to ili9xxx and added multiple drivers as well. including PR #3848 * fixed most of the clang reported issues * fixed reported issues * last fixes * Setting the right codeowners * missing changes * fixed naming Display() method. * clang again * clang fix * fixes reported by @jesserockz & @gpambrozio * a change to display.py removing an unneeded var * re-introduce **backlight** option. * update the ili9488 initialization * update the ili9488 initialization and fix typo * fixed typo * add missing constants * swap height and width back for the ili9488 * init fixes ili9488 * fixed lint issue testing the init code * oeps * init fixes ili9488 * fixed wrong define * fixed wrong define again * removed some spaces * revert to ili9341 * Remove parts that where used for the switchplate * lint fixes and removing unused function * fix error and introducing 16bit color option * fix error and introducing 16bit color option * fix clang issue * clang fix * clang issue again * is this what clang exprect * clang fix * clang fix * try again * let try again * and again * and the last clang fix * remove the need of wifi * update dimentions * update ili8488 init code. * update dimentions * allow to change height and width * dump color mode config * fix * fix * modify logging * referd back unrelated change * code formatting commit and moving functions around * add missing ; * update code * update code * use the correct write_array for sending uint16_t * fix panic loop * fix panic loop * - update the test file - fixed sending display data * clang fixes * clang fixes * clang fixes again * remove .gitignore items * remove .gitignore items * make sure Update() can can not be called while called * clang correction * adding a test yaml for the ili9341 * Update ili9341 example * Make test ili9xxx/tests only local * restore back old ili9341 driver code * Add a new config for the M5Core * fix clang request * reverd to restore of the old ili9341 there is no proper way to say it is depricated. * Remove the backlight/led pin from the config. You need to use a proper light platform component * Ili9488init changes (#88) Fixed ILI9488 init settings, and adjusted pixel handling code to push pixels in 18 bit format. This does not change the internal 16-bit representation. * fixed some leftover clang issues from the merge. * fixed the slang-tidy request. * remove `backlight_pin` warning. --------- Co-authored-by: JD Steffen <jdsteffen81@gmail.com>
139 lines
3.9 KiB
C++
139 lines
3.9 KiB
C++
#pragma once
|
|
#include "esphome/components/spi/spi.h"
|
|
#include "esphome/components/display/display_buffer.h"
|
|
#include "ili9xxx_defines.h"
|
|
#include "ili9xxx_init.h"
|
|
|
|
namespace esphome {
|
|
namespace ili9xxx {
|
|
|
|
const uint32_t ILI9XXX_TRANSFER_BUFFER_SIZE = 64;
|
|
|
|
enum ILI9XXXColorMode {
|
|
BITS_8 = 0x08,
|
|
BITS_8_INDEXED = 0x09,
|
|
BITS_16 = 0x10,
|
|
};
|
|
|
|
class ILI9XXXDisplay : public PollingComponent,
|
|
public display::DisplayBuffer,
|
|
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
|
|
spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_40MHZ> {
|
|
public:
|
|
void set_dc_pin(GPIOPin *dc_pin) { dc_pin_ = dc_pin; }
|
|
float get_setup_priority() const override;
|
|
void set_reset_pin(GPIOPin *reset) { this->reset_pin_ = reset; }
|
|
void set_palette(const uint8_t *palette) { this->palette_ = palette; }
|
|
void set_buffer_color_mode(ILI9XXXColorMode color_mode) { this->buffer_color_mode_ = color_mode; }
|
|
void set_dimentions(int16_t width, int16_t height) {
|
|
this->height_ = height;
|
|
this->width_ = width;
|
|
}
|
|
void command(uint8_t value);
|
|
void data(uint8_t value);
|
|
void send_command(uint8_t command_byte, const uint8_t *data_bytes, uint8_t num_data_bytes);
|
|
uint8_t read_command(uint8_t command_byte, uint8_t index);
|
|
|
|
void update() override;
|
|
|
|
void fill(Color color) override;
|
|
|
|
void dump_config() override;
|
|
void setup() override;
|
|
|
|
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_COLOR; }
|
|
|
|
protected:
|
|
void draw_absolute_pixel_internal(int x, int y, Color color) override;
|
|
void setup_pins_();
|
|
virtual void initialize() = 0;
|
|
|
|
void display_();
|
|
void init_lcd_(const uint8_t *init_cmd);
|
|
void set_addr_window_(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
|
|
void invert_display_(bool invert);
|
|
void reset_();
|
|
|
|
int16_t width_{0}; ///< Display width as modified by current rotation
|
|
int16_t height_{0}; ///< Display height as modified by current rotation
|
|
uint16_t x_low_{0};
|
|
uint16_t y_low_{0};
|
|
uint16_t x_high_{0};
|
|
uint16_t y_high_{0};
|
|
const uint8_t *palette_;
|
|
|
|
ILI9XXXColorMode buffer_color_mode_{BITS_16};
|
|
|
|
uint32_t get_buffer_length_();
|
|
int get_width_internal() override;
|
|
int get_height_internal() override;
|
|
|
|
void start_command_();
|
|
void end_command_();
|
|
void start_data_();
|
|
void end_data_();
|
|
|
|
uint16_t transfer_buffer_[ILI9XXX_TRANSFER_BUFFER_SIZE];
|
|
|
|
uint32_t buffer_to_transfer_(uint32_t pos, uint32_t sz);
|
|
|
|
GPIOPin *reset_pin_{nullptr};
|
|
GPIOPin *dc_pin_{nullptr};
|
|
GPIOPin *busy_pin_{nullptr};
|
|
|
|
bool prossing_update_ = false;
|
|
bool need_update_ = false;
|
|
bool is_18bitdisplay_ = false;
|
|
};
|
|
|
|
//----------- M5Stack display --------------
|
|
class ILI9XXXM5Stack : public ILI9XXXDisplay {
|
|
protected:
|
|
void initialize() override;
|
|
};
|
|
|
|
//----------- M5Stack display --------------
|
|
class ILI9XXXM5CORE : public ILI9XXXDisplay {
|
|
protected:
|
|
void initialize() override;
|
|
};
|
|
|
|
//----------- ILI9XXX_24_TFT display --------------
|
|
class ILI9XXXILI9341 : public ILI9XXXDisplay {
|
|
protected:
|
|
void initialize() override;
|
|
};
|
|
|
|
//----------- ILI9XXX_24_TFT rotated display --------------
|
|
class ILI9XXXILI9342 : public ILI9XXXDisplay {
|
|
protected:
|
|
void initialize() override;
|
|
};
|
|
|
|
//----------- ILI9XXX_??_TFT rotated display --------------
|
|
class ILI9XXXILI9481 : public ILI9XXXDisplay {
|
|
protected:
|
|
void initialize() override;
|
|
};
|
|
|
|
//----------- ILI9XXX_35_TFT rotated display --------------
|
|
class ILI9XXXILI9486 : public ILI9XXXDisplay {
|
|
protected:
|
|
void initialize() override;
|
|
};
|
|
|
|
//----------- ILI9XXX_35_TFT rotated display --------------
|
|
class ILI9XXXILI9488 : public ILI9XXXDisplay {
|
|
protected:
|
|
void initialize() override;
|
|
};
|
|
|
|
//----------- ILI9XXX_35_TFT rotated display --------------
|
|
class ILI9XXXST7796 : public ILI9XXXDisplay {
|
|
protected:
|
|
void initialize() override;
|
|
};
|
|
|
|
} // namespace ili9xxx
|
|
} // namespace esphome
|