esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
422 stars 27 forks source link

Please add st7789v option for mirroring the display output #2375

Open niahane opened 1 year ago

niahane commented 1 year ago

Describe the problem you have/What new integration you would like

I use this display platform with a prism, so the image is In reverse. It seems that no options is avaible for obtain rendering reversed. photo_6012685599011618750_y

Please describe your use case for this integration and alternatives you've tried:

Additional context

For example this integration has flip_x option, is possible to add to this diplay platform please? https://esphome.io/components/display/ssd1306.html

niahane commented 1 year ago

I have modified the source st7789v.cpp and it seems to work perfectly:

void HOT ST7789V::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;

  int inverted_x = this->get_width_internal() - 1 - x;

  if (this->eightbitcolor_) {
    auto color332 = display::ColorUtil::color_to_332(color);
    uint32_t pos = (inverted_x + y * this->get_width_internal());
    this->buffer_[pos] = color332;
  } else {
    auto color565 = display::ColorUtil::color_to_565(color);
    uint32_t pos = (inverted_x + y * this->get_width_internal()) * 2;
    this->buffer_[pos++] = (color565 >> 8) & 0xff;
    this->buffer_[pos] = color565 & 0xff;
  }
}

Unfortunately for now i am not able to add an option for enable/disable it in yaml file :(