diff --git a/radio/src/gui/colorlcd/lcd.cpp b/radio/src/gui/colorlcd/lcd.cpp index f70683f5b..ac918486d 100644 --- a/radio/src/gui/colorlcd/lcd.cpp +++ b/radio/src/gui/colorlcd/lcd.cpp @@ -85,84 +85,6 @@ void lcdSetContrast() lcdSetRefVolt(g_eeGeneral.contrast); } -#if defined(SIMU) -BitmapBuffer _lcd(BMP_RGB565, LCD_W, LCD_H, displayBuf); -BitmapBuffer * lcd = &_lcd; - -void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color) -{ -#if defined(LCD_VERTICAL_INVERT) - x = destw - (x + w); - y = desth - (y + h); -#endif - - for (int i=0; i> 12; - uint8_t red = ((((*q >> 8) & 0x0f) << 1) * alpha + (*p >> 11) * (0x0f-alpha)) / 0x0f; - uint8_t green = ((((*q >> 4) & 0x0f) << 2) * alpha + ((*p >> 5) & 0x3f) * (0x0f-alpha)) / 0x0f; - uint8_t blue = ((((*q >> 0) & 0x0f) << 1) * alpha + ((*p >> 0) & 0x1f) * (0x0f-alpha)) / 0x0f; - *p = (red << 11) + (green << 5) + (blue << 0); - p++; q++; - } - } -} - -void DMABitmapConvert(uint16_t * dest, const uint8_t * src, uint16_t w, uint16_t h, uint32_t format) -{ - if (format == DMA2D_ARGB4444) { - for (int row = 0; row < h; ++row) { - for (int col = 0; col < w; ++col) { - *dest = ARGB(src[0], src[1], src[2], src[3]); - ++dest; - src += 4; - } - } - } - else { - for (int row = 0; row < h; ++row) { - for(int col = 0; col < w; ++col) { - *dest = RGB(src[1], src[2], src[3]); - ++dest; - src += 4; - } - } - } -} -#endif - event_t getWindowEvent() { return getEvent(false); diff --git a/radio/src/gui/colorlcd/lcd.h b/radio/src/gui/colorlcd/lcd.h index cd0b2f97d..8595cdbba 100644 --- a/radio/src/gui/colorlcd/lcd.h +++ b/radio/src/gui/colorlcd/lcd.h @@ -38,15 +38,6 @@ #define DISPLAY_PIXELS_COUNT (LCD_W * LCD_H) #define DISPLAY_BUFFER_SIZE (DISPLAY_PIXELS_COUNT) -#if defined(SIMU) -extern pixel_t displayBuf[DISPLAY_BUFFER_SIZE]; -#else -#define displayBuf lcd->getData() -#endif - -#define DISPLAY_END (displayBuf + DISPLAY_BUFFER_SIZE) -#define ASSERT_IN_DISPLAY(p) assert((p) >= displayBuf && (p) < DISPLAY_END) - extern coord_t lcdNextPos; void lcdNextLayer(); @@ -55,12 +46,6 @@ inline void lcdClear() lcd->clear(); } -#if defined(LCD_VERTICAL_INVERT) - #define PIXEL_PTR(x, y) &displayBuf[(LCD_H*LCD_W-1) - (y)*LCD_W - (x)] -#else - #define PIXEL_PTR(x, y) &displayBuf[(y)*LCD_W + (x)] -#endif - void lcdDrawBlackOverlay(); #if defined(BOOT) diff --git a/radio/src/targets/horus/lcd_driver.cpp b/radio/src/targets/horus/lcd_driver.cpp index a9a91185a..d7f3d779b 100644 --- a/radio/src/targets/horus/lcd_driver.cpp +++ b/radio/src/targets/horus/lcd_driver.cpp @@ -382,9 +382,6 @@ void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, ui y = desth - (y + h); #endif - if (dest == displayBuf && !coordsWithinScreen(x, y, w, h)) - return; - DMA2D_DeInit(); DMA2D_InitTypeDef DMA2D_InitStruct; @@ -416,9 +413,6 @@ void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, srcy = srch - (srcy + h); #endif - if (dest == displayBuf && !coordsWithinScreen(x, y, w, h)) - return; - DMA2D_DeInit(); DMA2D_InitTypeDef DMA2D_InitStruct; @@ -459,9 +453,6 @@ void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_ srcy = srch - (srcy + h); #endif - if (dest == displayBuf && !coordsWithinScreen(x, y, w, h)) - return; - DMA2D_DeInit(); DMA2D_InitTypeDef DMA2D_InitStruct; diff --git a/radio/src/targets/simu/CMakeLists.txt b/radio/src/targets/simu/CMakeLists.txt index beb25cbc6..8703d8b77 100644 --- a/radio/src/targets/simu/CMakeLists.txt +++ b/radio/src/targets/simu/CMakeLists.txt @@ -15,6 +15,7 @@ set(SIMU_SRC simueeprom.cpp simufatfs.cpp simudisk.cpp + simulcd.cpp ) if(SIMU_DISKIO) diff --git a/radio/src/targets/simu/simpgmspace.cpp b/radio/src/targets/simu/simpgmspace.cpp index b19c745a0..2a809f110 100644 --- a/radio/src/targets/simu/simpgmspace.cpp +++ b/radio/src/targets/simu/simpgmspace.cpp @@ -21,6 +21,8 @@ #define SIMPGMSPC_USE_QT 0 #include "opentx.h" +#include "simulcd.h" + #include #include #include diff --git a/radio/src/targets/simu/simulcd.cpp b/radio/src/targets/simu/simulcd.cpp new file mode 100644 index 000000000..f18c842b9 --- /dev/null +++ b/radio/src/targets/simu/simulcd.cpp @@ -0,0 +1,108 @@ +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "lcd.h" +#include "simulcd.h" + +// #if defined(SIMU) +// extern pixel_t displayBuf[DISPLAY_BUFFER_SIZE]; +// #else +// #define displayBuf lcd->getData() +// #endif + +// #define DISPLAY_END (displayBuf + DISPLAY_BUFFER_SIZE) +// #define ASSERT_IN_DISPLAY(p) assert((p) >= displayBuf && (p) < DISPLAY_END) + + +BitmapBuffer _lcd(BMP_RGB565, LCD_W, LCD_H, displayBuf); +BitmapBuffer * lcd = &_lcd; + +void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color) +{ +#if defined(LCD_VERTICAL_INVERT) + x = destw - (x + w); + y = desth - (y + h); +#endif + + for (int i=0; i> 12; + uint8_t red = ((((*q >> 8) & 0x0f) << 1) * alpha + (*p >> 11) * (0x0f-alpha)) / 0x0f; + uint8_t green = ((((*q >> 4) & 0x0f) << 2) * alpha + ((*p >> 5) & 0x3f) * (0x0f-alpha)) / 0x0f; + uint8_t blue = ((((*q >> 0) & 0x0f) << 1) * alpha + ((*p >> 0) & 0x1f) * (0x0f-alpha)) / 0x0f; + *p = (red << 11) + (green << 5) + (blue << 0); + p++; q++; + } + } +} + +void DMABitmapConvert(uint16_t * dest, const uint8_t * src, uint16_t w, uint16_t h, uint32_t format) +{ + if (format == DMA2D_ARGB4444) { + for (int row = 0; row < h; ++row) { + for (int col = 0; col < w; ++col) { + *dest = ARGB(src[0], src[1], src[2], src[3]); + ++dest; + src += 4; + } + } + } + else { + for (int row = 0; row < h; ++row) { + for(int col = 0; col < w; ++col) { + *dest = RGB(src[1], src[2], src[3]); + ++dest; + src += 4; + } + } + } +} diff --git a/radio/src/targets/simu/simulcd.h b/radio/src/targets/simu/simulcd.h index f9ed5c5c8..1add99b4d 100644 --- a/radio/src/targets/simu/simulcd.h +++ b/radio/src/targets/simu/simulcd.h @@ -26,5 +26,6 @@ extern int g_snapshot_idx; extern bool simuLcdRefresh; extern pixel_t simuLcdBuf[DISPLAY_BUFFER_SIZE]; +extern pixel_t displayBuf[DISPLAY_BUFFER_SIZE]; #endif // _SIMULCD_H_