diff --git a/components/st7735/display.py b/components/st7735/display.py index ca028ac..a62230b 100644 --- a/components/st7735/display.py +++ b/components/st7735/display.py @@ -19,7 +19,7 @@ CONFIG_SCHEMA = display.FULL_DISPLAY_SCHEMA.extend({ cv.Required(CONF_DC_PIN): pins.gpio_output_pin_schema, cv.Required(CONF_CS_PIN): pins.gpio_output_pin_schema, cv.Optional(CONF_BRIGHTNESS, default=1.0): cv.percentage, -}).extend(cv.polling_component_schema('1s')).extend(spi.SPI_DEVICE_SCHEMA) +}).extend(cv.polling_component_schema('1s')).extend(spi.spi_device_schema()) def to_code(config): diff --git a/components/st7735/st7735.cpp b/components/st7735/st7735.cpp index 3336bcd..dcdfdea 100644 --- a/components/st7735/st7735.cpp +++ b/components/st7735/st7735.cpp @@ -162,10 +162,7 @@ void ST7735::setup() { this->displayInit(Rcmd3); this->writecommand(ST7735_INVON); -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //this->disable(); delay(120); - //this->enable(); this->writecommand(ST7735_DISPON); //Display on delay(120); @@ -270,18 +267,15 @@ size_t ST7735::get_buffer_length_() { return size_t(this->get_width_internal()) * size_t(this->get_height_internal()) * 2; } -void HOT ST7735::draw_absolute_pixel_internal(int x, int y, int color) { + +void HOT ST7735::draw_absolute_pixel_internal(int x, int y, Color color) { if (x >= this->get_width_internal() || x < 0 || y >= this->get_height_internal() || y < 0) return; - if (color == display::COLOR_ON) { - color = ST7735_WHITE; - } else if (color == display::COLOR_OFF) { - color = ST7735_BLACK; - } - uint16_t pos = (x + y * this->get_width_internal())*2; - this->buffer_[pos++] = (color>>8) & 0xff; - this->buffer_[pos] = color & 0xff; + auto color565 = color.to_rgb_565(); + uint16_t pos = (x + y * this->get_width_internal()) * 2; + this->buffer_[pos++] = (color565 >> 8) & 0xff; + this->buffer_[pos] = color565 & 0xff; } void ST7735::displayInit(const uint8_t *addr) { diff --git a/components/st7735/st7735.h b/components/st7735/st7735.h index 84e10f0..69f688f 100644 --- a/components/st7735/st7735.h +++ b/components/st7735/st7735.h @@ -147,8 +147,8 @@ class ST7735 : public PollingComponent, public display::DisplayBuffer, void spi_master_write_addr(uint16_t addr1, uint16_t addr2); void spi_master_write_color(uint16_t color, uint16_t size); - - void draw_absolute_pixel_internal(int x, int y, int color) override; + + void draw_absolute_pixel_internal(int x, int y, Color color) override; int get_height_internal() override; int get_width_internal() override;