mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 09:18:00 +01:00
Code cleaned, buffer still has to be optimized
This commit is contained in:
parent
dea4a69cfe
commit
e9a784b3c8
1 changed files with 217 additions and 214 deletions
|
@ -175,14 +175,11 @@ void WaveshareEPaper::fill(Color color) {
|
||||||
this->buffer_[i] = fill;
|
this->buffer_[i] = fill;
|
||||||
}
|
}
|
||||||
void WaveshareEPaper7C::init_internal_(uint32_t buffer_length) {
|
void WaveshareEPaper7C::init_internal_(uint32_t buffer_length) {
|
||||||
ESP_LOGI(TAG, "Buffer n°0 points to: %d", this->buffers_[0]);
|
ESP_LOGI(TAG, "Buffer n°0 points to: %d", this->buffers_[0]);//debug
|
||||||
ESP_LOGI(TAG, "EXEC CUSTOM WaveshareEPaper7C::init_internal_, creating splitted buffer");//debug
|
ESP_LOGI(TAG, "EXEC CUSTOM WaveshareEPaper7C::init_internal_, creating splitted buffer");//debug
|
||||||
for (int i = 0; i < NUM_BUFFERS; i++)
|
for (int i = 0; i < NUM_BUFFERS; i++)
|
||||||
this->buffers_[i] = nullptr;
|
this->buffers_[i] = nullptr;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ESP_LOGI(TAG, "EXEC CUSTOM WaveshareEPaper7C::init_internal_, creating splitted buffer");//debug
|
|
||||||
ESP_LOGI(TAG, "Available ram before allocation: %d", heap_caps_get_free_size(MALLOC_CAP_INTERNAL));//debug
|
ESP_LOGI(TAG, "Available ram before allocation: %d", heap_caps_get_free_size(MALLOC_CAP_INTERNAL));//debug
|
||||||
//Same as DisplayBuffer::init_internal_, but here we split the buffer because of heap fragmentation
|
//Same as DisplayBuffer::init_internal_, but here we split the buffer because of heap fragmentation
|
||||||
|
|
||||||
|
@ -191,15 +188,16 @@ void WaveshareEPaper7C::init_internal_(uint32_t buffer_length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//return;//debug
|
||||||
ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE);
|
ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE);
|
||||||
//ExternalRAMAllocator<uint8_t> allocator;
|
//ExternalRAMAllocator<uint8_t> allocator;//test debug
|
||||||
|
|
||||||
uint32_t small_buffer_length = buffer_length / NUM_BUFFERS;
|
uint32_t small_buffer_length = buffer_length / NUM_BUFFERS;
|
||||||
ESP_LOGI(TAG, "We want %d buffers of size %d", NUM_BUFFERS, small_buffer_length);//debug
|
ESP_LOGI(TAG, "We want %d buffers of size %d", NUM_BUFFERS, small_buffer_length);//debug
|
||||||
|
|
||||||
for (int i = 0; i < NUM_BUFFERS; i++)
|
for (int i = 0; i < NUM_BUFFERS; i++)
|
||||||
this->buffers_[i] = nullptr;
|
this->buffers_[i] = nullptr;
|
||||||
ESP_LOGI(TAG, "Buffer n°0 points to: %d", this->buffers_[0]);
|
ESP_LOGI(TAG, "Buffer n°0 points to: %d", this->buffers_[0]);//debug
|
||||||
|
|
||||||
uint8_t * tmp = nullptr;
|
uint8_t * tmp = nullptr;
|
||||||
for (int i = 0; i < NUM_BUFFERS; i++) {
|
for (int i = 0; i < NUM_BUFFERS; i++) {
|
||||||
|
@ -208,25 +206,23 @@ void WaveshareEPaper7C::init_internal_(uint32_t buffer_length) {
|
||||||
ESP_LOGI(TAG, "Biggest block: %d", heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL));//debug
|
ESP_LOGI(TAG, "Biggest block: %d", heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL));//debug
|
||||||
ESP_LOGI(TAG, "Wanted alloc: %d", small_buffer_length);//debug
|
ESP_LOGI(TAG, "Wanted alloc: %d", small_buffer_length);//debug
|
||||||
|
|
||||||
this->buffers_[i] = allocator.allocate(small_buffer_length);;
|
this->buffers_[i] = allocator.allocate(small_buffer_length);
|
||||||
|
|
||||||
if (this->buffers_[i] == nullptr) {
|
if (this->buffers_[i] == nullptr) {
|
||||||
ESP_LOGE(TAG, "Could not allocate buffer %d for display!", NUM_BUFFERS);
|
ESP_LOGE(TAG, "Could not allocate buffer %d for display!", NUM_BUFFERS);
|
||||||
ESP_LOGI(TAG, "Biggest block was: %d", heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL));//debug
|
ESP_LOGI(TAG, "Biggest block was: %d", heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL));//debug
|
||||||
|
|
||||||
//TODO : desallocate before nullptr
|
//TODO : desallocate before setting to nullptr
|
||||||
ESP_LOGE(TAG, "Deleting all buffers");
|
ESP_LOGE(TAG, "Deleting all buffers");//debug
|
||||||
for (int k = 0; k < NUM_BUFFERS; k++)
|
for (int k = 0; k < NUM_BUFFERS; k++)
|
||||||
this->buffers_[k] = nullptr;
|
this->buffers_[k] = nullptr;
|
||||||
ESP_LOGI(TAG, "Buffer n°0 points to: %d", this->buffers_[0]);
|
ESP_LOGI(TAG, "Buffer n°0 points to: %d", this->buffers_[0]);//debug, should be null
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "Buffer n°%d points to: %d", i, this->buffers_[i]);
|
ESP_LOGI(TAG, "Buffer n°%d points to: %d", i, this->buffers_[i]);//debug
|
||||||
|
|
||||||
ESP_LOGI(TAG, "ok");//debug
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(TAG, "init_internal_ : %d buffers allocated with success", NUM_BUFFERS);
|
ESP_LOGI(TAG, "init_internal_ : %d buffers allocated with success", NUM_BUFFERS);//debug
|
||||||
ESP_LOGI(TAG, "Available ram after allocation: %d", heap_caps_get_free_size(MALLOC_CAP_INTERNAL));//debug
|
ESP_LOGI(TAG, "Available ram after allocation: %d", heap_caps_get_free_size(MALLOC_CAP_INTERNAL));//debug
|
||||||
|
|
||||||
this->clear();
|
this->clear();
|
||||||
|
@ -257,6 +253,7 @@ void WaveshareEPaper7C::fill(Color color) {
|
||||||
ESP_LOGI(TAG, "this->get_width_internal() : %d", this->get_width_internal());
|
ESP_LOGI(TAG, "this->get_width_internal() : %d", this->get_width_internal());
|
||||||
ESP_LOGI(TAG, "this->get_height_internal() : %d", this->get_height_internal());
|
ESP_LOGI(TAG, "this->get_height_internal() : %d", this->get_height_internal());
|
||||||
ESP_LOGI(TAG, "this->get_buffer_length_() : %d", this->get_buffer_length_());
|
ESP_LOGI(TAG, "this->get_buffer_length_() : %d", this->get_buffer_length_());
|
||||||
|
return;//debug
|
||||||
|
|
||||||
uint8_t fill;
|
uint8_t fill;
|
||||||
if (!color.is_on()) {
|
if (!color.is_on()) {
|
||||||
|
@ -268,26 +265,26 @@ void WaveshareEPaper7C::fill(Color color) {
|
||||||
ESP_LOGI(TAG, "Color: (%d,%d,%d) converted to 0x%X", color.red, color.green, color.blue, fill);
|
ESP_LOGI(TAG, "Color: (%d,%d,%d) converted to 0x%X", color.red, color.green, color.blue, fill);
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Check buffers");
|
ESP_LOGI(TAG, "Check buffers");//debug
|
||||||
if (this->buffers_ == nullptr) {
|
if (this->buffers_ == nullptr) {
|
||||||
ESP_LOGE(TAG, "Buffer unavailable!");
|
ESP_LOGE(TAG, "Buffer unavailable!");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
uint32_t small_buffer_length = this->get_buffer_length_() / NUM_BUFFERS;
|
uint32_t small_buffer_length = this->get_buffer_length_() / NUM_BUFFERS;
|
||||||
ESP_LOGI(TAG, "small_buffer_length : %d",small_buffer_length);
|
ESP_LOGI(TAG, "small_buffer_length : %d",small_buffer_length);//debug
|
||||||
for (int buffer_index = 0; buffer_index < NUM_BUFFERS; buffer_index++) {
|
for (int buffer_index = 0; buffer_index < NUM_BUFFERS; buffer_index++) {
|
||||||
ESP_LOGI(TAG, "Buffer n°%d points to: %d", buffer_index, this->buffers_[buffer_index]);
|
ESP_LOGI(TAG, "Buffer n°%d points to: %d", buffer_index, this->buffers_[buffer_index]);//debug
|
||||||
for (uint32_t buffer_pos = 0; buffer_pos < small_buffer_length; buffer_pos++) {
|
for (uint32_t buffer_pos = 0; buffer_pos < small_buffer_length; buffer_pos++) {
|
||||||
this->buffers_[buffer_index][buffer_pos] = fill;
|
this->buffers_[buffer_index][buffer_pos] = fill;
|
||||||
if (buffer_pos<5){
|
if (buffer_pos<5){
|
||||||
ESP_LOGI(TAG, "Buffer n°%d pos %d points to: %d, value is 0x%X", buffer_index, buffer_pos, &(this->buffers_[buffer_index][buffer_pos]), fill);
|
ESP_LOGI(TAG, "Buffer n°%d pos %d points to: %d, value is 0x%X", buffer_index, buffer_pos, &(this->buffers_[buffer_index][buffer_pos]), fill);//debug
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
App.feed_wdt();
|
App.feed_wdt();
|
||||||
ESP_LOGI(TAG, "ok");
|
ESP_LOGI(TAG, "ok");//debug
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "fill done");
|
ESP_LOGI(TAG, "fill done");//debug
|
||||||
}
|
}
|
||||||
void HOT WaveshareEPaper::draw_absolute_pixel_internal(int x, int y, Color color) {
|
void HOT WaveshareEPaper::draw_absolute_pixel_internal(int x, int y, Color color) {
|
||||||
if (x >= this->get_width_internal() || y >= this->get_height_internal() || x < 0 || y < 0)
|
if (x >= this->get_width_internal() || y >= this->get_height_internal() || x < 0 || y < 0)
|
||||||
|
@ -310,7 +307,7 @@ uint32_t WaveshareEPaperBWR::get_buffer_length_() {
|
||||||
return this->get_width_controller() * this->get_height_internal() / 4u;
|
return this->get_width_controller() * this->get_height_internal() / 4u;
|
||||||
} // black and red buffer
|
} // black and red buffer
|
||||||
uint32_t WaveshareEPaper7C::get_buffer_length_() {
|
uint32_t WaveshareEPaper7C::get_buffer_length_() {
|
||||||
return this->get_width_controller() * this->get_height_internal() / 2u;//The goal is to put 2u here instead of 4u
|
return this->get_width_controller() * this->get_height_internal() / 3u;//2u make wifi crash, 3u is ok
|
||||||
} // 7 colors buffer
|
} // 7 colors buffer
|
||||||
|
|
||||||
void WaveshareEPaperBWR::fill(Color color) {
|
void WaveshareEPaperBWR::fill(Color color) {
|
||||||
|
@ -340,6 +337,7 @@ void HOT WaveshareEPaperBWR::draw_absolute_pixel_internal(int x, int y, Color co
|
||||||
}
|
}
|
||||||
void HOT WaveshareEPaper7C::draw_absolute_pixel_internal(int x, int y, Color color) {
|
void HOT WaveshareEPaper7C::draw_absolute_pixel_internal(int x, int y, Color color) {
|
||||||
ESP_LOGI(TAG, "EXEC WaveshareEPaper7C::draw_absolute_pixel_internal");
|
ESP_LOGI(TAG, "EXEC WaveshareEPaper7C::draw_absolute_pixel_internal");
|
||||||
|
return;//debug
|
||||||
if (x >= this->get_width_internal() || y >= this->get_height_internal() || x < 0 || y < 0)
|
if (x >= this->get_width_internal() || y >= this->get_height_internal() || x < 0 || y < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1472,8 +1470,7 @@ void WaveshareEPaper2P9InBV3::dump_config() {
|
||||||
LOG_UPDATE_INTERVAL(this);
|
LOG_UPDATE_INTERVAL(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========================================================
|
// ========================================================// 2.90in v2 rev2
|
||||||
// 2.90in v2 rev2
|
|
||||||
// based on SDK and examples in ZIP file from:
|
// based on SDK and examples in ZIP file from:
|
||||||
// https://www.waveshare.com/pico-epaper-2.9.htm
|
// https://www.waveshare.com/pico-epaper-2.9.htm
|
||||||
// ========================================================
|
// ========================================================
|
||||||
|
@ -2237,196 +2234,6 @@ void WaveshareEPaper5P8InV2::dump_config() {
|
||||||
LOG_PIN(" Busy Pin: ", this->busy_pin_);
|
LOG_PIN(" Busy Pin: ", this->busy_pin_);
|
||||||
LOG_UPDATE_INTERVAL(this);
|
LOG_UPDATE_INTERVAL(this);
|
||||||
}
|
}
|
||||||
void WaveshareEPaper7P3InF::initialize() {
|
|
||||||
this->reset_();
|
|
||||||
delay(20);
|
|
||||||
|
|
||||||
if (this->buffers_ == nullptr) {
|
|
||||||
ESP_LOGE(TAG, "Buffer unavailable!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// COMMAND CMDH
|
|
||||||
this->command(0xAA);
|
|
||||||
this->data(0x49);
|
|
||||||
this->data(0x55);
|
|
||||||
this->data(0x20);
|
|
||||||
this->data(0x08);
|
|
||||||
this->data(0x09);
|
|
||||||
this->data(0x18);
|
|
||||||
|
|
||||||
this->command(0x01);
|
|
||||||
this->data(0x3F);
|
|
||||||
this->data(0x00);
|
|
||||||
this->data(0x32);
|
|
||||||
this->data(0x2A);
|
|
||||||
this->data(0x0E);
|
|
||||||
this->data(0x2A);
|
|
||||||
|
|
||||||
this->command(0x00);
|
|
||||||
this->data(0x5F);
|
|
||||||
this->data(0x69);
|
|
||||||
|
|
||||||
this->command(0x03);
|
|
||||||
this->data(0x00);
|
|
||||||
this->data(0x54);
|
|
||||||
this->data(0x00);
|
|
||||||
this->data(0x44);
|
|
||||||
|
|
||||||
this->command(0x05);
|
|
||||||
this->data(0x40);
|
|
||||||
this->data(0x1F);
|
|
||||||
this->data(0x1F);
|
|
||||||
this->data(0x2C);
|
|
||||||
|
|
||||||
this->command(0x06);
|
|
||||||
this->data(0x6F);
|
|
||||||
this->data(0x1F);
|
|
||||||
this->data(0x1F);
|
|
||||||
this->data(0x22);
|
|
||||||
|
|
||||||
this->command(0x08);
|
|
||||||
this->data(0x6F);
|
|
||||||
this->data(0x1F);
|
|
||||||
this->data(0x1F);
|
|
||||||
this->data(0x22);
|
|
||||||
|
|
||||||
// COMMAND IPC
|
|
||||||
this->command(0x13);
|
|
||||||
this->data(0x00);
|
|
||||||
this->data(0x04);
|
|
||||||
|
|
||||||
this->command(0x30);
|
|
||||||
this->data(0x3C);
|
|
||||||
|
|
||||||
// COMMAND TSE
|
|
||||||
this->command(0x41);
|
|
||||||
this->data(0x00);
|
|
||||||
|
|
||||||
this->command(0x50);
|
|
||||||
this->data(0x3F);
|
|
||||||
|
|
||||||
this->command(0x60);
|
|
||||||
this->data(0x02);
|
|
||||||
this->data(0x00);
|
|
||||||
|
|
||||||
this->command(0x61);
|
|
||||||
this->data(0x03);
|
|
||||||
this->data(0x20);
|
|
||||||
this->data(0x01);
|
|
||||||
this->data(0xE0);
|
|
||||||
|
|
||||||
this->command(0x82);
|
|
||||||
this->data(0x1E);
|
|
||||||
|
|
||||||
this->command(0x84);
|
|
||||||
this->data(0x00);
|
|
||||||
|
|
||||||
// COMMAND AGID
|
|
||||||
this->command(0x86);
|
|
||||||
this->data(0x00);
|
|
||||||
|
|
||||||
this->command(0xE3);
|
|
||||||
this->data(0x2F);
|
|
||||||
|
|
||||||
// COMMAND CCSET
|
|
||||||
this->command(0xE0);
|
|
||||||
this->data(0x00);
|
|
||||||
|
|
||||||
// COMMAND TSSET
|
|
||||||
this->command(0xE6);
|
|
||||||
this->data(0x00);
|
|
||||||
ESP_LOGI(TAG, "Display initialized successfully");//debug
|
|
||||||
}
|
|
||||||
void HOT WaveshareEPaper7P3InF::display() {
|
|
||||||
ESP_LOGI(TAG, "EXEC DISPLAY");//debug
|
|
||||||
if (this->buffers_ == nullptr) {
|
|
||||||
ESP_LOGE(TAG, "Buffer unavailable!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
uint32_t buf_len = this->get_buffer_length_();
|
|
||||||
|
|
||||||
// WAKE UP FROM DEEP SLEEP
|
|
||||||
if (this->deep_sleep_between_updates_) {
|
|
||||||
ESP_LOGI(TAG, "Wake up the display from deep sleep");
|
|
||||||
this->reset_();
|
|
||||||
this->wait_until_idle_();
|
|
||||||
this->initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
// COMMAND DATA START TRANSMISSION
|
|
||||||
ESP_LOGI(TAG, "Sending data to the display");
|
|
||||||
ESP_LOGI(TAG, "buf_len : %d", buf_len);//debug
|
|
||||||
this->command(0x10);
|
|
||||||
delay(2);
|
|
||||||
uint32_t small_buffer_length = this->get_buffer_length_() / NUM_BUFFERS;
|
|
||||||
ESP_LOGI(TAG, "small_buffer_length : %d",small_buffer_length);
|
|
||||||
for (int buffer_index = 0; buffer_index < NUM_BUFFERS; buffer_index++) {
|
|
||||||
ESP_LOGI(TAG, "Buffer n°%d points to: %d", buffer_index, this->buffers_[buffer_index]);
|
|
||||||
for (uint32_t buffer_pos = 0; buffer_pos < small_buffer_length; buffer_pos++) {
|
|
||||||
//this->buffers_[buffer_index][buffer_pos] = 0x22;
|
|
||||||
this->data(this->buffers_[buffer_index][buffer_pos]);
|
|
||||||
if (buffer_pos<5){
|
|
||||||
ESP_LOGI(TAG, "Buffer n°%d pos %d points to: %d, value is 0x%X", buffer_index, buffer_pos, &(this->buffers_[buffer_index][buffer_pos]), this->buffers_[buffer_index][buffer_pos]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
App.feed_wdt();
|
|
||||||
ESP_LOGI(TAG, "ok");
|
|
||||||
}
|
|
||||||
this->wait_until_idle_();
|
|
||||||
|
|
||||||
// COMMAND POWER ON
|
|
||||||
ESP_LOGI(TAG, "Power on the display");
|
|
||||||
this->command(0x04);
|
|
||||||
this->wait_until_idle_();
|
|
||||||
|
|
||||||
// COMMAND REFRESH SCREEN
|
|
||||||
ESP_LOGI(TAG, "Refresh the display");
|
|
||||||
this->command(0x12);
|
|
||||||
this->data(0x00);
|
|
||||||
this->wait_until_idle_();
|
|
||||||
|
|
||||||
// COMMAND POWER OFF
|
|
||||||
ESP_LOGI(TAG, "Power off the display");
|
|
||||||
this->command(0x02);
|
|
||||||
this->data(0x00);
|
|
||||||
this->wait_until_idle_();
|
|
||||||
|
|
||||||
|
|
||||||
if (this->deep_sleep_between_updates_) {
|
|
||||||
ESP_LOGI(TAG, "Set the display to deep sleep");
|
|
||||||
this->command(0x07);
|
|
||||||
this->data(0xA5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int WaveshareEPaper7P3InF::get_width_internal() { return 800; }
|
|
||||||
int WaveshareEPaper7P3InF::get_height_internal() { return 480; }
|
|
||||||
uint32_t WaveshareEPaper7P3InF::idle_timeout_() { return 35000; }
|
|
||||||
void WaveshareEPaper7P3InF::dump_config() {
|
|
||||||
LOG_DISPLAY("", "Waveshare E-Paper", this);
|
|
||||||
ESP_LOGCONFIG(TAG, " Model: 7.3in-F");
|
|
||||||
LOG_PIN(" Reset Pin: ", this->reset_pin_);
|
|
||||||
LOG_PIN(" DC Pin: ", this->dc_pin_);
|
|
||||||
LOG_PIN(" Busy Pin: ", this->busy_pin_);
|
|
||||||
LOG_UPDATE_INTERVAL(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WaveshareEPaper7P3InF::wait_until_idle_() {
|
|
||||||
if (this->busy_pin_ == nullptr) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
const uint32_t start = millis();
|
|
||||||
while (this->busy_pin_->digital_read()) {
|
|
||||||
if (millis() - start > this->idle_timeout_()) {
|
|
||||||
ESP_LOGI(TAG, "Timeout while displaying image!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
App.feed_wdt();
|
|
||||||
delay(10);
|
|
||||||
}
|
|
||||||
delay(200);
|
|
||||||
//ESP_LOGI(TAG, "Was in 7P3::wait_until_idle_() for %d ms", millis() - start);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaveshareEPaper7P5InBV2::initialize() {
|
void WaveshareEPaper7P5InBV2::initialize() {
|
||||||
// COMMAND POWER SETTING
|
// COMMAND POWER SETTING
|
||||||
|
@ -2738,6 +2545,202 @@ void WaveshareEPaper7P5In::dump_config() {
|
||||||
LOG_PIN(" Busy Pin: ", this->busy_pin_);
|
LOG_PIN(" Busy Pin: ", this->busy_pin_);
|
||||||
LOG_UPDATE_INTERVAL(this);
|
LOG_UPDATE_INTERVAL(this);
|
||||||
}
|
}
|
||||||
|
void WaveshareEPaper7P3InF::initialize() {
|
||||||
|
ESP_LOGI(TAG, "initialize");
|
||||||
|
return;//debug
|
||||||
|
this->reset_();
|
||||||
|
delay(20);
|
||||||
|
|
||||||
|
if (this->buffers_ == nullptr) {
|
||||||
|
ESP_LOGE(TAG, "Buffer unavailable!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// COMMAND CMDH
|
||||||
|
this->command(0xAA);
|
||||||
|
this->data(0x49);
|
||||||
|
this->data(0x55);
|
||||||
|
this->data(0x20);
|
||||||
|
this->data(0x08);
|
||||||
|
this->data(0x09);
|
||||||
|
this->data(0x18);
|
||||||
|
|
||||||
|
this->command(0x01);
|
||||||
|
this->data(0x3F);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data(0x32);
|
||||||
|
this->data(0x2A);
|
||||||
|
this->data(0x0E);
|
||||||
|
this->data(0x2A);
|
||||||
|
|
||||||
|
this->command(0x00);
|
||||||
|
this->data(0x5F);
|
||||||
|
this->data(0x69);
|
||||||
|
|
||||||
|
this->command(0x03);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data(0x54);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data(0x44);
|
||||||
|
|
||||||
|
this->command(0x05);
|
||||||
|
this->data(0x40);
|
||||||
|
this->data(0x1F);
|
||||||
|
this->data(0x1F);
|
||||||
|
this->data(0x2C);
|
||||||
|
|
||||||
|
this->command(0x06);
|
||||||
|
this->data(0x6F);
|
||||||
|
this->data(0x1F);
|
||||||
|
this->data(0x1F);
|
||||||
|
this->data(0x22);
|
||||||
|
|
||||||
|
this->command(0x08);
|
||||||
|
this->data(0x6F);
|
||||||
|
this->data(0x1F);
|
||||||
|
this->data(0x1F);
|
||||||
|
this->data(0x22);
|
||||||
|
|
||||||
|
// COMMAND IPC
|
||||||
|
this->command(0x13);
|
||||||
|
this->data(0x00);
|
||||||
|
this->data(0x04);
|
||||||
|
|
||||||
|
this->command(0x30);
|
||||||
|
this->data(0x3C);
|
||||||
|
|
||||||
|
// COMMAND TSE
|
||||||
|
this->command(0x41);
|
||||||
|
this->data(0x00);
|
||||||
|
|
||||||
|
this->command(0x50);
|
||||||
|
this->data(0x3F);
|
||||||
|
|
||||||
|
this->command(0x60);
|
||||||
|
this->data(0x02);
|
||||||
|
this->data(0x00);
|
||||||
|
|
||||||
|
this->command(0x61);
|
||||||
|
this->data(0x03);
|
||||||
|
this->data(0x20);
|
||||||
|
this->data(0x01);
|
||||||
|
this->data(0xE0);
|
||||||
|
|
||||||
|
this->command(0x82);
|
||||||
|
this->data(0x1E);
|
||||||
|
|
||||||
|
this->command(0x84);
|
||||||
|
this->data(0x00);
|
||||||
|
|
||||||
|
// COMMAND AGID
|
||||||
|
this->command(0x86);
|
||||||
|
this->data(0x00);
|
||||||
|
|
||||||
|
this->command(0xE3);
|
||||||
|
this->data(0x2F);
|
||||||
|
|
||||||
|
// COMMAND CCSET
|
||||||
|
this->command(0xE0);
|
||||||
|
this->data(0x00);
|
||||||
|
|
||||||
|
// COMMAND TSSET
|
||||||
|
this->command(0xE6);
|
||||||
|
this->data(0x00);
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "Display initialized successfully");
|
||||||
|
}
|
||||||
|
void HOT WaveshareEPaper7P3InF::display() {
|
||||||
|
ESP_LOGI(TAG, "EXEC DISPLAY");//debug
|
||||||
|
return;
|
||||||
|
if (this->buffers_ == nullptr) {
|
||||||
|
ESP_LOGE(TAG, "Buffer unavailable!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uint32_t buf_len = this->get_buffer_length_();
|
||||||
|
|
||||||
|
// WAKE UP FROM DEEP SLEEP
|
||||||
|
if (this->deep_sleep_between_updates_) {
|
||||||
|
ESP_LOGI(TAG, "Wake up the display from deep sleep");
|
||||||
|
this->reset_();
|
||||||
|
this->wait_until_idle_();
|
||||||
|
this->initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
// COMMAND DATA START TRANSMISSION
|
||||||
|
ESP_LOGI(TAG, "Sending data to the display");
|
||||||
|
ESP_LOGI(TAG, "buf_len : %d", buf_len);//debug
|
||||||
|
this->command(0x10);
|
||||||
|
delay(2);
|
||||||
|
uint32_t small_buffer_length = this->get_buffer_length_() / NUM_BUFFERS;
|
||||||
|
ESP_LOGI(TAG, "small_buffer_length : %d",small_buffer_length);//debug
|
||||||
|
for (int buffer_index = 0; buffer_index < NUM_BUFFERS; buffer_index++) {
|
||||||
|
ESP_LOGI(TAG, "Buffer n°%d points to: %d", buffer_index, this->buffers_[buffer_index]);//debug
|
||||||
|
for (uint32_t buffer_pos = 0; buffer_pos < small_buffer_length; buffer_pos++) {
|
||||||
|
//this->buffers_[buffer_index][buffer_pos] = 0x22;
|
||||||
|
this->data(this->buffers_[buffer_index][buffer_pos]);
|
||||||
|
if (buffer_pos<5){
|
||||||
|
ESP_LOGI(TAG, "Buffer n°%d pos %d points to: %d, value is 0x%X", buffer_index, buffer_pos, &(this->buffers_[buffer_index][buffer_pos]), this->buffers_[buffer_index][buffer_pos]);//debug
|
||||||
|
}
|
||||||
|
}
|
||||||
|
App.feed_wdt();
|
||||||
|
ESP_LOGI(TAG, "ok");//debug
|
||||||
|
}
|
||||||
|
this->wait_until_idle_();
|
||||||
|
|
||||||
|
// COMMAND POWER ON
|
||||||
|
ESP_LOGI(TAG, "Power on the display");
|
||||||
|
this->command(0x04);
|
||||||
|
this->wait_until_idle_();
|
||||||
|
|
||||||
|
// COMMAND REFRESH SCREEN
|
||||||
|
ESP_LOGI(TAG, "Refresh the display");
|
||||||
|
this->command(0x12);
|
||||||
|
this->data(0x00);
|
||||||
|
this->wait_until_idle_();
|
||||||
|
|
||||||
|
// COMMAND POWER OFF
|
||||||
|
ESP_LOGI(TAG, "Power off the display");
|
||||||
|
this->command(0x02);
|
||||||
|
this->data(0x00);
|
||||||
|
this->wait_until_idle_();
|
||||||
|
|
||||||
|
|
||||||
|
if (this->deep_sleep_between_updates_) {
|
||||||
|
ESP_LOGI(TAG, "Set the display to deep sleep");
|
||||||
|
this->command(0x07);
|
||||||
|
this->data(0xA5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int WaveshareEPaper7P3InF::get_width_internal() { return 800; }
|
||||||
|
int WaveshareEPaper7P3InF::get_height_internal() { return 480; }
|
||||||
|
uint32_t WaveshareEPaper7P3InF::idle_timeout_() { return 35000; }
|
||||||
|
void WaveshareEPaper7P3InF::dump_config() {
|
||||||
|
LOG_DISPLAY("", "Waveshare E-Paper", this);
|
||||||
|
ESP_LOGCONFIG(TAG, " Model: 7.3in-F");
|
||||||
|
LOG_PIN(" Reset Pin: ", this->reset_pin_);
|
||||||
|
LOG_PIN(" DC Pin: ", this->dc_pin_);
|
||||||
|
LOG_PIN(" Busy Pin: ", this->busy_pin_);
|
||||||
|
LOG_UPDATE_INTERVAL(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WaveshareEPaper7P3InF::wait_until_idle_() {
|
||||||
|
ESP_LOGI(TAG, "wifi wait_until_idle_");//debug
|
||||||
|
return true;
|
||||||
|
if (this->busy_pin_ == nullptr) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
const uint32_t start = millis();
|
||||||
|
while (this->busy_pin_->digital_read()) {
|
||||||
|
if (millis() - start > this->idle_timeout_()) {
|
||||||
|
ESP_LOGI(TAG, "Timeout while displaying image!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
App.feed_wdt();
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
|
delay(200);
|
||||||
|
//ESP_LOGI(TAG, "Was in 7P3::wait_until_idle_() for %d ms", millis() - start);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
bool WaveshareEPaper7P5InV2::wait_until_idle_() {
|
bool WaveshareEPaper7P5InV2::wait_until_idle_() {
|
||||||
if (this->busy_pin_ == nullptr) {
|
if (this->busy_pin_ == nullptr) {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue