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