6#include <hal/gpio_hal.h>
11static const char *
const TAG =
"inkplate";
15 this->
pin_lut_[i] = ((i & 0b00000011) << 4) | (((i & 0b00001100) >> 2) << 18) | (((i & 0b00010000) >> 4) << 23) |
16 (((i & 0b11100000) >> 5) << 25);
78 if (this->
glut_ !=
nullptr) {
80 this->
glut_ =
nullptr;
82 if (this->
glut2_ !=
nullptr) {
89 ESP_LOGE(TAG,
"Could not allocate buffer for display!");
95 if (this->
glut_ ==
nullptr) {
96 ESP_LOGE(TAG,
"Could not allocate glut!");
101 if (this->
glut2_ ==
nullptr) {
102 ESP_LOGE(TAG,
"Could not allocate glut2!");
107 for (uint8_t i = 0; i < GLUT_SIZE; i++) {
108 for (
uint32_t j = 0; j < 256; j++) {
110 this->
glut_[i * 256 + j] = ((
z & 0b00000011) << 4) | (((
z & 0b00001100) >> 2) << 18) |
111 (((
z & 0b00010000) >> 4) << 23) | (((
z & 0b11100000) >> 5) << 25);
113 this->
glut2_[i * 256 + j] = ((
z & 0b00000011) << 4) | (((
z & 0b00001100) >> 2) << 18) |
114 (((
z & 0b00010000) >> 4) << 23) | (((
z & 0b11100000) >> 5) << 25);
121 ESP_LOGE(TAG,
"Could not allocate partial buffer for display!");
127 ESP_LOGE(TAG,
"Could not allocate partial buffer 2 for display!");
136 memset(this->
buffer_, 0, buffer_size);
179 uint8_t gs = ((color.
red * 2126 / 10000) + (color.
green * 7152 / 10000) + (color.
blue * 722 / 10000)) >> 5;
180 this->
buffer_[
pos] = (PIXEL_MASK_GLUT[x_sub] & current) | (x_sub ? gs : gs << 4);
192 LOG_DISPLAY(
"",
"Inkplate",
this);
195 " Partial Updating: %s\n"
196 " Full Update Every: %d",
199 LOG_PIN(
" CKV Pin: ", this->
ckv_pin_);
200 LOG_PIN(
" CL Pin: ", this->
cl_pin_);
203 LOG_PIN(
" LE Pin: ", this->
le_pin_);
204 LOG_PIN(
" OE Pin: ", this->
oe_pin_);
206 LOG_PIN(
" SPH Pin: ", this->
sph_pin_);
207 LOG_PIN(
" SPV Pin: ", this->
spv_pin_);
220 LOG_UPDATE_INTERVAL(
this);
224 ESP_LOGV(TAG,
"Eink off called");
252 ESP_LOGV(TAG,
"Eink on called");
281 if ((
millis() - timer) >= 250) {
282 ESP_LOGW(TAG,
"Power supply not detected");
297 return data == 0b11111010;
303 ESP_LOGV(TAG,
"Fill called");
308 Display::fill(color);
309 ESP_LOGV(TAG,
"Fill finished (%ums)",
millis() - start_time);
314 uint8_t
fill = ((color.
red * 2126 / 10000) + (color.
green * 7152 / 10000) + (color.
blue * 722 / 10000)) >> 5;
317 uint8_t
fill = color.
is_on() ? 0x00 : 0xFF;
321 ESP_LOGV(TAG,
"Fill finished (%ums)",
millis() - start_time);
325 ESP_LOGV(TAG,
"Display called");
332 ESP_LOGV(TAG,
"Display finished (partial) (%ums)",
millis() - start_time);
337 ESP_LOGV(TAG,
"Display finished (full) (%ums)",
millis() - start_time);
341 ESP_LOGV(TAG,
"Display1b called");
347 uint8_t buffer_value;
348 const uint8_t *buffer_ptr;
412 ESP_LOGV(TAG,
"Display1b start loops (%ums)",
millis() - start_time);
414 for (uint8_t k = 0; k < rep; k++) {
418 buffer_value = *(buffer_ptr--);
419 data = this->
model_ ==
INKPLATE_6_PLUS ? LUTW[(~buffer_value >> 4) & 0x0F] : LUTB[(buffer_value >> 4) & 0x0F];
422 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
423 GPIO.out_w1tc = data_mask | clock;
426 buffer_value = *(buffer_ptr--);
427 data = this->
model_ ==
INKPLATE_6_PLUS ? LUTW[(~buffer_value >> 4) & 0x0F] : LUTB[(buffer_value >> 4) & 0x0F];
428 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
429 GPIO.out_w1tc = data_mask | clock;
431 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
432 GPIO.out_w1tc = data_mask | clock;
436 GPIO.out_w1ts = clock;
437 GPIO.out_w1tc = data_mask | clock;
443 ESP_LOGV(TAG,
"Display1b first loop x %d (%ums)", 4,
millis() - start_time);
448 buffer_value = *(buffer_ptr--);
449 data = this->
model_ ==
INKPLATE_6_PLUS ? LUTB[(buffer_value >> 4) & 0x0F] : LUT2[(buffer_value >> 4) & 0x0F];
452 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
453 GPIO.out_w1tc = data_mask | clock;
456 buffer_value = *(buffer_ptr--);
457 data = this->
model_ ==
INKPLATE_6_PLUS ? LUTB[(buffer_value >> 4) & 0x0F] : LUT2[(buffer_value >> 4) & 0x0F];
458 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
459 GPIO.out_w1tc = data_mask | clock;
461 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
462 GPIO.out_w1tc = data_mask | clock;
466 GPIO.out_w1ts = clock;
467 GPIO.out_w1tc = data_mask | clock;
472 ESP_LOGV(TAG,
"Display1b second loop (%ums)",
millis() - start_time);
482 GPIO.out_w1ts = send | clock;
483 GPIO.out_w1tc = data_mask | clock;
485 GPIO.out_w1ts = send | clock;
486 GPIO.out_w1tc = data_mask | clock;
487 GPIO.out_w1ts = send | clock;
488 GPIO.out_w1tc = data_mask | clock;
492 GPIO.out_w1ts = clock;
493 GPIO.out_w1tc = data_mask | clock;
498 ESP_LOGV(TAG,
"Display1b third loop (%ums)",
millis() - start_time);
504 ESP_LOGV(TAG,
"Display1b finished (%ums)",
millis() - start_time);
508 ESP_LOGV(TAG,
"Display3b called");
582 uint8_t glut_size = 9;
583 for (
int k = 0; k < glut_size; k++) {
588 data |= this->
glut_[k * 256 + this->buffer_[--
pos]];
590 data = this->
glut2_[k * 256 + this->buffer_[--
pos]];
591 data |= this->
glut_[k * 256 + this->buffer_[--
pos]];
592 GPIO.out_w1ts = data | clock;
593 GPIO.out_w1tc = data_mask | clock;
596 data = this->
glut2_[k * 256 + this->buffer_[--
pos]];
597 data |= this->
glut_[k * 256 + this->buffer_[--
pos]];
598 GPIO.out_w1ts = data | clock;
599 GPIO.out_w1tc = data_mask | clock;
600 data = this->
glut2_[k * 256 + this->buffer_[--
pos]];
601 data |= this->
glut_[k * 256 + this->buffer_[--
pos]];
602 GPIO.out_w1ts = data | clock;
603 GPIO.out_w1tc = data_mask | clock;
607 GPIO.out_w1ts = clock;
608 GPIO.out_w1tc = data_mask | clock;
617 ESP_LOGV(TAG,
"Display3b finished (%ums)",
millis() - start_time);
621 ESP_LOGV(TAG,
"Partial update called");
632 uint8_t diffw, diffb;
644 ESP_LOGV(TAG,
"Partial update buffer built after (%ums)",
millis() - start_time);
651 for (
int k = 0; k < rep; k++) {
655 data = *(data_ptr--);
658 data = *(data_ptr--);
659 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
660 GPIO.out_w1tc = data_mask | clock;
664 GPIO.out_w1ts = clock;
665 GPIO.out_w1tc = data_mask | clock;
670 ESP_LOGV(TAG,
"Partial update loop k=%d (%ums)", k,
millis() - start_time);
678 ESP_LOGV(TAG,
"Partial update finished (%ums)",
millis() - start_time);
709 GPIO.out_w1ts = d | clock;
723 ESP_LOGV(TAG,
"Clean called");
733 ESP_LOGV(TAG,
"Clean finished (%ums)",
millis() - start_time);
737 ESP_LOGV(TAG,
"Clean fast called with: (%d, %d)", c, rep);
752 uint32_t send = ((data & 0b00000011) << 4) | (((data & 0b00001100) >> 2) << 18) | (((data & 0b00010000) >> 4) << 23) |
753 (((data & 0b11100000) >> 5) << 25);
756 for (
int k = 0; k < rep; k++) {
760 GPIO.out_w1ts = send | clock;
761 GPIO.out_w1tc = clock;
763 GPIO.out_w1ts = clock;
764 GPIO.out_w1tc = clock;
765 GPIO.out_w1ts = clock;
766 GPIO.out_w1tc = clock;
770 GPIO.out_w1ts = send | clock;
771 GPIO.out_w1tc = clock;
776 ESP_LOGV(TAG,
"Clean fast rep loop %d finished (%ums)", k,
millis() - start_time);
778 ESP_LOGV(TAG,
"Clean fast finished (%ums)",
millis() - start_time);
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)
Rect get_clipping() const
Get the current the clipping rectangle.
bool write_byte(uint8_t a_register, uint8_t data) const
ErrorCode read_register(uint8_t a_register, uint8_t *data, size_t len)
reads an array of bytes from a specific register in the I²C device
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len) const
size_t get_buffer_length_()
InternalGPIOPin * cl_pin_
void fill(Color color) override
InternalGPIOPin * display_data_0_pin_
uint32_t partial_updates_
void clean_fast_(uint8_t c, uint8_t rep)
void hscan_start_(uint32_t d)
InternalGPIOPin * display_data_7_pin_
InternalGPIOPin * le_pin_
InternalGPIOPin * display_data_4_pin_
GPIOPin * gpio0_enable_pin_
InternalGPIOPin * display_data_1_pin_
void draw_absolute_pixel_internal(int x, int y, Color color) override
uint32_t full_update_every_
uint8_t waveform_[GLUT_COUNT][GLUT_SIZE]
void dump_config() override
int get_width_internal() override
InternalGPIOPin * display_data_6_pin_
bool read_power_status_()
InternalGPIOPin * display_data_3_pin_
InternalGPIOPin * display_data_5_pin_
InternalGPIOPin * display_data_2_pin_
int get_height_internal() override
float get_setup_priority() const override
uint8_t * partial_buffer_2_
void initialize_()
Allocate buffers.
uint8_t * partial_buffer_
@ ERROR_OK
No error found during execution of method.
constexpr 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 HOT delay(uint32_t ms)
uint32_t IRAM_ATTR HOT millis()
bool is_on() ESPHOME_ALWAYS_INLINE