6#include <hal/gpio_hal.h>
11static const char *
const TAG =
"inkplate";
14 for (uint32_t i = 0; i < 256; i++) {
15 this->
pin_lut_[i] = ((i & 0b00000011) << 4) | (((i & 0b00001100) >> 2) << 18) | (((i & 0b00010000) >> 4) << 23) |
16 (((i & 0b11100000) >> 5) << 25);
72 if (this->
glut_ !=
nullptr)
74 if (this->
glut2_ !=
nullptr)
79 ESP_LOGE(TAG,
"Could not allocate buffer for display!");
84 uint8_t glut_size = 9;
87 if (this->
glut_ ==
nullptr) {
88 ESP_LOGE(TAG,
"Could not allocate glut!");
93 if (this->
glut2_ ==
nullptr) {
94 ESP_LOGE(TAG,
"Could not allocate glut2!");
101 for (
int i = 0; i < glut_size; i++) {
102 for (uint32_t j = 0; j < 256; j++) {
103 uint8_t
z = (waveform3_bit[j & 0x07][i] << 2) | (waveform3_bit[(j >> 4) & 0x07][i]);
104 this->
glut_[i * 256 + j] = ((
z & 0b00000011) << 4) | (((
z & 0b00001100) >> 2) << 18) |
105 (((
z & 0b00010000) >> 4) << 23) | (((
z & 0b11100000) >> 5) << 25);
106 z = ((waveform3_bit[j & 0x07][i] << 2) | (waveform3_bit[(j >> 4) & 0x07][i])) << 4;
107 this->
glut2_[i * 256 + j] = ((
z & 0b00000011) << 4) | (((
z & 0b00001100) >> 2) << 18) |
108 (((
z & 0b00010000) >> 4) << 23) | (((
z & 0b11100000) >> 5) << 25);
115 ESP_LOGE(TAG,
"Could not allocate partial buffer for display!");
121 ESP_LOGE(TAG,
"Could not allocate partial buffer 2 for display!");
130 memset(this->
buffer_, 0, buffer_size);
167 uint8_t current = this->
buffer_[pos];
173 uint8_t gs = ((color.
red * 2126 / 10000) + (color.
green * 7152 / 10000) + (color.
blue * 722 / 10000)) >> 5;
186 LOG_DISPLAY(
"",
"Inkplate",
this);
189 " Partial Updating: %s\n"
190 " Full Update Every: %d",
193 LOG_PIN(
" CKV Pin: ", this->
ckv_pin_);
194 LOG_PIN(
" CL Pin: ", this->
cl_pin_);
197 LOG_PIN(
" LE Pin: ", this->
le_pin_);
198 LOG_PIN(
" OE Pin: ", this->
oe_pin_);
200 LOG_PIN(
" SPH Pin: ", this->
sph_pin_);
201 LOG_PIN(
" SPV Pin: ", this->
spv_pin_);
214 LOG_UPDATE_INTERVAL(
this);
218 ESP_LOGV(TAG,
"Eink off called");
246 ESP_LOGV(TAG,
"Eink on called");
271 uint32_t timer =
millis();
275 if ((
millis() - timer) >= 250) {
276 ESP_LOGW(TAG,
"Power supply not detected");
291 return data == 0b11111010;
297 ESP_LOGV(TAG,
"Fill called");
298 uint32_t start_time =
millis();
301 uint8_t
fill = ((color.
red * 2126 / 10000) + (color.
green * 7152 / 10000) + (color.
blue * 722 / 10000)) >> 5;
304 uint8_t
fill = color.
is_on() ? 0x00 : 0xFF;
308 ESP_LOGV(TAG,
"Fill finished (%ums)",
millis() - start_time);
312 ESP_LOGV(TAG,
"Display called");
313 uint32_t start_time =
millis();
319 ESP_LOGV(TAG,
"Display finished (partial) (%ums)",
millis() - start_time);
324 ESP_LOGV(TAG,
"Display finished (full) (%ums)",
millis() - start_time);
328 ESP_LOGV(TAG,
"Display1b called");
329 uint32_t start_time =
millis();
334 uint8_t buffer_value;
335 const uint8_t *buffer_ptr;
358 ESP_LOGV(TAG,
"Display1b start loops (%ums)",
millis() - start_time);
362 for (
int k = 0; k < rep; k++) {
366 buffer_value = *(buffer_ptr--);
370 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
371 GPIO.out_w1tc = data_mask | clock;
374 buffer_value = *(buffer_ptr--);
376 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
377 GPIO.out_w1tc = data_mask | clock;
379 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
380 GPIO.out_w1tc = data_mask | clock;
384 GPIO.out_w1ts = clock;
385 GPIO.out_w1tc = data_mask | clock;
391 ESP_LOGV(TAG,
"Display1b first loop x %d (%ums)", 4,
millis() - start_time);
396 buffer_value = *(buffer_ptr--);
400 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
401 GPIO.out_w1tc = data_mask | clock;
404 buffer_value = *(buffer_ptr--);
406 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
407 GPIO.out_w1tc = data_mask | clock;
409 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
410 GPIO.out_w1tc = data_mask | clock;
414 GPIO.out_w1ts = clock;
415 GPIO.out_w1tc = data_mask | clock;
420 ESP_LOGV(TAG,
"Display1b second loop (%ums)",
millis() - start_time);
430 GPIO.out_w1ts = send | clock;
431 GPIO.out_w1tc = data_mask | clock;
433 GPIO.out_w1ts = send | clock;
434 GPIO.out_w1tc = data_mask | clock;
435 GPIO.out_w1ts = send | clock;
436 GPIO.out_w1tc = data_mask | clock;
440 GPIO.out_w1ts = clock;
441 GPIO.out_w1tc = data_mask | clock;
446 ESP_LOGV(TAG,
"Display1b third loop (%ums)",
millis() - start_time);
452 ESP_LOGV(TAG,
"Display1b finished (%ums)",
millis() - start_time);
456 ESP_LOGV(TAG,
"Display3b called");
457 uint32_t start_time =
millis();
483 uint8_t glut_size = 9;
484 for (
int k = 0; k < glut_size; k++) {
489 data |= this->
glut_[k * 256 + this->buffer_[--pos]];
491 data = this->
glut2_[k * 256 + this->buffer_[--pos]];
492 data |= this->
glut_[k * 256 + this->buffer_[--pos]];
493 GPIO.out_w1ts = data | clock;
494 GPIO.out_w1tc = data_mask | clock;
497 data = this->
glut2_[k * 256 + this->buffer_[--pos]];
498 data |= this->
glut_[k * 256 + this->buffer_[--pos]];
499 GPIO.out_w1ts = data | clock;
500 GPIO.out_w1tc = data_mask | clock;
501 data = this->
glut2_[k * 256 + this->buffer_[--pos]];
502 data |= this->
glut_[k * 256 + this->buffer_[--pos]];
503 GPIO.out_w1ts = data | clock;
504 GPIO.out_w1tc = data_mask | clock;
508 GPIO.out_w1ts = clock;
509 GPIO.out_w1tc = data_mask | clock;
518 ESP_LOGV(TAG,
"Display3b finished (%ums)",
millis() - start_time);
522 ESP_LOGV(TAG,
"Partial update called");
523 uint32_t start_time =
millis();
533 uint8_t diffw, diffb;
545 ESP_LOGV(TAG,
"Partial update buffer built after (%ums)",
millis() - start_time);
552 for (
int k = 0; k < rep; k++) {
556 data = *(data_ptr--);
559 data = *(data_ptr--);
560 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
561 GPIO.out_w1tc = data_mask | clock;
565 GPIO.out_w1ts = clock;
566 GPIO.out_w1tc = data_mask | clock;
571 ESP_LOGV(TAG,
"Partial update loop k=%d (%ums)", k,
millis() - start_time);
579 ESP_LOGV(TAG,
"Partial update finished (%ums)",
millis() - start_time);
610 GPIO.out_w1ts = d | clock;
624 ESP_LOGV(TAG,
"Clean called");
625 uint32_t start_time =
millis();
634 ESP_LOGV(TAG,
"Clean finished (%ums)",
millis() - start_time);
638 ESP_LOGV(TAG,
"Clean fast called with: (%d, %d)", c, rep);
639 uint32_t start_time =
millis();
653 uint32_t send = ((data & 0b00000011) << 4) | (((data & 0b00001100) >> 2) << 18) | (((data & 0b00010000) >> 4) << 23) |
654 (((data & 0b11100000) >> 5) << 25);
657 for (
int k = 0; k < rep; k++) {
661 GPIO.out_w1ts = send | clock;
662 GPIO.out_w1tc = clock;
664 GPIO.out_w1ts = clock;
665 GPIO.out_w1tc = clock;
666 GPIO.out_w1ts = clock;
667 GPIO.out_w1tc = clock;
671 GPIO.out_w1ts = send | clock;
672 GPIO.out_w1tc = clock;
677 ESP_LOGV(TAG,
"Clean fast rep loop %d finished (%ums)", k,
millis() - start_time);
679 ESP_LOGV(TAG,
"Clean fast finished (%ums)",
millis() - start_time);
virtual void mark_failed()
Mark this component as failed.
virtual void pin_mode(gpio::Flags flags)=0
virtual void digital_write(bool value)=0
virtual uint8_t get_pin() const =0
An STL allocator that uses SPI or internal RAM.
void deallocate(T *p, size_t n)
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len, bool stop=true)
bool write_byte(uint8_t a_register, uint8_t data, bool stop=true)
ErrorCode read_register(uint8_t a_register, uint8_t *data, size_t len, bool stop=true)
reads an array of bytes from a specific register in the I²C device
InternalGPIOPin * display_data_4_pin_
InternalGPIOPin * le_pin_
InternalGPIOPin * display_data_5_pin_
InternalGPIOPin * display_data_3_pin_
size_t get_buffer_length_()
InternalGPIOPin * display_data_0_pin_
const uint8_t pixelMaskLUT[8]
InternalGPIOPin * display_data_2_pin_
uint32_t partial_updates_
const uint8_t pixelMaskGLUT[2]
void dump_config() override
InternalGPIOPin * display_data_1_pin_
uint8_t * partial_buffer_
void draw_absolute_pixel_internal(int x, int y, Color color) override
GPIOPin * gpio0_enable_pin_
int get_height_internal() override
InternalGPIOPin * display_data_6_pin_
float get_setup_priority() const override
InternalGPIOPin * cl_pin_
uint32_t full_update_every_
bool read_power_status_()
void clean_fast_(uint8_t c, uint8_t rep)
void hscan_start_(uint32_t d)
int get_width_internal() override
const uint8_t waveform3BitAll[6][8][9]
InternalGPIOPin * display_data_7_pin_
uint8_t * partial_buffer_2_
void fill(Color color) override
void initialize_()
Allocate buffers.
@ ERROR_OK
No error found during execution of method.
const float PROCESSOR
For components that use data from sensors like displays.
Providing packet encoding functions for exchanging data with a remote host.
void IRAM_ATTR HOT delayMicroseconds(uint32_t us)
void IRAM_ATTR HOT delay(uint32_t ms)
uint32_t IRAM_ATTR HOT millis()
bool is_on() ESPHOME_ALWAYS_INLINE