Fixed partial refresh problem, but refresh may blackout un touched pixels

This commit is contained in:
GW_MC
2026-01-27 11:50:12 +08:00
parent 5f491dff6e
commit dc2a76e131
2 changed files with 63 additions and 28 deletions

View File

@@ -183,22 +183,43 @@ esp_err_t EInkDisplayHandler::partial_refresh(const uint8_t* partial_framebuffer
ESP_LOGE(TAG, "Partial refresh area x1 and x2 must be byte-aligned (x1 %% 8 == 0 and x2 %% 8 == 7)");
return ESP_ERR_INVALID_ARG;
}
// no rounding needed, area is expected to be aligned
// ------DD
// DDDDD000
// ------DD
// DDDDD111
// ------DD
// DDDDDDDD
// ------DD
// DDDDDDDD
// -------D
// area should be multiple of 8 in x direction
const int32_t x_bank_start = area.x1 >> 3;
const int32_t x_bank_end = area.x2 >> 3;
std::vector<uint8_t> window_data = {
// x start
static_cast<uint8_t>((area.x1 >> 8) & 0xFF), // x start high byte
static_cast<uint8_t>(area.x1 & 0x07), // x start low byte
// x end
static_cast<uint8_t>((area.x2 >> 8) & 0xFF),
static_cast<uint8_t>(area.x2 & 0x07),
// y start
static_cast<uint8_t>((area.y1 >> 8) & 0xFF),
// x start, [9:8] bit -> 6 and 7 bits of x_bank_start
static_cast<uint8_t>((x_bank_start >> 5) & 0x03),
// x start, [7:3] bit + 3 bits of 0 -> 5 bits of x_bank_start and pad 3 LSBs as 0
static_cast<uint8_t>((x_bank_start & 0x1F) << 3),
// x end, [9:8] bit
static_cast<uint8_t>((x_bank_end >> 5) & 0x03),
// x end, [7:3] bit + 3 bits of 1
static_cast<uint8_t>(((x_bank_end & 0x1F) << 3) | 0x07),
// y start, [9:8] bit
static_cast<uint8_t>((area.y1 >> 8) & 0x03),
// y start, [7:0] bit
static_cast<uint8_t>(area.y1 & 0xFF),
// y end
static_cast<uint8_t>((area.y2 >> 8) & 0xFF),
// y end, [9:8] bit
static_cast<uint8_t>((area.y2 >> 8) & 0x03),
// y end, [7:0] bit
static_cast<uint8_t>(area.y2 & 0xFF),
0x01 // Gates scan both inside and outside of the partial window
};
ESP_LOGI(TAG, "Setting partial window: x1=%d, y1=%d, x2=%d, y2=%d",
area.x1, area.y1, area.x2, area.y2);
ESP_LOGI(TAG, "Partial window data: %02X %02X %02X %02X %02X %02X %02X %02X",
window_data[0], window_data[1], window_data[2], window_data[3], window_data[4],
window_data[5], window_data[6], window_data[7]);
err = epd_write_cmd_with_data(0x90, window_data, transaction_guard.transaction_id()); // Set partial window
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to send set partial window command: %s", esp_err_to_name(err));