From 140e63d98479453f123a01404a0bffdfc968eded Mon Sep 17 00:00:00 2001 From: martinberlin Date: Sun, 14 Feb 2021 16:44:46 +0100 Subject: [PATCH] #31 Make cleaning buffer 7x faster --- components/CalEPD/models/gdeh0154d67.cpp | 25 +++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/components/CalEPD/models/gdeh0154d67.cpp b/components/CalEPD/models/gdeh0154d67.cpp index 45e4c46..915988e 100644 --- a/components/CalEPD/models/gdeh0154d67.cpp +++ b/components/CalEPD/models/gdeh0154d67.cpp @@ -77,8 +77,6 @@ void Gdeh0154d67::_setPartialRamArea(uint16_t x, uint16_t y, uint16_t w, uint16_ } void Gdeh0154d67::_wakeUp(){ - printf("wakeup() start commands\n"); - IO.cmd(0x12); _waitBusy("epd_wakeup_power:ON", power_on_time); IO.cmd(0x01); // Driver output control @@ -225,6 +223,7 @@ void Gdeh0154d67::updateWindow(int16_t x, int16_t y, int16_t w, int16_t h, bool IO.data(~data); } } + uint64_t endTime = esp_timer_get_time(); // Update partial @@ -234,17 +233,29 @@ void Gdeh0154d67::updateWindow(int16_t x, int16_t y, int16_t w, int16_t h, bool _waitBusy("partial_update", 100); uint64_t updateTime = esp_timer_get_time(); - printf("\n\nSTATS (ms)\n%llu _wakeUp settings+send Buffer\n%llu update \n%llu total time in millis\n", - (endTime - startTime) / 1000, (updateTime - endTime) / 1000, (updateTime - startTime) / 1000); - + // Clean buffer: 0x01 is essential _setRamDataEntryMode(0x01); + + // v2 SPI optimizing. Check: https://github.com/martinberlin/cale-idf/wiki/About-SPI-optimization IO.cmd(0x24); - for (int16_t x1 = xs_d8; x1 <= GDEH0154D67_BUFFER_SIZE; x1++) + + uint8_t xLineBytes = GDEH0154D67_WIDTH / 8; + uint8_t x1buf[xLineBytes]; + for (uint16_t y = 1; y <= GDEH0154D67_HEIGHT; y++) { - IO.data(0xFF); + for (uint16_t x = 1; x <= xLineBytes; x++) + { + x1buf[x - 1] = 0xFF; + } + IO.data(x1buf, sizeof(x1buf)); } + uint64_t cleanTime = esp_timer_get_time(); + printf("\n\nSTATS (ms)\n%llu _wakeUp settings+send Buffer\n%llu update \nclean_buffer:%llu\n%llu total time in millis\n", + (endTime - startTime) / 1000, (updateTime - endTime) / 1000, (cleanTime - updateTime) / 1000, (cleanTime - startTime) / 1000); + + } void Gdeh0154d67::_waitBusy(const char* message, uint16_t busy_time){