ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
inkplate.h
Go to the documentation of this file.
1#pragma once
2
6#include "esphome/core/hal.h"
7
8#include <array>
9
10namespace esphome::inkplate {
11
20
21static constexpr uint8_t GLUT_SIZE = 9;
22static constexpr uint8_t GLUT_COUNT = 8;
23
24static constexpr uint8_t LUT2[16] = {0xAA, 0xA9, 0xA6, 0xA5, 0x9A, 0x99, 0x96, 0x95,
25 0x6A, 0x69, 0x66, 0x65, 0x5A, 0x59, 0x56, 0x55};
26static constexpr uint8_t LUTW[16] = {0xFF, 0xFE, 0xFB, 0xFA, 0xEF, 0xEE, 0xEB, 0xEA,
27 0xBF, 0xBE, 0xBB, 0xBA, 0xAF, 0xAE, 0xAB, 0xAA};
28static constexpr uint8_t LUTB[16] = {0xFF, 0xFD, 0xF7, 0xF5, 0xDF, 0xDD, 0xD7, 0xD5,
29 0x7F, 0x7D, 0x77, 0x75, 0x5F, 0x5D, 0x57, 0x55};
30
31static constexpr uint8_t PIXEL_MASK_LUT[8] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
32static constexpr uint8_t PIXEL_MASK_GLUT[2] = {0x0F, 0xF0};
33
35 public:
36 void set_greyscale(bool greyscale) {
37 this->greyscale_ = greyscale;
38 this->block_partial_ = true;
39 if (this->is_ready())
40 this->initialize_();
41 }
42
43 void set_waveform(const std::array<uint8_t, GLUT_COUNT * GLUT_SIZE> &waveform, bool is_custom) {
44 static_assert(sizeof(this->waveform_) == sizeof(uint8_t) * GLUT_COUNT * GLUT_SIZE,
45 "waveform_ buffer size must match input waveform array size");
46 memmove(this->waveform_, waveform.data(), sizeof(this->waveform_));
47 this->custom_waveform_ = is_custom;
48 }
49
50 void set_mirror_y(bool mirror_y) { this->mirror_y_ = mirror_y; }
51 void set_mirror_x(bool mirror_x) { this->mirror_x_ = mirror_x; }
52
53 void set_partial_updating(bool partial_updating) { this->partial_updating_ = partial_updating; }
54 void set_full_update_every(uint32_t full_update_every) { this->full_update_every_ = full_update_every; }
55
56 void set_model(InkplateModel model) { this->model_ = model; }
57
66
67 void set_ckv_pin(GPIOPin *ckv) { this->ckv_pin_ = ckv; }
68 void set_cl_pin(InternalGPIOPin *cl) { this->cl_pin_ = cl; }
69 void set_gpio0_enable_pin(GPIOPin *gpio0_enable) { this->gpio0_enable_pin_ = gpio0_enable; }
70 void set_gmod_pin(GPIOPin *gmod) { this->gmod_pin_ = gmod; }
71 void set_le_pin(InternalGPIOPin *le) { this->le_pin_ = le; }
72 void set_oe_pin(GPIOPin *oe) { this->oe_pin_ = oe; }
73 void set_powerup_pin(GPIOPin *powerup) { this->powerup_pin_ = powerup; }
74 void set_sph_pin(GPIOPin *sph) { this->sph_pin_ = sph; }
75 void set_spv_pin(GPIOPin *spv) { this->spv_pin_ = spv; }
76 void set_vcom_pin(GPIOPin *vcom) { this->vcom_pin_ = vcom; }
77 void set_wakeup_pin(GPIOPin *wakeup) { this->wakeup_pin_ = wakeup; }
78
79 float get_setup_priority() const override;
80
81 void dump_config() override;
82
83 void display();
84 void clean();
85 void fill(Color color) override;
86
87 void update() override;
88
89 void setup() override;
90
91 uint8_t get_panel_state() { return this->panel_on_; }
92 bool get_greyscale() { return this->greyscale_; }
93 bool get_partial_updating() { return this->partial_updating_; }
94 uint8_t get_temperature() { return this->temperature_; }
95
96 void block_partial() { this->block_partial_ = true; }
97
101
102 protected:
103 void draw_absolute_pixel_internal(int x, int y, Color color) override;
104 void display1b_();
105 void display3b_();
106 void initialize_();
107 bool partial_update_();
108 void clean_fast_(uint8_t c, uint8_t rep);
109
110 void hscan_start_(uint32_t d);
111 void vscan_end_();
112 void vscan_start_();
113
114 void eink_off_();
115 void eink_on_();
116 bool read_power_status_();
117
119 void pins_z_state_();
120 void pins_as_outputs_();
121
122 int get_width_internal() override {
123 if (this->model_ == INKPLATE_6 || this->model_ == INKPLATE_6_V2) {
124 return 800;
125 } else if (this->model_ == INKPLATE_10) {
126 return 1200;
127 } else if (this->model_ == INKPLATE_5) {
128 return 960;
129 } else if (this->model_ == INKPLATE_5_V2) {
130 return 1280;
131 } else if (this->model_ == INKPLATE_6_PLUS) {
132 return 1024;
133 }
134 return 0;
135 }
136
137 int get_height_internal() override {
138 if (this->model_ == INKPLATE_6 || this->model_ == INKPLATE_6_V2) {
139 return 600;
140 } else if (this->model_ == INKPLATE_5) {
141 return 540;
142 } else if (this->model_ == INKPLATE_5_V2) {
143 return 720;
144 } else if (this->model_ == INKPLATE_10) {
145 return 825;
146 } else if (this->model_ == INKPLATE_6_PLUS) {
147 return 758;
148 }
149 return 0;
150 }
151
152 size_t get_buffer_length_();
153
155 uint32_t data = 0;
156 data |= (1UL << this->display_data_0_pin_->get_pin());
157 data |= (1UL << this->display_data_1_pin_->get_pin());
158 data |= (1UL << this->display_data_2_pin_->get_pin());
159 data |= (1UL << this->display_data_3_pin_->get_pin());
160 data |= (1UL << this->display_data_4_pin_->get_pin());
161 data |= (1UL << this->display_data_5_pin_->get_pin());
162 data |= (1UL << this->display_data_6_pin_->get_pin());
163 data |= (1UL << this->display_data_7_pin_->get_pin());
164 return data;
165 }
166
167 bool panel_on_{false};
169
170 uint8_t *partial_buffer_{nullptr};
171 uint8_t *partial_buffer_2_{nullptr};
172
173 uint32_t *glut_{nullptr};
174 uint32_t *glut2_{nullptr};
176
179
180 bool block_partial_{true};
182 bool mirror_y_{false};
183 bool mirror_x_{false};
185 bool custom_waveform_{false};
186 uint8_t waveform_[GLUT_COUNT][GLUT_SIZE];
187
189
198
210};
211
212} // namespace esphome::inkplate
bool is_ready() const
virtual uint8_t get_pin() const =0
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:132
InternalGPIOPin * cl_pin_
Definition inkplate.h:200
void set_mirror_x(bool mirror_x)
Definition inkplate.h:51
void set_model(InkplateModel model)
Definition inkplate.h:56
void fill(Color color) override
Definition inkplate.cpp:303
InternalGPIOPin * display_data_0_pin_
Definition inkplate.h:190
void clean_fast_(uint8_t c, uint8_t rep)
Definition inkplate.cpp:737
void set_spv_pin(GPIOPin *spv)
Definition inkplate.h:75
void hscan_start_(uint32_t d)
Definition inkplate.cpp:707
void set_display_data_3_pin(InternalGPIOPin *data)
Definition inkplate.h:61
void set_gpio0_enable_pin(GPIOPin *gpio0_enable)
Definition inkplate.h:69
void set_display_data_6_pin(InternalGPIOPin *data)
Definition inkplate.h:64
InternalGPIOPin * display_data_7_pin_
Definition inkplate.h:197
void set_wakeup_pin(GPIOPin *wakeup)
Definition inkplate.h:77
InternalGPIOPin * le_pin_
Definition inkplate.h:203
InternalGPIOPin * display_data_4_pin_
Definition inkplate.h:194
display::DisplayType get_display_type() override
Definition inkplate.h:98
InternalGPIOPin * display_data_1_pin_
Definition inkplate.h:191
void set_ckv_pin(GPIOPin *ckv)
Definition inkplate.h:67
void set_display_data_0_pin(InternalGPIOPin *data)
Definition inkplate.h:58
void set_cl_pin(InternalGPIOPin *cl)
Definition inkplate.h:68
void draw_absolute_pixel_internal(int x, int y, Color color) override
Definition inkplate.cpp:160
void set_display_data_5_pin(InternalGPIOPin *data)
Definition inkplate.h:63
void set_display_data_4_pin(InternalGPIOPin *data)
Definition inkplate.h:62
void set_sph_pin(GPIOPin *sph)
Definition inkplate.h:74
uint8_t waveform_[GLUT_COUNT][GLUT_SIZE]
Definition inkplate.h:186
void set_display_data_1_pin(InternalGPIOPin *data)
Definition inkplate.h:59
void dump_config() override
Definition inkplate.cpp:192
int get_width_internal() override
Definition inkplate.h:122
InternalGPIOPin * display_data_6_pin_
Definition inkplate.h:196
void set_vcom_pin(GPIOPin *vcom)
Definition inkplate.h:76
void set_le_pin(InternalGPIOPin *le)
Definition inkplate.h:71
void set_display_data_7_pin(InternalGPIOPin *data)
Definition inkplate.h:65
void set_oe_pin(GPIOPin *oe)
Definition inkplate.h:72
void set_waveform(const std::array< uint8_t, GLUT_COUNT *GLUT_SIZE > &waveform, bool is_custom)
Definition inkplate.h:43
void set_full_update_every(uint32_t full_update_every)
Definition inkplate.h:54
InternalGPIOPin * display_data_3_pin_
Definition inkplate.h:193
InternalGPIOPin * display_data_5_pin_
Definition inkplate.h:195
InternalGPIOPin * display_data_2_pin_
Definition inkplate.h:192
void set_gmod_pin(GPIOPin *gmod)
Definition inkplate.h:70
void set_display_data_2_pin(InternalGPIOPin *data)
Definition inkplate.h:60
int get_height_internal() override
Definition inkplate.h:137
float get_setup_priority() const override
Definition inkplate.cpp:140
void set_partial_updating(bool partial_updating)
Definition inkplate.h:53
void set_powerup_pin(GPIOPin *powerup)
Definition inkplate.h:73
void set_mirror_y(bool mirror_y)
Definition inkplate.h:50
void initialize_()
Allocate buffers.
Definition inkplate.cpp:60
void set_greyscale(bool greyscale)
Definition inkplate.h:36
static void uint32_t
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6