mirror of
https://github.com/esphome/esphome.git
synced 2026-10-21 13:34:12 +00:00
[st7305] Fix position of partial updates on landscape panels (#21172)
This commit is contained in:
@@ -116,6 +116,11 @@ ST7305::Window ST7305::compute_window_() const {
|
||||
window.block_start = static_cast<uint16_t>((inv_min >> 2) / 3 * 3);
|
||||
window.block_end =
|
||||
static_cast<uint16_t>(std::min(((inv_max >> 2) / 3) * 3 + 2, static_cast<int>(window.stride) - 1));
|
||||
// The panel mirrors the column address window (MADCTL MX) but still fills it in ascending
|
||||
// order, so the bands are addressed from the far end of the column range.
|
||||
const int last_band = window.stride / 3 - 1;
|
||||
window.caset_start = static_cast<uint8_t>(this->column_start_ + last_band - window.block_end / 3);
|
||||
window.caset_end = static_cast<uint8_t>(this->column_start_ + last_band - window.block_start / 3);
|
||||
} else {
|
||||
// RASET rows are y pairs; CASET columns are 12-pixel bands of x blocks.
|
||||
window.stride = static_cast<uint16_t>(this->width_ / 4);
|
||||
@@ -125,9 +130,9 @@ ST7305::Window ST7305::compute_window_() const {
|
||||
const int block_max = this->x_high_ >> 2;
|
||||
window.block_start = static_cast<uint16_t>(block_min / 3 * 3);
|
||||
window.block_end = static_cast<uint16_t>(std::min((block_max / 3) * 3 + 2, static_cast<int>(window.stride) - 1));
|
||||
window.caset_start = static_cast<uint8_t>(this->column_start_ + window.block_start / 3);
|
||||
window.caset_end = static_cast<uint8_t>(this->column_start_ + window.block_end / 3);
|
||||
}
|
||||
window.caset_start = static_cast<uint8_t>(this->column_start_ + window.block_start / 3);
|
||||
window.caset_end = static_cast<uint8_t>(this->column_start_ + window.block_end / 3);
|
||||
return window;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,10 +108,24 @@ TEST_F(ST7305Test, WindowAlignsToAddressBlocks) {
|
||||
EXPECT_EQ(window.outer_end, 0);
|
||||
EXPECT_EQ(window.block_start, 0);
|
||||
EXPECT_EQ(window.block_end, 2);
|
||||
EXPECT_EQ(window.caset_start, 0x12);
|
||||
EXPECT_EQ(window.caset_end, 0x12);
|
||||
EXPECT_EQ(window.caset_start, 0x2A);
|
||||
EXPECT_EQ(window.caset_end, 0x2A);
|
||||
EXPECT_EQ(window.data_length(), 3u);
|
||||
|
||||
// A window spanning several bands is addressed from the far end of the column range.
|
||||
this->reset_screen_();
|
||||
this->display_.draw_pixel_at(100, 85, Color::WHITE);
|
||||
this->display_.draw_pixel_at(368, 293, Color::WHITE);
|
||||
|
||||
const auto bands = this->display_.compute_window();
|
||||
EXPECT_EQ(bands.outer_start, 50);
|
||||
EXPECT_EQ(bands.outer_end, 184);
|
||||
EXPECT_EQ(bands.block_start, 0);
|
||||
EXPECT_EQ(bands.block_end, 53);
|
||||
EXPECT_EQ(bands.caset_start, 0x19);
|
||||
EXPECT_EQ(bands.caset_end, 0x2A);
|
||||
EXPECT_EQ(bands.data_length(), 135u * 54u);
|
||||
|
||||
this->reset_screen_();
|
||||
this->display_.draw_pixel_at(200, 150, Color::WHITE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user