ESPHome  2022.6.3
inkplate.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/hal.h"
7 
8 #ifdef USE_ESP32_FRAMEWORK_ARDUINO
9 
10 namespace esphome {
11 namespace inkplate6 {
12 
13 enum InkplateModel : uint8_t {
17 };
18 
20  public:
21  const uint8_t LUT2[16] = {0xAA, 0xA9, 0xA6, 0xA5, 0x9A, 0x99, 0x96, 0x95,
22  0x6A, 0x69, 0x66, 0x65, 0x5A, 0x59, 0x56, 0x55};
23  const uint8_t LUTW[16] = {0xFF, 0xFE, 0xFB, 0xFA, 0xEF, 0xEE, 0xEB, 0xEA,
24  0xBF, 0xBE, 0xBB, 0xBA, 0xAF, 0xAE, 0xAB, 0xAA};
25  const uint8_t LUTB[16] = {0xFF, 0xFD, 0xF7, 0xF5, 0xDF, 0xDD, 0xD7, 0xD5,
26  0x7F, 0x7D, 0x77, 0x75, 0x5F, 0x5D, 0x57, 0x55};
27 
28  const uint8_t pixelMaskLUT[8] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
29  const uint8_t pixelMaskGLUT[2] = {0x0F, 0xF0};
30 
31  const uint8_t waveform3Bit[8][8] = {{0, 1, 1, 0, 0, 1, 1, 0}, {0, 1, 2, 1, 1, 2, 1, 0}, {1, 1, 1, 2, 2, 1, 0, 0},
32  {0, 0, 0, 1, 1, 1, 2, 0}, {2, 1, 1, 1, 2, 1, 2, 0}, {2, 2, 1, 1, 2, 1, 2, 0},
33  {1, 1, 1, 2, 1, 2, 2, 0}, {0, 0, 0, 0, 0, 0, 2, 0}};
34  const uint8_t waveform3Bit6Plus[8][9] = {{0, 0, 0, 0, 0, 2, 1, 1, 0}, {0, 0, 2, 1, 1, 1, 2, 1, 0},
35  {0, 2, 2, 2, 1, 1, 2, 1, 0}, {0, 0, 2, 2, 2, 1, 2, 1, 0},
36  {0, 0, 0, 0, 2, 2, 2, 1, 0}, {0, 0, 2, 1, 2, 1, 1, 2, 0},
37  {0, 0, 2, 2, 2, 1, 1, 2, 0}, {0, 0, 0, 0, 2, 2, 2, 2, 0}};
38 
39  void set_greyscale(bool greyscale) {
40  this->greyscale_ = greyscale;
41  this->initialize_();
42  this->block_partial_ = true;
43  }
44  void set_partial_updating(bool partial_updating) { this->partial_updating_ = partial_updating; }
45  void set_full_update_every(uint32_t full_update_every) { this->full_update_every_ = full_update_every; }
46 
47  void set_model(InkplateModel model) { this->model_ = model; }
48 
57 
58  void set_ckv_pin(GPIOPin *ckv) { this->ckv_pin_ = ckv; }
59  void set_cl_pin(InternalGPIOPin *cl) { this->cl_pin_ = cl; }
60  void set_gpio0_enable_pin(GPIOPin *gpio0_enable) { this->gpio0_enable_pin_ = gpio0_enable; }
61  void set_gmod_pin(GPIOPin *gmod) { this->gmod_pin_ = gmod; }
62  void set_le_pin(InternalGPIOPin *le) { this->le_pin_ = le; }
63  void set_oe_pin(GPIOPin *oe) { this->oe_pin_ = oe; }
64  void set_powerup_pin(GPIOPin *powerup) { this->powerup_pin_ = powerup; }
65  void set_sph_pin(GPIOPin *sph) { this->sph_pin_ = sph; }
66  void set_spv_pin(GPIOPin *spv) { this->spv_pin_ = spv; }
67  void set_vcom_pin(GPIOPin *vcom) { this->vcom_pin_ = vcom; }
68  void set_wakeup_pin(GPIOPin *wakeup) { this->wakeup_pin_ = wakeup; }
69 
70  float get_setup_priority() const override;
71 
72  void dump_config() override;
73 
74  void display();
75  void clean();
76  void fill(Color color) override;
77 
78  void update() override;
79 
80  void setup() override;
81 
82  uint8_t get_panel_state() { return this->panel_on_; }
83  bool get_greyscale() { return this->greyscale_; }
84  bool get_partial_updating() { return this->partial_updating_; }
85  uint8_t get_temperature() { return this->temperature_; }
86 
87  void block_partial() { this->block_partial_ = true; }
88 
91  }
92 
93  protected:
94  void draw_absolute_pixel_internal(int x, int y, Color color) override;
95  void display1b_();
96  void display3b_();
97  void initialize_();
98  bool partial_update_();
99  void clean_fast_(uint8_t c, uint8_t rep);
100 
101  void hscan_start_(uint32_t d);
102  void vscan_end_();
103  void vscan_start_();
104 
105  void eink_off_();
106  void eink_on_();
107  bool read_power_status_();
108 
109  void setup_pins_();
110  void pins_z_state_();
111  void pins_as_outputs_();
112 
113  int get_width_internal() override {
114  if (this->model_ == INKPLATE_6) {
115  return 800;
116  } else if (this->model_ == INKPLATE_10) {
117  return 1200;
118  } else if (this->model_ == INKPLATE_6_PLUS) {
119  return 1024;
120  }
121  return 0;
122  }
123 
124  int get_height_internal() override {
125  if (this->model_ == INKPLATE_6) {
126  return 600;
127  } else if (this->model_ == INKPLATE_10) {
128  return 825;
129  } else if (this->model_ == INKPLATE_6_PLUS) {
130  return 758;
131  }
132  return 0;
133  }
134 
135  size_t get_buffer_length_();
136 
138  int data = 0;
139  data |= (1 << this->display_data_0_pin_->get_pin());
140  data |= (1 << this->display_data_1_pin_->get_pin());
141  data |= (1 << this->display_data_2_pin_->get_pin());
142  data |= (1 << this->display_data_3_pin_->get_pin());
143  data |= (1 << this->display_data_4_pin_->get_pin());
144  data |= (1 << this->display_data_5_pin_->get_pin());
145  data |= (1 << this->display_data_6_pin_->get_pin());
146  data |= (1 << this->display_data_7_pin_->get_pin());
147  return data;
148  }
149 
150  bool panel_on_{false};
151  uint8_t temperature_;
152 
153  uint8_t *partial_buffer_{nullptr};
154  uint8_t *partial_buffer_2_{nullptr};
155 
156  uint32_t *glut_{nullptr};
157  uint32_t *glut2_{nullptr};
158  uint32_t pin_lut_[256];
159 
161  uint32_t partial_updates_{0};
162 
163  bool block_partial_{true};
166 
168 
177 
189 };
190 
191 } // namespace inkplate6
192 } // namespace esphome
193 
194 #endif // USE_ESP32_FRAMEWORK_ARDUINO
float get_setup_priority() const override
Definition: inkplate.cpp:130
void set_greyscale(bool greyscale)
Definition: inkplate.h:39
const uint8_t LUTW[16]
Definition: inkplate.h:23
int get_height_internal() override
Definition: inkplate.h:124
void set_cl_pin(InternalGPIOPin *cl)
Definition: inkplate.h:59
InternalGPIOPin * display_data_2_pin_
Definition: inkplate.h:171
const uint8_t waveform3Bit[8][8]
Definition: inkplate.h:31
void set_partial_updating(bool partial_updating)
Definition: inkplate.h:44
void set_le_pin(InternalGPIOPin *le)
Definition: inkplate.h:62
void draw_absolute_pixel_internal(int x, int y, Color color) override
Definition: inkplate.cpp:150
void set_powerup_pin(GPIOPin *powerup)
Definition: inkplate.h:64
void set_gpio0_enable_pin(GPIOPin *gpio0_enable)
Definition: inkplate.h:60
void set_model(InkplateModel model)
Definition: inkplate.h:47
InternalGPIOPin * display_data_1_pin_
Definition: inkplate.h:170
This class simplifies creating components that periodically check a state.
Definition: component.h:266
void set_display_data_4_pin(InternalGPIOPin *data)
Definition: inkplate.h:53
void set_gmod_pin(GPIOPin *gmod)
Definition: inkplate.h:61
void clean_fast_(uint8_t c, uint8_t rep)
Definition: inkplate.cpp:605
virtual uint8_t get_pin() const =0
InternalGPIOPin * display_data_4_pin_
Definition: inkplate.h:173
void set_oe_pin(GPIOPin *oe)
Definition: inkplate.h:63
InternalGPIOPin * cl_pin_
Definition: inkplate.h:179
void set_spv_pin(GPIOPin *spv)
Definition: inkplate.h:66
void set_vcom_pin(GPIOPin *vcom)
Definition: inkplate.h:67
void set_display_data_1_pin(InternalGPIOPin *data)
Definition: inkplate.h:50
InternalGPIOPin * le_pin_
Definition: inkplate.h:182
void set_display_data_2_pin(InternalGPIOPin *data)
Definition: inkplate.h:51
void set_wakeup_pin(GPIOPin *wakeup)
Definition: inkplate.h:68
const uint8_t waveform3Bit6Plus[8][9]
Definition: inkplate.h:34
const uint8_t LUTB[16]
Definition: inkplate.h:25
void set_display_data_3_pin(InternalGPIOPin *data)
Definition: inkplate.h:52
void fill(Color color) override
Definition: inkplate.cpp:285
InternalGPIOPin * display_data_0_pin_
Definition: inkplate.h:169
const uint8_t pixelMaskLUT[8]
Definition: inkplate.h:28
void dump_config() override
Definition: inkplate.cpp:176
display::DisplayType get_display_type() override
Definition: inkplate.h:89
void set_display_data_0_pin(InternalGPIOPin *data)
Definition: inkplate.h:49
int get_width_internal() override
Definition: inkplate.h:113
void set_ckv_pin(GPIOPin *ckv)
Definition: inkplate.h:58
void set_display_data_7_pin(InternalGPIOPin *data)
Definition: inkplate.h:56
void set_display_data_6_pin(InternalGPIOPin *data)
Definition: inkplate.h:55
InternalGPIOPin * display_data_6_pin_
Definition: inkplate.h:175
Definition: a4988.cpp:4
InternalGPIOPin * display_data_7_pin_
Definition: inkplate.h:176
void set_display_data_5_pin(InternalGPIOPin *data)
Definition: inkplate.h:54
const uint8_t pixelMaskGLUT[2]
Definition: inkplate.h:29
InternalGPIOPin * display_data_3_pin_
Definition: inkplate.h:172
void hscan_start_(uint32_t d)
Definition: inkplate.cpp:575
void set_sph_pin(GPIOPin *sph)
Definition: inkplate.h:65
void set_full_update_every(uint32_t full_update_every)
Definition: inkplate.h:45
const uint8_t LUT2[16]
Definition: inkplate.h:21
InternalGPIOPin * display_data_5_pin_
Definition: inkplate.h:174