From eb4e4af0d224d9366d645d78305bde0e6d943675 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Mon, 26 Apr 2021 17:05:58 +0200 Subject: [PATCH] Fixed display inversion issues. --- radio/src/targets/horus/hal.h | 4 ++-- radio/src/targets/simu/simpgmspace.cpp | 8 ++++++++ radio/src/targets/simu/simulcd.cpp | 7 +++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/radio/src/targets/horus/hal.h b/radio/src/targets/horus/hal.h index 1f8c2f772..ddc9ad6ff 100644 --- a/radio/src/targets/horus/hal.h +++ b/radio/src/targets/horus/hal.h @@ -532,10 +532,10 @@ #define LCD_GPIO_NRST GPIOI #define LCD_GPIO_PIN_NRST GPIO_Pin_10 // PI.10 #endif -#if defined(PCBX10) && !defined(RADIO_T18) && !defined(SIMU) +#if defined(PCBX10) && !defined(RADIO_T18) #define LCD_VERTICAL_INVERT #endif -#if defined(PCBX10) && !defined(SIMU) +#if defined(PCBX10) #define LCD_VERTICAL_INVERT #endif #define LTDC_IRQ_PRIO 4 diff --git a/radio/src/targets/simu/simpgmspace.cpp b/radio/src/targets/simu/simpgmspace.cpp index 2a809f110..2b96aa06d 100644 --- a/radio/src/targets/simu/simpgmspace.cpp +++ b/radio/src/targets/simu/simpgmspace.cpp @@ -448,7 +448,15 @@ void lcdRefresh() static bool lightEnabled = (bool)isBacklightEnabled(); if (bool(isBacklightEnabled()) != lightEnabled || memcmp(simuLcdBuf, displayBuf, DISPLAY_BUFFER_SIZE * sizeof(pixel_t))) { +#if defined(LCD_VERTICAL_INVERT) + auto src = (pixel_t*)displayBuf + DISPLAY_BUFFER_SIZE - 1; + auto dst = simuLcdBuf; + auto end = dst + DISPLAY_BUFFER_SIZE; + + while (dst != end) { *(dst++) = *(src--); } +#else memcpy(simuLcdBuf, displayBuf, DISPLAY_BUFFER_SIZE * sizeof(pixel_t)); +#endif lightEnabled = (bool)isBacklightEnabled(); simuLcdRefresh = true; } diff --git a/radio/src/targets/simu/simulcd.cpp b/radio/src/targets/simu/simulcd.cpp index 35a44a316..c92ace74d 100644 --- a/radio/src/targets/simu/simulcd.cpp +++ b/radio/src/targets/simu/simulcd.cpp @@ -91,6 +91,13 @@ void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_ // 'dest' has RGB565 void DMACopyAlphaMask(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint8_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h, uint16_t fg_color) { +#if defined(LCD_VERTICAL_INVERT) + x = destw - (x + w); + y = desth - (y + h); + srcx = srcw - (srcx + w); + srcy = srch - (srcy + h); +#endif + RGB_SPLIT(fg_color, red, green, blue); for (coord_t line=0; line