ESPHome 2025.6.3
Loading...
Searching...
No Matches
inkplate.h
Go to the documentation of this file.
1#pragma once
2
6#include "esphome/core/hal.h"
7
8namespace esphome {
9namespace inkplate6 {
10
19
21 public:
22 const uint8_t LUT2[16] = {0xAA, 0xA9, 0xA6, 0xA5, 0x9A, 0x99, 0x96, 0x95,
23 0x6A, 0x69, 0x66, 0x65, 0x5A, 0x59, 0x56, 0x55};
24 const uint8_t LUTW[16] = {0xFF, 0xFE, 0xFB, 0xFA, 0xEF, 0xEE, 0xEB, 0xEA,
25 0xBF, 0xBE, 0xBB, 0xBA, 0xAF, 0xAE, 0xAB, 0xAA};
26 const uint8_t LUTB[16] = {0xFF, 0xFD, 0xF7, 0xF5, 0xDF, 0xDD, 0xD7, 0xD5,
27 0x7F, 0x7D, 0x77, 0x75, 0x5F, 0x5D, 0x57, 0x55};
28
29 const uint8_t pixelMaskLUT[8] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
30 const uint8_t pixelMaskGLUT[2] = {0x0F, 0xF0};
31
32 const uint8_t waveform3BitAll[6][8][9] = {// INKPLATE_6
33 {{0, 1, 1, 0, 0, 1, 1, 0, 0},
34 {0, 1, 2, 1, 1, 2, 1, 0, 0},
35 {1, 1, 1, 2, 2, 1, 0, 0, 0},
36 {0, 0, 0, 1, 1, 1, 2, 0, 0},
37 {2, 1, 1, 1, 2, 1, 2, 0, 0},
38 {2, 2, 1, 1, 2, 1, 2, 0, 0},
39 {1, 1, 1, 2, 1, 2, 2, 0, 0},
40 {0, 0, 0, 0, 0, 0, 2, 0, 0}},
41 // INKPLATE_10
42 {{0, 0, 0, 0, 0, 0, 0, 1, 0},
43 {0, 0, 0, 2, 2, 2, 1, 1, 0},
44 {0, 0, 2, 1, 1, 2, 2, 1, 0},
45 {0, 1, 2, 2, 1, 2, 2, 1, 0},
46 {0, 0, 2, 1, 2, 2, 2, 1, 0},
47 {0, 2, 2, 2, 2, 2, 2, 1, 0},
48 {0, 0, 0, 0, 0,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 2, 2, 1, 2, 0},
85 {0, 0, 0, 0, 0, 0, 0, 0, 0}}};
86
87 void set_greyscale(bool greyscale) {
88 this->greyscale_ = greyscale;
89 this->block_partial_ = true;
90 if (this->is_ready())
91 this->initialize_();
92 }
93 void set_mirror_y(bool mirror_y) { this->mirror_y_ = mirror_y; }
94 void set_mirror_x(bool mirror_x) { this->mirror_x_ = mirror_x; }
95
96 void set_partial_updating(bool partial_updating) { this->partial_updating_ = partial_updating; }
97 void set_full_update_every(uint32_t full_update_every) { this->full_update_every_ = full_update_every; }
98
99 void set_model(InkplateModel model) { this->model_ = model; }
100
109
110 void set_ckv_pin(GPIOPin *ckv) { this->ckv_pin_ = ckv; }
111 void set_cl_pin(InternalGPIOPin *cl) { this->cl_pin_ = cl; }
112 void set_gpio0_enable_pin(GPIOPin *gpio0_enable) { this->gpio0_enable_pin_ = gpio0_enable; }
113 void set_gmod_pin(GPIOPin *gmod) { this->gmod_pin_ = gmod; }
114 void set_le_pin(InternalGPIOPin *le) { this->le_pin_ = le; }
115 void set_oe_pin(GPIOPin *oe) { this->oe_pin_ = oe; }
116 void set_powerup_pin(GPIOPin *powerup) { this->powerup_pin_ = powerup; }
117 void set_sph_pin(GPIOPin *sph) { this->sph_pin_ = sph; }
118 void set_spv_pin(GPIOPin *spv) { this->spv_pin_ = spv; }
119 void set_vcom_pin(GPIOPin *vcom) { this->vcom_pin_ = vcom; }
120 void set_wakeup_pin(GPIOPin *wakeup) { this->wakeup_pin_ = wakeup; }
121
122 float get_setup_priority() const override;
123
124 void dump_config() override;
125
126 void display();
127 void clean();
128 void fill(Color color) override;
129
130 void update() override;
131
132 void setup() override;
133
134 uint8_t get_panel_state() { return this->panel_on_; }
135 bool get_greyscale() { return this->greyscale_; }
137 uint8_t get_temperature() { return this->temperature_; }
138
139 void block_partial() { this->block_partial_ = true; }
140
144
145 protected:
146 void draw_absolute_pixel_internal(int x, int y, Color color) override;
147 void display1b_();
148 void display3b_();
149 void initialize_();
150 bool partial_update_();
151 void clean_fast_(uint8_t c, uint8_t rep);
152
153 void hscan_start_(uint32_t d);
154 void vscan_end_();
155 void vscan_start_();
156
157 void eink_off_();
158 void eink_on_();
159 bool read_power_status_();
160
162 void pins_z_state_();
163 void pins_as_outputs_();
164
165 int get_width_internal() override {
166 if (this->model_ == INKPLATE_6 || this->model_ == INKPLATE_6_V2) {
167 return 800;
168 } else if (this->model_ == INKPLATE_10) {
169 return 1200;
170 } else if (this->model_ == INKPLATE_5) {
171 return 960;
172 } else if (this->model_ == INKPLATE_5_V2) {
173 return 1280;
174 } else if (this->model_ == INKPLATE_6_PLUS) {
175 return 1024;
176 }
177 return 0;
178 }
179
180 int get_height_internal() override {
181 if (this->model_ == INKPLATE_6 || this->model_ == INKPLATE_6_V2) {
182 return 600;
183 } else if (this->model_ == INKPLATE_5) {
184 return 540;
185 } else if (this->model_ == INKPLATE_5_V2) {
186 return 720;
187 } else if (this->model_ == INKPLATE_10) {
188 return 825;
189 } else if (this->model_ == INKPLATE_6_PLUS) {
190 return 758;
191 }
192 return 0;
193 }
194
195 size_t get_buffer_length_();
196
198 int data = 0;
199 data |= (1 << this->display_data_0_pin_->get_pin());
200 data |= (1 << this->display_data_1_pin_->get_pin());
201 data |= (1 << this->display_data_2_pin_->get_pin());
202 data |= (1 << this->display_data_3_pin_->get_pin());
203 data |= (1 << this->display_data_4_pin_->get_pin());
204 data |= (1 << this->display_data_5_pin_->get_pin());
205 data |= (1 << this->display_data_6_pin_->get_pin());
206 data |= (1 << this->display_data_7_pin_->get_pin());
207 return data;
208 }
209
210 bool panel_on_{false};
212
213 uint8_t *partial_buffer_{nullptr};
214 uint8_t *partial_buffer_2_{nullptr};
215
216 uint32_t *glut_{nullptr};
217 uint32_t *glut2_{nullptr};
218 uint32_t pin_lut_[256];
219
221 uint32_t partial_updates_{0};
222
223 bool block_partial_{true};
225 bool mirror_y_{false};
226 bool mirror_x_{false};
228
230
239
251};
252
253} // namespace inkplate6
254} // namespace esphome
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:133
void set_model(InkplateModel model)
Definition inkplate.h:99
void set_spv_pin(GPIOPin *spv)
Definition inkplate.h:118
InternalGPIOPin * display_data_4_pin_
Definition inkplate.h:235
void set_mirror_x(bool mirror_x)
Definition inkplate.h:94
void set_display_data_1_pin(InternalGPIOPin *data)
Definition inkplate.h:102
void set_sph_pin(GPIOPin *sph)
Definition inkplate.h:117
InternalGPIOPin * le_pin_
Definition inkplate.h:244
void set_full_update_every(uint32_t full_update_every)
Definition inkplate.h:97
void set_ckv_pin(GPIOPin *ckv)
Definition inkplate.h:110
InternalGPIOPin * display_data_5_pin_
Definition inkplate.h:236
InternalGPIOPin * display_data_3_pin_
Definition inkplate.h:234
InternalGPIOPin * display_data_0_pin_
Definition inkplate.h:231
const uint8_t pixelMaskLUT[8]
Definition inkplate.h:29
void set_wakeup_pin(GPIOPin *wakeup)
Definition inkplate.h:120
InternalGPIOPin * display_data_2_pin_
Definition inkplate.h:233
const uint8_t pixelMaskGLUT[2]
Definition inkplate.h:30
void set_display_data_6_pin(InternalGPIOPin *data)
Definition inkplate.h:107
void set_cl_pin(InternalGPIOPin *cl)
Definition inkplate.h:111
InternalGPIOPin * display_data_1_pin_
Definition inkplate.h:232
void set_display_data_5_pin(InternalGPIOPin *data)
Definition inkplate.h:106
void set_greyscale(bool greyscale)
Definition inkplate.h:87
void set_gpio0_enable_pin(GPIOPin *gpio0_enable)
Definition inkplate.h:112
void draw_absolute_pixel_internal(int x, int y, Color color) override
Definition inkplate.cpp:153
display::DisplayType get_display_type() override
Definition inkplate.h:141
const uint8_t LUT2[16]
Definition inkplate.h:22
void set_partial_updating(bool partial_updating)
Definition inkplate.h:96
void set_display_data_0_pin(InternalGPIOPin *data)
Definition inkplate.h:101
void set_display_data_7_pin(InternalGPIOPin *data)
Definition inkplate.h:108
int get_height_internal() override
Definition inkplate.h:180
InternalGPIOPin * display_data_6_pin_
Definition inkplate.h:237
void set_display_data_2_pin(InternalGPIOPin *data)
Definition inkplate.h:103
float get_setup_priority() const override
Definition inkplate.cpp:133
void set_display_data_4_pin(InternalGPIOPin *data)
Definition inkplate.h:105
void set_mirror_y(bool mirror_y)
Definition inkplate.h:93
void set_display_data_3_pin(InternalGPIOPin *data)
Definition inkplate.h:104
InternalGPIOPin * cl_pin_
Definition inkplate.h:241
void clean_fast_(uint8_t c, uint8_t rep)
Definition inkplate.cpp:637
const uint8_t LUTB[16]
Definition inkplate.h:26
void set_le_pin(InternalGPIOPin *le)
Definition inkplate.h:114
void hscan_start_(uint32_t d)
Definition inkplate.cpp:607
int get_width_internal() override
Definition inkplate.h:165
void set_gmod_pin(GPIOPin *gmod)
Definition inkplate.h:113
const uint8_t LUTW[16]
Definition inkplate.h:24
const uint8_t waveform3BitAll[6][8][9]
Definition inkplate.h:32
void set_oe_pin(GPIOPin *oe)
Definition inkplate.h:115
InternalGPIOPin * display_data_7_pin_
Definition inkplate.h:238
void fill(Color color) override
Definition inkplate.cpp:296
void set_vcom_pin(GPIOPin *vcom)
Definition inkplate.h:119
void initialize_()
Allocate buffers.
Definition inkplate.cpp:59
void set_powerup_pin(GPIOPin *powerup)
Definition inkplate.h:116
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6