6 #ifdef USE_ESP32_FRAMEWORK_ARDUINO 8 #include <esp32-hal-gpio.h> 13 static const char *
const TAG =
"inkplate";
16 for (uint32_t i = 0; i < 256; i++) {
17 this->
pin_lut_[i] = ((i & 0b00000011) << 4) | (((i & 0b00001100) >> 2) << 18) | (((i & 0b00010000) >> 4) << 23) |
18 (((i & 0b11100000) >> 5) << 25);
71 if (this->
glut_ !=
nullptr)
73 if (this->
glut2_ !=
nullptr)
78 ESP_LOGE(TAG,
"Could not allocate buffer for display!");
86 if (this->
glut_ ==
nullptr) {
87 ESP_LOGE(TAG,
"Could not allocate glut!");
92 if (this->
glut2_ ==
nullptr) {
93 ESP_LOGE(TAG,
"Could not allocate glut2!");
98 for (
int i = 0; i < glut_size; i++) {
99 for (uint32_t j = 0; j < 256; j++) {
101 this->
glut_[i * 256 + j] = ((z & 0b00000011) << 4) | (((z & 0b00001100) >> 2) << 18) |
102 (((z & 0b00010000) >> 4) << 23) | (((z & 0b11100000) >> 5) << 25);
104 this->
glut2_[i * 256 + j] = ((z & 0b00000011) << 4) | (((z & 0b00001100) >> 2) << 18) |
105 (((z & 0b00010000) >> 4) << 23) | (((z & 0b11100000) >> 5) << 25);
112 ESP_LOGE(TAG,
"Could not allocate partial buffer for display!");
118 ESP_LOGE(TAG,
"Could not allocate partial buffer 2 for display!");
127 memset(this->
buffer_, 0, buffer_size);
158 uint8_t current = this->
buffer_[pos];
164 uint8_t gs = ((color.
red * 2126 / 10000) + (color.
green * 7152 / 10000) + (color.
blue * 722 / 10000)) >> 5;
177 LOG_DISPLAY(
"",
"Inkplate",
this);
178 ESP_LOGCONFIG(TAG,
" Greyscale: %s", YESNO(this->
greyscale_));
182 LOG_PIN(
" CKV Pin: ", this->
ckv_pin_);
183 LOG_PIN(
" CL Pin: ", this->
cl_pin_);
186 LOG_PIN(
" LE Pin: ", this->
le_pin_);
187 LOG_PIN(
" OE Pin: ", this->
oe_pin_);
189 LOG_PIN(
" SPH Pin: ", this->
sph_pin_);
190 LOG_PIN(
" SPV Pin: ", this->
spv_pin_);
203 LOG_UPDATE_INTERVAL(
this);
207 ESP_LOGV(TAG,
"Eink off called");
235 ESP_LOGV(TAG,
"Eink on called");
260 uint32_t timer =
millis();
264 if ((
millis() - timer) >= 250) {
265 ESP_LOGW(TAG,
"Power supply not detected");
280 return data == 0b11111010;
286 ESP_LOGV(TAG,
"Fill called");
287 uint32_t start_time =
millis();
290 uint8_t
fill = ((color.
red * 2126 / 10000) + (color.
green * 7152 / 10000) + (color.
blue * 722 / 10000)) >> 5;
293 uint8_t
fill = color.
is_on() ? 0x00 : 0xFF;
297 ESP_LOGV(TAG,
"Fill finished (%ums)",
millis() - start_time);
301 ESP_LOGV(TAG,
"Display called");
302 uint32_t start_time =
millis();
308 ESP_LOGV(TAG,
"Display finished (partial) (%ums)",
millis() - start_time);
313 ESP_LOGV(TAG,
"Display finished (full) (%ums)",
millis() - start_time);
317 ESP_LOGV(TAG,
"Display1b called");
318 uint32_t start_time =
millis();
323 uint8_t buffer_value;
324 const uint8_t *buffer_ptr;
346 ESP_LOGV(TAG,
"Display1b start loops (%ums)",
millis() - start_time);
348 for (
int k = 0; k < 4; k++) {
352 buffer_value = *(buffer_ptr--);
356 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
357 GPIO.out_w1tc = data_mask | clock;
360 buffer_value = *(buffer_ptr--);
362 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
363 GPIO.out_w1tc = data_mask | clock;
365 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
366 GPIO.out_w1tc = data_mask | clock;
368 GPIO.out_w1ts = clock;
369 GPIO.out_w1tc = data_mask | clock;
374 ESP_LOGV(TAG,
"Display1b first loop x %d (%ums)", 4,
millis() - start_time);
379 buffer_value = *(buffer_ptr--);
383 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
384 GPIO.out_w1tc = data_mask | clock;
387 buffer_value = *(buffer_ptr--);
389 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
390 GPIO.out_w1tc = data_mask | clock;
392 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
393 GPIO.out_w1tc = data_mask | clock;
395 GPIO.out_w1ts = clock;
396 GPIO.out_w1tc = data_mask | clock;
400 ESP_LOGV(TAG,
"Display1b second loop (%ums)",
millis() - start_time);
410 GPIO.out_w1ts = send | clock;
411 GPIO.out_w1tc = data_mask | clock;
413 GPIO.out_w1ts = send | clock;
414 GPIO.out_w1tc = data_mask | clock;
415 GPIO.out_w1ts = send | clock;
416 GPIO.out_w1tc = data_mask | clock;
418 GPIO.out_w1ts = send | clock;
419 GPIO.out_w1tc = data_mask | clock;
423 ESP_LOGV(TAG,
"Display1b third loop (%ums)",
millis() - start_time);
429 ESP_LOGV(TAG,
"Display1b finished (%ums)",
millis() - start_time);
433 ESP_LOGV(TAG,
"Display3b called");
434 uint32_t start_time =
millis();
460 for (
int k = 0; k < glut_size; k++) {
465 data |= this->
glut_[k * 256 + this->buffer_[--pos]];
467 data = this->
glut2_[k * 256 + this->buffer_[--pos]];
468 data |= this->
glut_[k * 256 + this->buffer_[--pos]];
469 GPIO.out_w1ts = data | clock;
470 GPIO.out_w1tc = data_mask | clock;
473 data = this->
glut2_[k * 256 + this->buffer_[--pos]];
474 data |= this->
glut_[k * 256 + this->buffer_[--pos]];
475 GPIO.out_w1ts = data | clock;
476 GPIO.out_w1tc = data_mask | clock;
477 data = this->
glut2_[k * 256 + this->buffer_[--pos]];
478 data |= this->
glut_[k * 256 + this->buffer_[--pos]];
479 GPIO.out_w1ts = data | clock;
480 GPIO.out_w1tc = data_mask | clock;
482 GPIO.out_w1ts = clock;
483 GPIO.out_w1tc = data_mask | clock;
491 ESP_LOGV(TAG,
"Display3b finished (%ums)",
millis() - start_time);
495 ESP_LOGV(TAG,
"Partial update called");
496 uint32_t start_time =
millis();
506 uint8_t diffw, diffb;
518 ESP_LOGV(TAG,
"Partial update buffer built after (%ums)",
millis() - start_time);
523 for (
int k = 0; k < 5; k++) {
527 data = *(data_ptr--);
530 data = *(data_ptr--);
531 GPIO.out_w1ts = this->
pin_lut_[data] | clock;
532 GPIO.out_w1tc = data_mask | clock;
534 GPIO.out_w1ts = clock;
535 GPIO.out_w1tc = data_mask | clock;
539 ESP_LOGV(TAG,
"Partial update loop k=%d (%ums)", k,
millis() - start_time);
547 ESP_LOGV(TAG,
"Partial update finished (%ums)",
millis() - start_time);
578 GPIO.out_w1ts = d | clock;
592 ESP_LOGV(TAG,
"Clean called");
593 uint32_t start_time =
millis();
602 ESP_LOGV(TAG,
"Clean finished (%ums)",
millis() - start_time);
606 ESP_LOGV(TAG,
"Clean fast called with: (%d, %d)", c, rep);
607 uint32_t start_time =
millis();
621 uint32_t send = ((data & 0b00000011) << 4) | (((data & 0b00001100) >> 2) << 18) | (((data & 0b00010000) >> 4) << 23) |
622 (((data & 0b11100000) >> 5) << 25);
625 for (
int k = 0; k < rep; k++) {
629 GPIO.out_w1ts = send | clock;
630 GPIO.out_w1tc = clock;
632 GPIO.out_w1ts = clock;
633 GPIO.out_w1tc = clock;
634 GPIO.out_w1ts = clock;
635 GPIO.out_w1tc = clock;
637 GPIO.out_w1ts = send | clock;
638 GPIO.out_w1tc = clock;
642 ESP_LOGV(TAG,
"Clean fast rep loop %d finished (%ums)", k,
millis() - start_time);
644 ESP_LOGV(TAG,
"Clean fast finished (%ums)",
millis() - start_time);
690 #endif // USE_ESP32_FRAMEWORK_ARDUINO virtual void digital_write(bool value)=0
float get_setup_priority() const override
int get_height_internal() override
GPIOPin * gpio0_enable_pin_
ErrorCode read_register(uint8_t a_register, uint8_t *data, size_t len, bool stop=true)
InternalGPIOPin * display_data_2_pin_
const uint8_t waveform3Bit[8][8]
void draw_absolute_pixel_internal(int x, int y, Color color) override
An STL allocator that uses SPI RAM.
virtual void pin_mode(gpio::Flags flags)=0
bool read_power_status_()
void deallocate(T *p, size_t n)
InternalGPIOPin * display_data_1_pin_
uint32_t full_update_every_
uint32_t IRAM_ATTR HOT millis()
void clean_fast_(uint8_t c, uint8_t rep)
virtual uint8_t get_pin() const =0
InternalGPIOPin * display_data_4_pin_
InternalGPIOPin * cl_pin_
InternalGPIOPin * le_pin_
const float PROCESSOR
For components that use data from sensors like displays.
void fill(Color color) override
InternalGPIOPin * display_data_0_pin_
const uint8_t pixelMaskLUT[8]
void dump_config() override
uint8_t * partial_buffer_2_
int get_width_internal() override
bool write_byte(uint8_t a_register, uint8_t data, bool stop=true)
virtual void mark_failed()
Mark this component as failed.
InternalGPIOPin * display_data_6_pin_
uint8_t * partial_buffer_
size_t get_buffer_length_()
InternalGPIOPin * display_data_7_pin_
void IRAM_ATTR HOT delayMicroseconds(uint32_t us)
const uint8_t pixelMaskGLUT[2]
bool is_on() ALWAYS_INLINE
InternalGPIOPin * display_data_3_pin_
void hscan_start_(uint32_t d)
void IRAM_ATTR HOT delay(uint32_t ms)
InternalGPIOPin * display_data_5_pin_
uint32_t partial_updates_
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len, bool stop=true)