zepd_display.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. #pragma once
  2. #include "esphome/core/component.h"
  3. #include "esphome/core/helpers.h"
  4. #include "esphome/components/display/display_buffer.h"
  5. #include "esphome/components/spi/spi.h"
  6. #include "engine.h"
  7. #include "engine_model.h"
  8. #include "zepd_model_generated.h"
  9. namespace esphome::zepd {
  10. static const char *const TAG = "zepd";
  11. // ESPHome display component (the engine adapter) for a zEPD model. The
  12. // model arrives as one codegen'd zepd::EngineModel, selected at ESPHome
  13. // compile time by display.py from the drivers/*.json registry (see
  14. // claude/DESCRIPTOR_REGISTRY_PLAN.md) and written to
  15. // zepd_model_generated.h - not templated over per-panel C++ classes the
  16. // way GxEPD2 itself is. Driven by zepd::Engine, the generic replay state
  17. // machine; this class is the ESPHome-side half of the engine adapter.
  18. class ZepdDisplay : public display::DisplayBuffer {
  19. public:
  20. void set_cs_pin(GPIOPin *pin) { this->cs_ = pin; }
  21. void set_dc_pin(GPIOPin *pin) { this->dc_ = pin; }
  22. void set_reset_pin(GPIOPin *pin) { this->rst_ = pin; }
  23. void set_busy_pin(GPIOPin *pin) { this->busy_ = pin; }
  24. void set_spi_parent(spi::SPIComponent *parent) { this->spi_.set_spi_parent(parent); }
  25. void set_descriptor(const EngineModel *desc) { this->desc_ = desc; }
  26. void set_invert_mono(bool invert) { this->invert_mono_ = invert; }
  27. // The short model label test_pattern() can print, derived from the
  28. // registry's oem_part_numbers[0] (see display.py).
  29. void set_model_name(const char *name) { this->model_name_ = name; }
  30. // Whether this model's data is confirmed on real hardware (vs captured
  31. // but not yet bench-verified) - surfaced in dump_config(). From the
  32. // registry's `verified` field, via display.py.
  33. void set_verified(bool v) { this->verified_ = v; }
  34. // Bench visual-check pattern, bit-depth aware. Everything scales to what
  35. // THIS panel can actually show (see test_colors_): the color-bar count,
  36. // the ladder color cycle and the corner markers all follow the panel's
  37. // real color set instead of a hardcoded 4, so the drawn pattern doubles as
  38. // a statement of what the engine model expects of the panel. Adds a
  39. // dithered grey ramp so a 1bpp panel shows a graded sweep, not just two
  40. // flat blocks.
  41. //
  42. // Pass a font to label the panel with its model (and the panel can spare the
  43. // room); pass nothing to skip the label - handy when you just want a quick
  44. // pattern without defining a font. From the display lambda:
  45. // id(<display_id>).test_pattern(); // no label
  46. // id(<display_id>).test_pattern(id(<font_id>)); // labelled
  47. void test_pattern(display::BaseFont *font = nullptr) {
  48. const int w = this->get_width();
  49. const int h = this->get_height();
  50. Color colors[8];
  51. const int n = this->test_colors_(colors, 8);
  52. this->fill(Color(0xFF, 0xFF, 0xFF));
  53. const int smin = w < h ? w : h;
  54. const int border = smin / 100 > 1 ? smin / 100 : 1;
  55. const int x0 = border;
  56. int y0 = border;
  57. const int iw = w - 2 * border;
  58. int ih = h - 2 * border;
  59. // Name band, above every test zone. Drawn only when a font was passed and
  60. // the panel is tall enough to give it a fifth of the interior without
  61. // crowding the zones below.
  62. if (font != nullptr && this->model_name_ != nullptr && this->model_name_[0] != '\0') {
  63. int tw, xoff, baseline, th;
  64. font->measure(this->model_name_, &tw, &xoff, &baseline, &th);
  65. const int band = th + 4;
  66. if (band <= ih / 5) {
  67. this->print(w / 2, y0 + band / 2, font, Color(0x00, 0x00, 0x00), display::TextAlign::CENTER, this->model_name_);
  68. y0 += band;
  69. ih -= band;
  70. }
  71. }
  72. // Vertical budget for the four zones below any name band.
  73. const int bars_h = ih * 34 / 100;
  74. int dither_h = ih * 12 / 100;
  75. if (dither_h < 8) dither_h = 8;
  76. const int row_h = ih * 18 / 100 > 2 ? ih * 18 / 100 : 2;
  77. const int dy = y0 + bars_h;
  78. const int ry = dy + dither_h;
  79. const int col_y = ry + row_h;
  80. const int col_h = (y0 + ih) - col_y;
  81. // Color bars: one solid block per available color, in palette/wire-code
  82. // order (black, white, then the accents). A wrong or missing block
  83. // points straight at the color - or the wire code - it stands for.
  84. const int bar_w = iw / n;
  85. for (int i = 0; i < n; i++) {
  86. const int bx = x0 + i * bar_w;
  87. const int bw = (i == n - 1) ? (x0 + iw - bx) : bar_w;
  88. this->filled_rectangle(bx, y0, bw, bars_h, colors[i]);
  89. }
  90. // Dithered grey ramp: brightness 255 (left) -> 0 (right) via an ordered
  91. // 4x4 Bayer threshold. On a 1bpp panel this is the only zone that shows
  92. // a graded sweep; on deeper panels it's a quick mono/uniformity check.
  93. static const uint8_t BAYER4[4][4] = {
  94. {0, 8, 2, 10}, {12, 4, 14, 6}, {3, 11, 1, 9}, {15, 7, 13, 5}};
  95. for (int yy = 0; yy < dither_h; yy++) {
  96. for (int xx = 0; xx < iw; xx++) {
  97. const int bright = (iw <= 1) ? 255 : 255 - xx * 255 / (iw - 1);
  98. const int thr = (BAYER4[yy & 3][xx & 3] * 2 + 1) * 255 / 32;
  99. if (bright <= thr)
  100. this->draw_pixel_at(x0 + xx, dy + yy, Color(0x00, 0x00, 0x00));
  101. }
  102. }
  103. // Row ladder: 1px rows cycling the full color set - a dropped, doubled
  104. // or reordered row breaks the N-row cadence.
  105. for (int yy = 0; yy < row_h; yy++)
  106. this->horizontal_line(x0, ry + yy, iw, colors[yy % n]);
  107. // Column ladder: the same rotated 90 degrees, catching nibble/column
  108. // order bugs the row ladder can't (packed formats put several pixels per
  109. // byte, so a column-order fault can leave every row looking fine).
  110. for (int xx = 0; xx < iw; xx++)
  111. this->vertical_line(x0 + xx, col_y, col_h, colors[xx % n]);
  112. // Corner markers for orientation, using the panel's ink colors (every
  113. // color but white). BL is always black; TL/TR take the next inks when
  114. // the panel has them; BR is left blank as the distinct "no marker"
  115. // state. A 90/180 rotation or mirror can't survive this even though the
  116. // bars and ladders are otherwise symmetric.
  117. Color ink[8];
  118. int ni = 0;
  119. for (int i = 0; i < n; i++) {
  120. if (colors[i].red == 0xFF && colors[i].green == 0xFF && colors[i].blue == 0xFF)
  121. continue; // skip white - a white marker is invisible
  122. ink[ni++] = colors[i];
  123. }
  124. const int mk = smin / 12 > 3 ? smin / 12 : 3;
  125. if (ni > 0) this->filled_rectangle(x0, y0 + ih - mk, mk, mk, ink[0]); // BL
  126. if (ni > 1) this->filled_rectangle(x0, y0, mk, mk, ink[1]); // TL
  127. if (ni > 2) this->filled_rectangle(x0 + iw - mk, y0, mk, mk, ink[2]); // TR
  128. // Corner-to-corner diagonals over everything: the cheapest coordinate-
  129. // transform check - a clean line means no row/column reordering.
  130. this->line(0, 0, w - 1, h - 1, Color(0x00, 0x00, 0x00));
  131. this->line(w - 1, 0, 0, h - 1, Color(0x00, 0x00, 0x00));
  132. // Border frame last, so it stays an unbroken rectangle on all four edges
  133. // even where a zone fills to the edge - catches a clipped/offset origin.
  134. this->rectangle(0, 0, w, h, Color(0x00, 0x00, 0x00));
  135. }
  136. void setup() override {
  137. const auto *desc = this->desc_;
  138. // window_per_plane panels (e.g. a master+slave dual-region panel) size
  139. // each plane's own buffer from plane_width (each region's own local
  140. // width), not the descriptor's overall width (the full logical canvas
  141. // the adapter draws into) - both regions are the same size here, so
  142. // one plane_bytes_ value covers both buffers.
  143. uint32_t w = desc->window_per_plane ? desc->plane_width : desc->width;
  144. // width*height*bpp/8: /8 at 1bpp, /4 at 2bpp (4-color), /2 at 4bpp (7-color).
  145. this->plane_bytes_ = (uint32_t) w * desc->height * desc->bits_per_pixel / 8;
  146. RAMAllocator<uint8_t> allocator;
  147. this->plane0_ = allocator.allocate(this->plane_bytes_);
  148. bool need_plane1 = desc->plane_count > 1;
  149. this->plane1_ = need_plane1 ? allocator.allocate(this->plane_bytes_) : nullptr;
  150. if (this->plane0_ == nullptr || (need_plane1 && this->plane1_ == nullptr)) {
  151. ESP_LOGE(TAG, "Failed to allocate %u-byte plane buffer(s)", (unsigned) this->plane_bytes_);
  152. this->mark_failed();
  153. return;
  154. }
  155. if (desc->bits_per_pixel > 1) {
  156. // Packed modes: clear every pixel to the panel's white/blank code,
  157. // replicated across the byte - e.g. 4-color white=0x01 -> 0x55, 7-color
  158. // white=0x01 -> 0x11, matching GxEPD2's own writeScreenBuffer() fill
  159. // (color4()*0x55 / color7()|<<4). Both regions of a window_per_plane
  160. // panel (master/slave) get the same blank fill.
  161. uint8_t fill = replicate_code_(desc->blank_code, desc->bits_per_pixel);
  162. memset(this->plane0_, fill, this->plane_bytes_);
  163. if (this->plane1_ != nullptr)
  164. memset(this->plane1_, fill, this->plane_bytes_);
  165. } else {
  166. // 1bpp plane model: plane0 white = all bits set (0xFF); plane1 (the
  167. // accent/red plane, when present) = 0 = not-red.
  168. memset(this->plane0_, 0xFF, this->plane_bytes_);
  169. if (this->plane1_ != nullptr)
  170. memset(this->plane1_, 0x00, this->plane_bytes_);
  171. }
  172. this->spi_.spi_setup();
  173. this->engine_.begin(desc, this->cs_, this->dc_, this->rst_, this->busy_, &this->spi_);
  174. }
  175. // Arms the state machine and returns immediately - the real several-
  176. // seconds-long write/refresh/busy-wait cycle happens across many
  177. // subsequent loop() ticks, not before this call returns.
  178. void update() override {
  179. if (!this->engine_.idle()) {
  180. ESP_LOGW(TAG, "Skipping update: previous display refresh is still running");
  181. return;
  182. }
  183. this->do_update_();
  184. this->engine_.request_full_update(this->plane0_, this->plane1_);
  185. }
  186. void loop() override { this->engine_.step(); }
  187. // True once the engine has returned to idle after the last update()/
  188. // power_off()/hibernate() call. Lets a more complex application (a lambda
  189. // chaining several updates, a deep_sleep automation deciding whether to
  190. // wait) check "is the panel still mid-refresh" instead of guessing from
  191. // timing - the same thing power_off()/hibernate()'s own guards below check
  192. // internally.
  193. bool idle() const { return this->engine_.idle(); }
  194. // Turns off the panel's driving-voltage generation (reduces fading over
  195. // time between refreshes). Call from a lambda, e.g.
  196. // id(<display_id>).power_off(); - not called automatically by update(),
  197. // since this engine does a full hardware reset every cycle regardless of
  198. // prior power state, so correctness never depends on it. (It IS called
  199. // automatically from on_powerdown() below.) Safe to call mid-refresh: see
  200. // zepd::Engine::request_power_off().
  201. void power_off() {
  202. if (!this->engine_.idle())
  203. ESP_LOGW(TAG, "power_off() called mid-refresh; aborting the in-progress update");
  204. this->engine_.request_power_off();
  205. }
  206. // power_off() + deep sleep, wakeable only by a hardware reset pulse - which
  207. // the next update() always issues (request_full_update()'s RESET_LOW), so
  208. // no paired "wake" call is needed; just call update() as usual. Safe to
  209. // call mid-refresh: see zepd::Engine::request_hibernate().
  210. void hibernate() {
  211. if (!this->engine_.idle())
  212. ESP_LOGW(TAG, "hibernate() called mid-refresh; aborting the in-progress update");
  213. this->engine_.request_hibernate();
  214. }
  215. // ESPHome calls this on every component right before deep_sleep actually
  216. // suspends the MCU, and on safe_reboot() - see
  217. // Application::run_powerdown_hooks() (fires after teardown_components()
  218. // completes or times out, deep_sleep's should_teardown_() is unconditional
  219. // on every supported platform). Powers the panel down with no YAML/lambda
  220. // needed for the common case: hibernate() when a reset pin is wired (the
  221. // next update()'s unconditional RESET_LOW wakes it - see hibernate()
  222. // above), else power_off() (needs no reset pulse to recover, so it's safe
  223. // with no rst pin at all).
  224. //
  225. // Deliberately NOT paired with a teardown() override to wait out a
  226. // mid-flight refresh: ESPHome's teardown budget (1s on reboot, 5s on deep
  227. // sleep) is far shorter than this engine's slower busy_timeout_ms classes
  228. // (up to 45-60s for 4bpp/7-color panels), so stalling teardown here would
  229. // just lose that race every time and get force-advanced anyway - the
  230. // budget is sized for a network flush (see api_server::teardown()), not a
  231. // hardware operation. If a refresh is still running when this fires,
  232. // power_off()/hibernate() abort it with a reset pulse first rather than
  233. // writing a power-down command over a controller that's still asserting
  234. // BUSY and would just ignore it (see zepd::Engine::request_power_off()). A
  235. // caller who cares about that race can check idle() (above) and hold off
  236. // triggering deep sleep themselves.
  237. void on_powerdown() override {
  238. if (this->rst_ != nullptr) {
  239. this->hibernate();
  240. } else {
  241. this->power_off();
  242. }
  243. }
  244. #ifdef USE_ZEPD_DIAGNOSTICS
  245. // Dev-time diagnostics - compiled out entirely unless this display's YAML
  246. // sets `diagnostics: true` (display.py then adds -DUSE_ZEPD_DIAGNOSTICS),
  247. // so a production build pays nothing for them. A stash for throwaway bench
  248. // tests, not a stable API - add more here as needed, don't feel obliged to
  249. // keep any of it around once a test has done its job.
  250. //
  251. // Draws the current lambda/pages content and pushes it WITHOUT the reset
  252. // pulse update() normally does first - see
  253. // zepd::Engine::diag_request_update_no_reset(). Call from a lambda, e.g. to
  254. // check whether power_off()/hibernate() actually took: call one of those,
  255. // then this with a pattern distinct from what's already on screen - no
  256. // change (or odd BUSY behavior) means the panel really is off-line; follow
  257. // with a normal update() to confirm the next real reset wakes it and to
  258. // leave the panel in a known state either way.
  259. void diag_update_no_reset() {
  260. if (!this->engine_.idle()) {
  261. ESP_LOGW(TAG, "Skipping diag_update_no_reset: display refresh still in progress");
  262. return;
  263. }
  264. this->do_update_();
  265. this->engine_.diag_request_update_no_reset(this->plane0_, this->plane1_);
  266. }
  267. #endif
  268. void dump_config() override {
  269. ESP_LOGCONFIG(TAG, "zEPD Display:");
  270. ESP_LOGCONFIG(TAG, " Model: %s", this->model_name_ != nullptr ? this->model_name_ : "(unknown)");
  271. ESP_LOGCONFIG(TAG, " Dimensions: %ux%u", (unsigned) this->desc_->width, (unsigned) this->desc_->height);
  272. ESP_LOGCONFIG(TAG, " Bits/pixel: %u (%s)", (unsigned) this->desc_->bits_per_pixel,
  273. this->desc_->bits_per_pixel == 1 ? "mono/plane" : "packed palette");
  274. ESP_LOGCONFIG(TAG, " Planes/regions: %u", (unsigned) this->desc_->plane_count);
  275. ESP_LOGCONFIG(TAG, " Busy active level: %s", this->desc_->busy_active_level ? "HIGH" : "LOW");
  276. if (this->desc_->bits_per_pixel == 1)
  277. ESP_LOGCONFIG(TAG, " invert_mono: %s", YESNO(this->invert_mono_));
  278. ESP_LOGCONFIG(TAG, " Hardware-verified: %s", YESNO(this->verified_));
  279. if (!this->verified_)
  280. ESP_LOGW(TAG, "Model %s is not yet hardware-verified - the captured data may be wrong; "
  281. "if it renders correctly, please report it so it can be marked verified",
  282. this->model_name_ != nullptr ? this->model_name_ : "(unknown)");
  283. LOG_UPDATE_INTERVAL(this);
  284. }
  285. display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_COLOR; }
  286. protected:
  287. // Replicates a packed wire code across a whole byte (one code per pixel
  288. // slot), e.g. 2bpp code 0x01 -> 0x55, 4bpp code 0x01 -> 0x11.
  289. static uint8_t replicate_code_(uint8_t code, uint8_t bpp) {
  290. uint8_t mask = static_cast<uint8_t>((1u << bpp) - 1);
  291. uint8_t out = 0;
  292. for (uint8_t i = 0; i < 8 / bpp; i++)
  293. out = static_cast<uint8_t>((out << bpp) | (code & mask));
  294. return out;
  295. }
  296. // Maps a drawn RGB color to its panel wire code via the descriptor's
  297. // palette: exact matches win (so named colors are deterministic, like
  298. // GxEPD2's color4()/color7() switch), otherwise nearest in RGB space.
  299. static uint8_t classify_(Color c, const EpdPaletteEntry *pal, uint8_t len) {
  300. if (pal == nullptr || len == 0)
  301. return 0;
  302. uint8_t best = 0;
  303. long best_d = -1;
  304. for (uint8_t i = 0; i < len; i++) {
  305. long dr = static_cast<long>(c.red) - pal[i].r;
  306. long dg = static_cast<long>(c.green) - pal[i].g;
  307. long db = static_cast<long>(c.blue) - pal[i].b;
  308. long d = dr * dr + dg * dg + db * db;
  309. if (d == 0)
  310. return pal[i].code;
  311. if (best_d < 0 || d < best_d) {
  312. best_d = d;
  313. best = i;
  314. }
  315. }
  316. return pal[best].code;
  317. }
  318. // Packed code-per-pixel model (bits_per_pixel > 1): N bits/pixel, MSB
  319. // first, matching GxEPD2's own out_data packing in writeImage (4-color
  320. // 4px/byte, 7-color 2px/byte). Routes to the correct region for a
  321. // window_per_plane (master/slave) panel the same way the mono path does.
  322. void draw_packed_(int x, int y, Color color) {
  323. const uint8_t bpp = this->desc_->bits_per_pixel;
  324. uint8_t code = classify_(color, this->desc_->palette, this->desc_->palette_len);
  325. uint16_t stride = this->desc_->width;
  326. uint8_t *buf = this->plane0_;
  327. int local_x = x;
  328. if (this->desc_->window_per_plane && this->desc_->plane_count > 1) {
  329. stride = this->desc_->plane_width;
  330. if (x >= stride) {
  331. buf = this->plane1_;
  332. local_x = x - stride;
  333. }
  334. }
  335. uint32_t px = static_cast<uint32_t>(y) * stride + local_x;
  336. const uint8_t ppb = 8 / bpp;
  337. uint32_t idx = px / ppb;
  338. uint8_t shift = static_cast<uint8_t>((ppb - 1 - (px % ppb)) * bpp);
  339. uint8_t mask = static_cast<uint8_t>((1u << bpp) - 1);
  340. buf[idx] = static_cast<uint8_t>((buf[idx] & ~(mask << shift)) | ((code & mask) << shift));
  341. }
  342. void draw_absolute_pixel_internal(int x, int y, Color color) override {
  343. if (x < 0 || y < 0 || x >= this->desc_->width || y >= this->desc_->height)
  344. return;
  345. if (this->desc_->bits_per_pixel > 1) {
  346. this->draw_packed_(x, y, color);
  347. return;
  348. }
  349. bool red = color.red > color.green && color.red > color.blue && color.red > 0x7f;
  350. bool bright = color.red > 0x7f || color.green > 0x7f || color.blue > 0x7f;
  351. uint32_t idx = (static_cast<uint32_t>(y) * this->desc_->width + x) / 8;
  352. uint8_t mask = 0x80 >> (x % 8);
  353. // Red/accent pixels go to the color plane (when the panel has one),
  354. // everything else is black/white on the black plane. get_display_type()
  355. // reports DISPLAY_TYPE_COLOR, so callers draw literal RGB colors, not
  356. // the on/off is_on() convention, even on a plane_count==1 (BW-only)
  357. // panel - there just is no color plane for a "red" classification to
  358. // land on.
  359. //
  360. // Buffer convention here is 1=red/0=not-red, transformed to the wire
  361. // value by plane_invert[1].
  362. if (red && this->plane1_ != nullptr) {
  363. this->plane1_[idx] |= mask;
  364. } else {
  365. if (this->plane1_ != nullptr)
  366. this->plane1_[idx] &= ~mask;
  367. // plane0 bit set = white/blank. invert_mono_ flips the mono sense so a
  368. // bright color (e.g. ESPHome's default COLOR_ON) becomes ink, not blank
  369. // - see display.py's CONF_INVERT_MONO. Red classification is unaffected.
  370. if (bright ^ this->invert_mono_) {
  371. this->plane0_[idx] |= mask;
  372. } else {
  373. this->plane0_[idx] &= ~mask;
  374. }
  375. }
  376. }
  377. int get_width_internal() override { return this->desc_->width; }
  378. int get_height_internal() override { return this->desc_->height; }
  379. // The colors this panel can actually show, each as a representative RGB, in
  380. // a stable order (black, white, then accents). Packed panels (>1bpp): one
  381. // entry per distinct palette wire code, first RGB seen for each. 1bpp:
  382. // black + white, plus red when a second plane exists for the accent (only
  383. // red-classified pixels reach it - see draw_absolute_pixel_internal). This
  384. // is what makes test_pattern() bit-depth aware. Returns the count.
  385. int test_colors_(Color *out, int max) {
  386. int n = 0;
  387. if (this->desc_->bits_per_pixel > 1 && this->desc_->palette != nullptr) {
  388. uint8_t seen[16];
  389. int seen_n = 0;
  390. for (int i = 0; i < this->desc_->palette_len && n < max; i++) {
  391. const uint8_t code = this->desc_->palette[i].code;
  392. bool dup = false;
  393. for (int j = 0; j < seen_n; j++)
  394. if (seen[j] == code) { dup = true; break; }
  395. if (dup) continue;
  396. if (seen_n < (int) sizeof(seen)) seen[seen_n++] = code;
  397. const auto &e = this->desc_->palette[i];
  398. out[n++] = Color(e.r, e.g, e.b);
  399. }
  400. } else {
  401. if (n < max) out[n++] = Color(0x00, 0x00, 0x00); // black
  402. if (n < max) out[n++] = Color(0xFF, 0xFF, 0xFF); // white
  403. if (this->desc_->plane_count >= 2 && n < max) out[n++] = Color(0xFF, 0x00, 0x00); // accent
  404. }
  405. return n;
  406. }
  407. const EngineModel *desc_{nullptr};
  408. const char *model_name_{nullptr};
  409. bool verified_{false};
  410. GPIOPin *cs_{nullptr};
  411. GPIOPin *dc_{nullptr};
  412. GPIOPin *rst_{nullptr};
  413. GPIOPin *busy_{nullptr};
  414. EpdSPIDevice spi_;
  415. Engine engine_;
  416. uint8_t *plane0_{nullptr};
  417. uint8_t *plane1_{nullptr};
  418. uint32_t plane_bytes_{0};
  419. bool invert_mono_{false};
  420. };
  421. } // namespace esphome::zepd