Skip to content

Commit

Permalink
#78 Cleanup partial: Still some strange update when it falls in parti…
Browse files Browse the repository at this point in the history
…cular X
  • Loading branch information
martinberlin committed Jan 12, 2023
1 parent b0a728c commit b44ed17
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
31 changes: 16 additions & 15 deletions components/CalEPD/models/small/gdew0102I4FC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,7 @@ void Gdew0102I4FC::_setPartialRamArea(uint16_t x, uint16_t y, uint16_t xe, uint1

void Gdew0102I4FC::updateWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool using_rotation) {
//printf("updateWindow is still not implemented\n");
if (!_using_partial_mode) {
_wakeUpPart();
}
int16_t w1 = x < 0 ? w + x : w;
int16_t h1 = y < 0 ? h + y : h;
int16_t x1 = x < 0 ? 0 : x;
int16_t y1 = y < 0 ? 0 : y;
w1 = x1 + w1 < int16_t(GDEW0102I4FC_WIDTH) ? w1 : int16_t(GDEW0102I4FC_WIDTH) - x1;
h1 = y1 + h1 < int16_t(GDEW0102I4FC_HEIGHT) ? h1 : int16_t(GDEW0102I4FC_HEIGHT) - y1;

if (using_rotation) _rotate(x, y, w, h);
if (x >= GDEW0102I4FC_WIDTH) {
ESP_LOGE(TAG, "Given width exceeds display");
Expand All @@ -243,29 +235,38 @@ void Gdew0102I4FC::updateWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h,
ESP_LOGE(TAG, "Given height exceeds display");
return;
}
if (!_using_partial_mode) {
_wakeUpPart();
}
uint16_t xe = gx_uint16_min(GDEW0102I4FC_WIDTH, x + w) - 1;
uint16_t ye = gx_uint16_min(GDEW0102I4FC_HEIGHT, y + h) - 1;
uint16_t xs_bx = x / 8;
uint16_t xe_bx = (xe + 7) / 8;

w1 += x1 % 8;
uint8_t w1 = w;
w1 += x % 8;
if (w1 % 8 > 0) w1 += 8 - w1 % 8;
x1 -= x1 % 8;
x -= x % 8;

// This command makes the display enter partial mode
IO.cmd(0x91); // partial in
// Here it sets where in RAM is going to write it
_setPartialRamArea(x1, y1, w1, h1);
_setPartialRamArea(x, y, w1, h);

// NO need to fill 0x10 buffer or send it for partial
/* IO.cmd(0x10);
uint8_t full_buff[GDEW0102I4FC_BUFFER_SIZE];
for(uint16_t y = 0; y < GDEW0102I4FC_BUFFER_SIZE; y++) {
full_buff[y] = 0xFF;
}
IO.data(full_buff, GDEW0102I4FC_BUFFER_SIZE); */
// New data
IO.cmd(0x13);
for (int16_t y1 = y; y1 <= ye+1; y1++)
{
for (int16_t x1 = xs_bx; x1 < xe_bx; x1++)
{
uint16_t idx = y1 * (GDEW0102I4FC_WIDTH/ 8) + x1;
uint8_t data = (idx < sizeof(_black_buffer)) ? _black_buffer[idx] : 0x00; // white is 0x00 in buffer
IO.data(data); // white is 0xFF on device
IO.data(_black_buffer[idx]); // white is 0xFF on device
}
}

Expand Down
22 changes: 16 additions & 6 deletions main/demos/small/small-display.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include <stdlib.h> /* srand, rand */
// Should match with your epaper module, size

// New small GOODISPLAY models
Expand All @@ -22,6 +23,10 @@ extern "C"
}
void delay(uint32_t millis) { vTaskDelay(millis / portTICK_PERIOD_MS); }

uint16_t randomNumber(uint16_t max) {
srand(esp_timer_get_time());
return rand()%max;
}

void demo(uint16_t bkcolor, uint16_t fgcolor)
{
Expand Down Expand Up @@ -71,13 +76,18 @@ void app_main(void)
// Test Epd class
display.init(false);
display.setFont(&Ubuntu_M12pt8b);
/* display.fillCircle(display.width()/2,display.height()/2,30,EPD_BLACK);
//display.fillCircle(display.width()/2,display.height()/2,30,EPD_BLACK);
display.update();
delay(1000); */
display.fillScreen(EPD_WHITE);
uint8_t radius = 20;
display.fillCircle(display.width()/2,display.height()/2,radius,EPD_BLACK);
display.updateWindow(display.width()/2-radius,display.height()/2-radius,radius*2,radius*2);

uint8_t radius = 8;

for (auto y = 0; y<40; y+=2) {
int ranx = randomNumber(display.width()-(radius*2))+radius;
int rany = randomNumber(display.height()-(radius*2))+radius;
display.fillCircle(ranx,rany,radius,EPD_BLACK);
display.updateWindow(ranx-radius,rany-radius,radius*2,radius*2);
delay(10);
}
printf("Partial update test\n");
delay(2000);
return; // Just clean display and draw a circle
Expand Down

0 comments on commit b44ed17

Please sign in to comment.