From 97efa76200c4ff2e3c804fff6931e1c21369ab46 Mon Sep 17 00:00:00 2001 From: Antoine Weill--Duflos Date: Sun, 1 Dec 2024 15:32:45 -0500 Subject: [PATCH] add flip_y --- esphome/components/inkplate6/display.py | 4 +++- esphome/components/inkplate6/inkplate.cpp | 3 +++ esphome/components/inkplate6/inkplate.h | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/esphome/components/inkplate6/display.py b/esphome/components/inkplate6/display.py index 8fe7f7d41d..05cd8705b6 100644 --- a/esphome/components/inkplate6/display.py +++ b/esphome/components/inkplate6/display.py @@ -35,7 +35,7 @@ CONF_POWERUP_PIN = "powerup_pin" CONF_SPH_PIN = "sph_pin" CONF_SPV_PIN = "spv_pin" CONF_VCOM_PIN = "vcom_pin" - +CONF_FLIP_Y = "flip_y" inkplate6_ns = cg.esphome_ns.namespace("inkplate6") Inkplate6 = inkplate6_ns.class_( @@ -62,6 +62,7 @@ CONFIG_SCHEMA = cv.All( { cv.GenerateID(): cv.declare_id(Inkplate6), cv.Optional(CONF_GREYSCALE, default=False): cv.boolean, + cv.Optional(CONF_FLIP_Y, default=False): cv.boolean, cv.Optional(CONF_PARTIAL_UPDATING, default=True): cv.boolean, cv.Optional(CONF_FULL_UPDATE_EVERY, default=10): cv.uint32_t, cv.Optional(CONF_MODEL, default="inkplate_6"): cv.enum( @@ -126,6 +127,7 @@ async def to_code(config): cg.add(var.set_writer(lambda_)) cg.add(var.set_greyscale(config[CONF_GREYSCALE])) + cg.add(var.set_flip_y(config[CONF_FLIP_Y])) cg.add(var.set_partial_updating(config[CONF_PARTIAL_UPDATING])) cg.add(var.set_full_update_every(config[CONF_FULL_UPDATE_EVERY])) diff --git a/esphome/components/inkplate6/inkplate.cpp b/esphome/components/inkplate6/inkplate.cpp index f4d0fedf83..eb853d9aec 100644 --- a/esphome/components/inkplate6/inkplate.cpp +++ b/esphome/components/inkplate6/inkplate.cpp @@ -156,6 +156,9 @@ void HOT Inkplate6::draw_absolute_pixel_internal(int x, int y, Color color) { if (x >= this->get_width_internal() || y >= this->get_height_internal() || x < 0 || y < 0) return; + if (this->flip_y_) + y = this->get_height_internal() - y - 1; + if (this->greyscale_) { int x1 = x / 2; int x_sub = x % 2; diff --git a/esphome/components/inkplate6/inkplate.h b/esphome/components/inkplate6/inkplate.h index ca2ad46f1e..ce3683ea09 100644 --- a/esphome/components/inkplate6/inkplate.h +++ b/esphome/components/inkplate6/inkplate.h @@ -92,6 +92,8 @@ class Inkplate6 : public display::DisplayBuffer, public i2c::I2CDevice { if (this->is_ready()) this->initialize_(); } + void set_flip_y(bool flip_y) { this->flip_y_ = flip_y; } + void set_partial_updating(bool partial_updating) { this->partial_updating_ = partial_updating; } void set_full_update_every(uint32_t full_update_every) { this->full_update_every_ = full_update_every; } @@ -221,6 +223,7 @@ class Inkplate6 : public display::DisplayBuffer, public i2c::I2CDevice { bool block_partial_{true}; bool greyscale_; + bool flip_y_; bool partial_updating_; InkplateModel model_;