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!");
85 if (this->
glut_ ==
nullptr) {
86 ESP_LOGE(TAG,
"Could not allocate glut!");
91 if (this->
glut2_ ==
nullptr) {
92 ESP_LOGE(TAG,
"Could not allocate glut2!");
97 for (uint8_t i = 0; i < GLUT_SIZE; i++) {
98 for (uint32_t j = 0; j < 256; j++) {
100 this->
glut_[i * 256 + j] = ((
z & 0b00000011) << 4) | (((
z & 0b00001100) >> 2) << 18) |
101 (((
z & 0b00010000) >> 4) << 23) | (((
z & 0b11100000) >> 5) << 25);
103 this->
glut2_[i * 256 + j] = ((
z & 0b00000011) << 4) | (((
z & 0b00001100) >> 2) << 18) |
104 (((
z & 0b00010000) >> 4) << 23) | (((
z & 0b11100000) >> 5) << 25);
111 ESP_LOGE(TAG,
"Could not allocate partial buffer for display!");
117 ESP_LOGE(TAG,
"Could not allocate partial buffer 2 for display!");
126 memset(this->
buffer_, 0, buffer_size);
163 uint8_t current = this->
buffer_[pos];
169 uint8_t gs = ((color.
red * 2126 / 10000) + (color.
green * 7152 / 10000) + (color.
blue * 722 / 10000)) >> 5;
170 this->
buffer_[pos] = (PIXEL_MASK_GLUT[x_sub] & current) | (x_sub ? gs : gs << 4);
177 this->
partial_buffer_[pos] = (~PIXEL_MASK_LUT[x_sub] & current) | (color.
is_on() ? 0 : PIXEL_MASK_LUT[x_sub]);
182 LOG_DISPLAY(
"",
"Inkplate",
this);
185 " Partial Updating: %s\n"
186 " Full Update Every: %d",
189 LOG_PIN(
" CKV Pin: ", this->
ckv_pin_);
190 LOG_PIN(
" CL Pin: ", this->
cl_pin_);
193 LOG_PIN(
" LE Pin: ", this->
le_pin_);
194 LOG_PIN(
" OE Pin: ", this->
oe_pin_);
196 LOG_PIN(
" SPH Pin: ", this->
sph_pin_);
197 LOG_PIN(
" SPV Pin: ", this->
spv_pin_);
210 LOG_UPDATE_INTERVAL(
this);
214 ESP_LOGV(TAG,
"Eink off called");
242 ESP_LOGV(TAG,
"Eink on called");
267 uint32_t timer =
millis();
271 if ((
millis() - timer) >= 250) {
272 ESP_LOGW(TAG,
"Power supply not detected");
287 return data == 0b11111010;
293 ESP_LOGV(TAG,
"Fill called");
294 uint32_t start_time =
millis();
298 Display::fill(color);
299 ESP_LOGV(TAG,
"Fill finished (%ums)",
millis() - start_time);
304 uint8_t
fill = ((color.
red * 2126 / 10000) + (color.
green * 7152 / 10000) + (color.
blue * 722 / 10000)) >> 5;
307 uint8_t
fill = color.
is_on() ? 0x00 : 0xFF;
311 ESP_LOGV(TAG,
"Fill finished (%ums)",
millis() - start_time);
315 ESP_LOGV(TAG,
"Display called");
316 uint32_t start_time =
millis();
322 ESP_LOGV(TAG,
"Display finished (partial) (%ums)",
millis() - start_time);
327 ESP_LOGV(TAG,
"Display finished (full) (%ums)",
millis() - start_time);
331 ESP_LOGV(TAG,
"Display1b called");
332 uint32_t start_time =
millis();
337 uint8_t buffer_value;
338 const uint8_t *buffer_ptr;
402 ESP_LOGV(TAG,
"Display1b start loops (%ums)",
millis() - start_time);
404 for (uint8_t k = 0; k < rep; k++) {
408 buffer_value = *(buffer_ptr--);
413 GPIO.out_w1tc = data_mask | clock;
416 buffer_value = *(buffer_ptr--);
419 GPIO.out_w1tc = data_mask | clock;
422 GPIO.out_w1tc = data_mask | clock;
426 GPIO.out_w1ts = clock;
427 GPIO.out_w1tc = data_mask | clock;
433 ESP_LOGV(TAG,
"Display1b first loop x %d (%ums)", 4,
millis() - start_time);
438 buffer_value = *(buffer_ptr--);
443 GPIO.out_w1tc = data_mask | clock;
446 buffer_value = *(buffer_ptr--);
449 GPIO.out_w1tc = data_mask | clock;
452 GPIO.out_w1tc = data_mask | clock;
456 GPIO.out_w1ts = clock;
457 GPIO.out_w1tc = data_mask | clock;
462 ESP_LOGV(TAG,
"Display1b second loop (%ums)",
millis() - start_time);
472 GPIO.out_w1ts = send | clock;
473 GPIO.out_w1tc = data_mask | clock;
475 GPIO.out_w1ts = send | clock;
476 GPIO.out_w1tc = data_mask | clock;
477 GPIO.out_w1ts = send | clock;
478 GPIO.out_w1tc = data_mask | clock;
482 GPIO.out_w1ts = clock;
483 GPIO.out_w1tc = data_mask | clock;
488 ESP_LOGV(TAG,
"Display1b third loop (%ums)",
millis() - start_time);
494 ESP_LOGV(TAG,
"Display1b finished (%ums)",
millis() - start_time);
498 ESP_LOGV(TAG,
"Display3b called");
499 uint32_t start_time =
millis();
572 uint8_t glut_size = 9;
573 for (
int k = 0; k < glut_size; k++) {
578 data |= this->
glut_[k * 256 + this->buffer_[--pos]];
580 data = this->
glut2_[k * 256 + this->buffer_[--pos]];
581 data |= this->
glut_[k * 256 + this->buffer_[--pos]];
582 GPIO.out_w1ts =
data | clock;
583 GPIO.out_w1tc = data_mask | clock;
586 data = this->
glut2_[k * 256 + this->buffer_[--pos]];
587 data |= this->
glut_[k * 256 + this->buffer_[--pos]];
588 GPIO.out_w1ts =
data | clock;
589 GPIO.out_w1tc = data_mask | clock;
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;
597 GPIO.out_w1ts = clock;
598 GPIO.out_w1tc = data_mask | clock;
607 ESP_LOGV(TAG,
"Display3b finished (%ums)",
millis() - start_time);
611 ESP_LOGV(TAG,
"Partial update called");
612 uint32_t start_time =
millis();
622 uint8_t diffw, diffb;
634 ESP_LOGV(TAG,
"Partial update buffer built after (%ums)",
millis() - start_time);
641 for (
int k = 0; k < rep; k++) {
645 data = *(data_ptr--);
648 data = *(data_ptr--);
650 GPIO.out_w1tc = data_mask | clock;
654 GPIO.out_w1ts = clock;
655 GPIO.out_w1tc = data_mask | clock;
660 ESP_LOGV(TAG,
"Partial update loop k=%d (%ums)", k,
millis() - start_time);
668 ESP_LOGV(TAG,
"Partial update finished (%ums)",
millis() - start_time);
699 GPIO.out_w1ts = d | clock;
713 ESP_LOGV(TAG,
"Clean called");
714 uint32_t start_time =
millis();
723 ESP_LOGV(TAG,
"Clean finished (%ums)",
millis() - start_time);
727 ESP_LOGV(TAG,
"Clean fast called with: (%d, %d)", c, rep);
728 uint32_t start_time =
millis();
742 uint32_t send = ((
data & 0b00000011) << 4) | (((
data & 0b00001100) >> 2) << 18) | (((
data & 0b00010000) >> 4) << 23) |
743 (((
data & 0b11100000) >> 5) << 25);
746 for (
int k = 0; k < rep; k++) {
750 GPIO.out_w1ts = send | clock;
751 GPIO.out_w1tc = clock;
753 GPIO.out_w1ts = clock;
754 GPIO.out_w1tc = clock;
755 GPIO.out_w1ts = clock;
756 GPIO.out_w1tc = clock;
760 GPIO.out_w1ts = send | clock;
761 GPIO.out_w1tc = clock;
766 ESP_LOGV(TAG,
"Clean fast rep loop %d finished (%ums)", k,
millis() - start_time);
768 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)
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.
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