|
@@ -29,6 +29,7 @@ class GxEPD2Display : public display::DisplayBuffer {
|
|
|
void set_busy_pin(GPIOPin *pin) { this->busy_ = pin; }
|
|
void set_busy_pin(GPIOPin *pin) { this->busy_ = pin; }
|
|
|
void set_spi_parent(spi::SPIComponent *parent) { this->spi_.set_spi_parent(parent); }
|
|
void set_spi_parent(spi::SPIComponent *parent) { this->spi_.set_spi_parent(parent); }
|
|
|
void set_descriptor(const EpdPanelDescriptor *desc) { this->desc_ = desc; }
|
|
void set_descriptor(const EpdPanelDescriptor *desc) { this->desc_ = desc; }
|
|
|
|
|
+ void set_invert_mono(bool invert) { this->invert_mono_ = invert; }
|
|
|
|
|
|
|
|
void setup() override {
|
|
void setup() override {
|
|
|
const auto *desc = this->desc_;
|
|
const auto *desc = this->desc_;
|
|
@@ -86,7 +87,14 @@ class GxEPD2Display : public display::DisplayBuffer {
|
|
|
void loop() override { this->engine_.step(); }
|
|
void loop() override { this->engine_.step(); }
|
|
|
|
|
|
|
|
void dump_config() override {
|
|
void dump_config() override {
|
|
|
- ESP_LOGCONFIG(TAG, "GxEPD2 Display");
|
|
|
|
|
|
|
+ ESP_LOGCONFIG(TAG, "GxEPD2 Display:");
|
|
|
|
|
+ ESP_LOGCONFIG(TAG, " Dimensions: %ux%u", (unsigned) this->desc_->width, (unsigned) this->desc_->height);
|
|
|
|
|
+ ESP_LOGCONFIG(TAG, " Bits/pixel: %u (%s)", (unsigned) this->desc_->bits_per_pixel,
|
|
|
|
|
+ this->desc_->bits_per_pixel == 1 ? "mono/plane" : "packed palette");
|
|
|
|
|
+ ESP_LOGCONFIG(TAG, " Planes/regions: %u", (unsigned) this->desc_->plane_count);
|
|
|
|
|
+ ESP_LOGCONFIG(TAG, " Busy active level: %s", this->desc_->busy_active_level ? "HIGH" : "LOW");
|
|
|
|
|
+ if (this->desc_->bits_per_pixel == 1)
|
|
|
|
|
+ ESP_LOGCONFIG(TAG, " invert_mono: %s", YESNO(this->invert_mono_));
|
|
|
LOG_UPDATE_INTERVAL(this);
|
|
LOG_UPDATE_INTERVAL(this);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -179,7 +187,10 @@ class GxEPD2Display : public display::DisplayBuffer {
|
|
|
} else {
|
|
} else {
|
|
|
if (this->plane1_ != nullptr)
|
|
if (this->plane1_ != nullptr)
|
|
|
this->plane1_[idx] &= ~mask;
|
|
this->plane1_[idx] &= ~mask;
|
|
|
- if (bright) {
|
|
|
|
|
|
|
+ // plane0 bit set = white/blank. invert_mono_ flips the mono sense so a
|
|
|
|
|
+ // bright color (e.g. ESPHome's default COLOR_ON) becomes ink, not blank
|
|
|
|
|
+ // - see display.py's CONF_INVERT_MONO. Red classification is unaffected.
|
|
|
|
|
+ if (bright ^ this->invert_mono_) {
|
|
|
this->plane0_[idx] |= mask;
|
|
this->plane0_[idx] |= mask;
|
|
|
} else {
|
|
} else {
|
|
|
this->plane0_[idx] &= ~mask;
|
|
this->plane0_[idx] &= ~mask;
|
|
@@ -199,6 +210,7 @@ class GxEPD2Display : public display::DisplayBuffer {
|
|
|
uint8_t *plane0_{nullptr};
|
|
uint8_t *plane0_{nullptr};
|
|
|
uint8_t *plane1_{nullptr};
|
|
uint8_t *plane1_{nullptr};
|
|
|
uint32_t plane_bytes_{0};
|
|
uint32_t plane_bytes_{0};
|
|
|
|
|
+ bool invert_mono_{false};
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
} // namespace esphome::gxepd2
|
|
} // namespace esphome::gxepd2
|