|
|
@@ -33,23 +33,23 @@ class GxEPD2Display : public display::DisplayBuffer {
|
|
|
void set_spi_parent(spi::SPIComponent *parent) { this->spi_.set_spi_parent(parent); }
|
|
|
void set_descriptor(const EpdPanelDescriptor *desc) { this->desc_ = desc; }
|
|
|
void set_invert_mono(bool invert) { this->invert_mono_ = invert; }
|
|
|
- // Model trailer (e.g. "GDEQ0583T31", not the full "GxEPD2_583_..." id) and
|
|
|
- // an optional font, both for test_pattern()'s on-screen panel label. Set
|
|
|
- // from display.py: the name is derived from model:, the font is a normal
|
|
|
- // ESPHome font: the builder can pull from gfonts://. See test_pattern().
|
|
|
+ // The short panel label (e.g. "GDEQ0583T31") test_pattern() can print,
|
|
|
+ // derived from model: in display.py.
|
|
|
void set_model_name(const char *name) { this->model_name_ = name; }
|
|
|
- void set_name_font(display::BaseFont *font) { this->name_font_ = font; }
|
|
|
|
|
|
// Bench visual-check pattern, bit-depth aware. Everything scales to what
|
|
|
// THIS panel can actually show (see test_colors_): the color-bar count,
|
|
|
// the ladder color cycle and the corner markers all follow the panel's
|
|
|
// real color set instead of a hardcoded 4, so the drawn pattern doubles as
|
|
|
- // a statement of what the driver expects of the panel. Adds a dithered
|
|
|
- // grey ramp (so a 1bpp panel shows a graded sweep, not just two flat
|
|
|
- // blocks) and, when a name font is set and the panel can spare the room, a
|
|
|
- // model-trailer label so a tested panel says what it is on the shelf.
|
|
|
- // Call it from the display lambda: `id(<display_id>).test_pattern();`.
|
|
|
- void test_pattern() {
|
|
|
+ // a statement of what the driver expects of the panel. Adds a dithered grey
|
|
|
+ // ramp so a 1bpp panel shows a graded sweep, not just two flat blocks.
|
|
|
+ //
|
|
|
+ // Pass a font to label the panel with its model (and the panel can spare the
|
|
|
+ // room); pass nothing to skip the label - handy when you just want a quick
|
|
|
+ // pattern without defining a font. From the display lambda:
|
|
|
+ // id(<display_id>).test_pattern(); // no label
|
|
|
+ // id(<display_id>).test_pattern(id(<font_id>)); // labelled
|
|
|
+ void test_pattern(display::BaseFont *font = nullptr) {
|
|
|
const int w = this->get_width();
|
|
|
const int h = this->get_height();
|
|
|
Color colors[8];
|
|
|
@@ -64,17 +64,15 @@ class GxEPD2Display : public display::DisplayBuffer {
|
|
|
const int iw = w - 2 * border;
|
|
|
int ih = h - 2 * border;
|
|
|
|
|
|
- // Name band, above every test zone. Drawn only when a font is set and
|
|
|
+ // Name band, above every test zone. Drawn only when a font was passed and
|
|
|
// the panel is tall enough to give it a fifth of the interior without
|
|
|
- // crowding the zones below - the "skip the name on panels too short to
|
|
|
- // spare ~10px above the bar" rule, sized to the actual font.
|
|
|
- if (this->name_font_ != nullptr && this->model_name_ != nullptr && this->model_name_[0] != '\0') {
|
|
|
+ // crowding the zones below.
|
|
|
+ if (font != nullptr && this->model_name_ != nullptr && this->model_name_[0] != '\0') {
|
|
|
int tw, xoff, baseline, th;
|
|
|
- this->name_font_->measure(this->model_name_, &tw, &xoff, &baseline, &th);
|
|
|
+ font->measure(this->model_name_, &tw, &xoff, &baseline, &th);
|
|
|
const int band = th + 4;
|
|
|
if (band <= ih / 5) {
|
|
|
- this->print(w / 2, y0 + band / 2, this->name_font_, Color(0x00, 0x00, 0x00),
|
|
|
- display::TextAlign::CENTER, this->model_name_);
|
|
|
+ this->print(w / 2, y0 + band / 2, font, Color(0x00, 0x00, 0x00), display::TextAlign::CENTER, this->model_name_);
|
|
|
y0 += band;
|
|
|
ih -= band;
|
|
|
}
|
|
|
@@ -352,7 +350,6 @@ class GxEPD2Display : public display::DisplayBuffer {
|
|
|
|
|
|
const EpdPanelDescriptor *desc_{nullptr};
|
|
|
const char *model_name_{nullptr};
|
|
|
- display::BaseFont *name_font_{nullptr};
|
|
|
GPIOPin *cs_{nullptr};
|
|
|
GPIOPin *dc_{nullptr};
|
|
|
GPIOPin *rst_{nullptr};
|