Moved simu LCD buffer to simu target
This commit is contained in:
committed by
Raphael Coeffic
parent
a642f094e9
commit
ca36c9595e
@@ -85,84 +85,6 @@ void lcdSetContrast()
|
|||||||
lcdSetRefVolt(g_eeGeneral.contrast);
|
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<h; i++) {
|
|
||||||
for (int j=0; j<w; j++) {
|
|
||||||
dest[(y+i)*destw+x+j] = color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h)
|
|
||||||
{
|
|
||||||
#if defined(LCD_VERTICAL_INVERT)
|
|
||||||
x = destw - (x + w);
|
|
||||||
y = desth - (y + h);
|
|
||||||
srcx = srcw - (srcx + w);
|
|
||||||
srcy = srch - (srcy + h);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int i=0; i<h; i++) {
|
|
||||||
memcpy(dest+(y+i)*destw+x, src+(srcy+i)*srcw+srcx, 2*w);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h)
|
|
||||||
{
|
|
||||||
#if defined(LCD_VERTICAL_INVERT)
|
|
||||||
x = destw - (x + w);
|
|
||||||
y = desth - (y + h);
|
|
||||||
srcx = srcw - (srcx + w);
|
|
||||||
srcy = srch - (srcy + h);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (coord_t line=0; line<h; line++) {
|
|
||||||
uint16_t * p = dest + (y+line)*destw + x;
|
|
||||||
const uint16_t * q = src + (srcy+line)*srcw + srcx;
|
|
||||||
for (coord_t col=0; col<w; col++) {
|
|
||||||
uint8_t alpha = *q >> 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()
|
event_t getWindowEvent()
|
||||||
{
|
{
|
||||||
return getEvent(false);
|
return getEvent(false);
|
||||||
|
|||||||
@@ -38,15 +38,6 @@
|
|||||||
#define DISPLAY_PIXELS_COUNT (LCD_W * LCD_H)
|
#define DISPLAY_PIXELS_COUNT (LCD_W * LCD_H)
|
||||||
#define DISPLAY_BUFFER_SIZE (DISPLAY_PIXELS_COUNT)
|
#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;
|
extern coord_t lcdNextPos;
|
||||||
void lcdNextLayer();
|
void lcdNextLayer();
|
||||||
|
|
||||||
@@ -55,12 +46,6 @@ inline void lcdClear()
|
|||||||
lcd->clear();
|
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();
|
void lcdDrawBlackOverlay();
|
||||||
|
|
||||||
#if defined(BOOT)
|
#if defined(BOOT)
|
||||||
|
|||||||
@@ -382,9 +382,6 @@ void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, ui
|
|||||||
y = desth - (y + h);
|
y = desth - (y + h);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (dest == displayBuf && !coordsWithinScreen(x, y, w, h))
|
|
||||||
return;
|
|
||||||
|
|
||||||
DMA2D_DeInit();
|
DMA2D_DeInit();
|
||||||
|
|
||||||
DMA2D_InitTypeDef DMA2D_InitStruct;
|
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);
|
srcy = srch - (srcy + h);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (dest == displayBuf && !coordsWithinScreen(x, y, w, h))
|
|
||||||
return;
|
|
||||||
|
|
||||||
DMA2D_DeInit();
|
DMA2D_DeInit();
|
||||||
|
|
||||||
DMA2D_InitTypeDef DMA2D_InitStruct;
|
DMA2D_InitTypeDef DMA2D_InitStruct;
|
||||||
@@ -459,9 +453,6 @@ void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_
|
|||||||
srcy = srch - (srcy + h);
|
srcy = srch - (srcy + h);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (dest == displayBuf && !coordsWithinScreen(x, y, w, h))
|
|
||||||
return;
|
|
||||||
|
|
||||||
DMA2D_DeInit();
|
DMA2D_DeInit();
|
||||||
|
|
||||||
DMA2D_InitTypeDef DMA2D_InitStruct;
|
DMA2D_InitTypeDef DMA2D_InitStruct;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ set(SIMU_SRC
|
|||||||
simueeprom.cpp
|
simueeprom.cpp
|
||||||
simufatfs.cpp
|
simufatfs.cpp
|
||||||
simudisk.cpp
|
simudisk.cpp
|
||||||
|
simulcd.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if(SIMU_DISKIO)
|
if(SIMU_DISKIO)
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
#define SIMPGMSPC_USE_QT 0
|
#define SIMPGMSPC_USE_QT 0
|
||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
#include "simulcd.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|||||||
@@ -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<h; i++) {
|
||||||
|
for (int j=0; j<w; j++) {
|
||||||
|
dest[(y+i)*destw+x+j] = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h)
|
||||||
|
{
|
||||||
|
#if defined(LCD_VERTICAL_INVERT)
|
||||||
|
x = destw - (x + w);
|
||||||
|
y = desth - (y + h);
|
||||||
|
srcx = srcw - (srcx + w);
|
||||||
|
srcy = srch - (srcy + h);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (int i=0; i<h; i++) {
|
||||||
|
memcpy(dest+(y+i)*destw+x, src+(srcy+i)*srcw+srcx, 2*w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h)
|
||||||
|
{
|
||||||
|
#if defined(LCD_VERTICAL_INVERT)
|
||||||
|
x = destw - (x + w);
|
||||||
|
y = desth - (y + h);
|
||||||
|
srcx = srcw - (srcx + w);
|
||||||
|
srcy = srch - (srcy + h);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (coord_t line=0; line<h; line++) {
|
||||||
|
uint16_t * p = dest + (y+line)*destw + x;
|
||||||
|
const uint16_t * q = src + (srcy+line)*srcw + srcx;
|
||||||
|
for (coord_t col=0; col<w; col++) {
|
||||||
|
uint8_t alpha = *q >> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,5 +26,6 @@
|
|||||||
extern int g_snapshot_idx;
|
extern int g_snapshot_idx;
|
||||||
extern bool simuLcdRefresh;
|
extern bool simuLcdRefresh;
|
||||||
extern pixel_t simuLcdBuf[DISPLAY_BUFFER_SIZE];
|
extern pixel_t simuLcdBuf[DISPLAY_BUFFER_SIZE];
|
||||||
|
extern pixel_t displayBuf[DISPLAY_BUFFER_SIZE];
|
||||||
|
|
||||||
#endif // _SIMULCD_H_
|
#endif // _SIMULCD_H_
|
||||||
|
|||||||
Reference in New Issue
Block a user