Skip to content

Commit

Permalink
Rotate display from top down instead of bottom up.
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz authored and pfeerick committed Oct 23, 2023
1 parent c4d855a commit 5109d1a
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions radio/src/targets/horus/lcd_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,39 +68,36 @@ static void _copy_rotate_180(uint16_t* dst, uint16_t* src, const rect_t& copy_ar
coord_t x1 = LCD_W - copy_area.w - copy_area.x;
coord_t y1 = LCD_H - copy_area.h - copy_area.y;

auto total = copy_area.w * copy_area.h;
uint16_t* px_src = src + total - 2;
src += copy_area.w - 2;
dst += (y1 + copy_area.h - 1) * LCD_W + x1;

dst += y1 * LCD_W + x1;

for (auto line = 0; line < copy_area.h; line++) {

// invert line into _line_buffer first (SRAM)
auto px_dst = _line_buffer;

auto line_end = px_dst + (copy_area.w & ~1);
while (px_dst != line_end) {
uint32_t* px2_src = (uint32_t*)px_src;
uint32_t* px2_dst = (uint32_t*)px_dst;
uint32_t* px2_src = (uint32_t*)src;

uint32_t px = ((*px2_src & 0xFFFF0000) >> 16) | ((*px2_src & 0xFFFF) << 16);
*px2_dst = px;
*((uint32_t*)px_dst) = ((*px2_src & 0xFFFF0000) >> 16) | ((*px2_src & 0xFFFF) << 16);

px_src -= 2;
src -= 2;
px_dst += 2;
}

if (copy_area.w & 1) {
*px_dst = *(px_src+1);
px_src--;
*px_dst = *(src+1);
src--;
}

// ... and DMA back into SDRAM
DMACopyBitmap(dst, copy_area.w, 1, 0, 0,
_line_buffer, copy_area.w, 1, 0, 0,
copy_area.w, 1);

dst += LCD_W;

src += copy_area.w * 2;
dst -= LCD_W;
}
}

Expand Down

0 comments on commit 5109d1a

Please sign in to comment.