📄 lcdwin.c
字号:
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* 礐/GUI is protected by international copyright laws. Knowledge of the
* source code may not be used to write a similar product. This file may
* only be used in accordance with a license and should not be redistributed
* in any way. We appreciate your understanding and fairness.
*
----------------------------------------------------------------------
File : LCDWin.C
Purpose : Driver for Simulator under Windows
----------------------------------------------------------------------
Version-Date---Author-Explanation
----------------------------------------------------------------------
2.00 010402 RS a) LCD_GetDevCaps removed from driver
(now LCD.c)
1.30c 000529 JE a) Interface changed
1.30b 000428 RS a) DIB class eliminated
b) Internal cleanups, support for high color
1.30a 000417 RS a) Major cleanup in DIB class
1.30 000309 RS a) Interface change for emWIn V1.30
(LCD_L0_SetLUTEntry, LCD_GetDevCap)
1.10a 000121 RS a) RECTHEIGHT, RECTWIDTH modified in order to
fix bug which would at some time prevent
displaying the first line of the display.
1.10.00 000110 RS a) Modifications in order to make it easy to
implement driver in any windows program
1.04.02 991118 RS a) additional assertion added
LCD_MAX_LOG_COLORS
1.04.01 991018 RS a) Support for LCD_FIXEDPALETTE added
with Anitaliasing enabled
1.04.00 991013 JE/RS a) Support for LCD_FIXEDPALETTE added
b) Driver now accepts the same LCDConf.h as
the embedded system
c) Bugfix for ..
1.02.02 990831 RS a) Small optimization added for 16-color bitmaps
1.02.01 990726 RS a) Transparency support for 16-color bitmpas
added
1.02.00 990212 RS a) New interface version 1.02 supported
1.00 990118 RS First release
----------------------------------------------------------------------
Known problems or limitations with current version
----------------------------------------------------------------------
---------------------------END-OF-HEADER------------------------------
*/
#if defined(WIN32) && !defined(LCD_SIMCONTROLLER)
#include <windows.h>
#include "LCD.h"
#include "LCD_Private.h" /* include LCDConf.h */
#include "LCDSim.h"
#include "GUI_Private.h"
#include "memory.h"
#if LCD_BITSPERPIXEL <= 8
#define PIXELINDEX U8
#else
#define PIXELINDEX WORD
#endif
#ifdef WIN32
#ifndef ASSERT
#define ASSERT(Val) \
if (!(Val)) \
MessageBox(NULL,"...in file "__FILE__,"Assertion failed...",MB_OK);
#endif
#endif
#ifdef LCD_ASSERT
#undef LCD_ASSERT
#endif
#define LCD_ASSERT(v) ASSERT(v)
#ifndef LCD_DISPLAY_INDEX
#define LCD_DISPLAY_INDEX 0
#endif
/*
*********************************************************
* *
* Macros for internal use *
* *
*********************************************************
*/
#define SETPIXEL(x, y, c) LCDSIM_SetPixelIndex(x, y, c)
#define GETPIXEL(x, y) LCD_GetPixel(x,y)
#define XORPIXEL(x, y) XorPixel(x,y)
#if LCD_DISPLAY_INDEX == 1 /* Second display in a multi-display configuration */
#define LCDSIM_SetPixelIndex LCDSIM_1_SetPixelIndex
#define LCDSIM_SetLUTEntry LCDSIM_1_SetLUTEntry
#endif
/*
*********************************************************
* *
* ID translation table *
* *
*********************************************************
This table contains 0, 1, 2, ... and serves as translation table for DDBs
*/
#define INTS(Base) Base+0,Base+1,Base+2,Base+3,Base+4,Base+5, \
Base+6,Base+7,Base+8,Base+9,Base+10,Base+11, \
Base+12,Base+13,Base+14,Base+15
static void XorPixel (int x, int y) {
unsigned int Index = LCD_L0_GetPixelIndex(x,y);
LCDSIM_SetPixelIndex(x, y, LCD_NUM_COLORS-1-Index);
}
/*
*********************************************************
* *
* LCD_L0_SetColorIndex *
* LCD_L0_SetBkColorIndex *
* *
*********************************************************
*/
#define COLORINDEX LCD_COLORINDEX
#define BKCOLORINDEX LCD_BKCOLORINDEX
/*
*********************************************************
* *
* LCD_L0_DrawPixel *
* *
*********************************************************
Purpose: This routine is called by emWin. It writes 1 pixel into the
display.
*/
void LCD_L0_DrawPixel(int x, int y) {
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
XORPIXEL(x, y);
} else {
SETPIXEL(x, y, COLORINDEX);
}
}
/*
*********************************************************
* *
* LCD_DrawLine vertical/horizontal *
* LCD_DrawRect *
* *
*********************************************************
*/
void LCD_L0_DrawHLine (int x0, int y, int x1) {
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
for (;x0 <= x1; x0++) {
XORPIXEL(x0, y);
}
} else {
// LCDSIM_FillLine(x0,y,x1,COLORINDEX);
for (;x0 <= x1; x0++) {
SETPIXEL(x0, y, COLORINDEX);
}
}
}
void LCD_L0_DrawVLine (int x, int y0, int y1) {
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
while (y0 <= y1) {
XORPIXEL(x, y0);
y0++;
}
} else {
while (y0 <= y1) {
SETPIXEL(x, y0, COLORINDEX);
y0++;
}
}
}
void LCD_L0_FillRect(int x0, int y0, int x1, int y1) {
for (; y0 <= y1; y0++) {
LCD_L0_DrawHLine(x0,y0, x1);
}
}
/*
***************************************************************
* *
* Internal bitmap routines *
* *
***************************************************************
*/
/*
*********************************************
* *
* Draw Bitmap 1 BPP *
* *
*********************************************
*/
static void DrawBitLine1BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) {
LCD_PIXELINDEX Index0 = *(pTrans+0);
LCD_PIXELINDEX Index1 = *(pTrans+1);
x+=Diff;
/*
// Jump to right entry point
*/
switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS|LCD_DRAWMODE_XOR)) {
case 0: /* Write mode */
do {
LCDSIM_SetPixelIndex(x++,y, (*p & (0x80>>Diff)) ? Index1 : Index0);
if (++Diff==8) {
Diff=0;
p++;
}
} while (--xsize);
break;
case LCD_DRAWMODE_TRANS:
do {
if (*p & (0x80>>Diff))
LCDSIM_SetPixelIndex(x,y, Index1);
x++;
if (++Diff==8) {
Diff=0;
p++;
}
} while (--xsize);
break;
case LCD_DRAWMODE_XOR:;
do {
if (*p & (0x80>>Diff)) {
int Pixel = LCDSIM_GetPixelIndex(x,y);
LCDSIM_SetPixelIndex(x,y, LCD_NUM_COLORS-1-Pixel);
}
x++;
if (++Diff==8) {
Diff=0;
p++;
}
} while (--xsize);
break;
}
}
/*
*********************************************
* *
* Draw Bitmap 2 BPP *
* *
*********************************************
*/
#if (LCD_MAX_LOG_COLORS > 2)
static void DrawBitLine2BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) {
PIXELINDEX pixels;
/*
// Jump to right entry point
*/
pixels = *p;
if (GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) switch (Diff&3) {
case 0:
goto WriteTBit0;
case 1:
goto WriteTBit1;
case 2:
goto WriteTBit2;
default:
goto WriteTBit3;
} else switch (Diff&3) {
case 0:
goto WriteBit0;
case 1:
goto WriteBit1;
case 2:
goto WriteBit2;
default:
goto WriteBit3;
}
/*
Write without transparency
*/
WriteBit0:
SETPIXEL(x+0, y, *(pTrans+(pixels>>6)));
if (!--xsize)
return;
WriteBit1:
SETPIXEL(x+1, y, *(pTrans+(3&(pixels>>4))));
if (!--xsize)
return;
WriteBit2:
SETPIXEL(x+2, y, *(pTrans+(3&(pixels>>2))));
if (!--xsize)
return;
WriteBit3:
SETPIXEL(x+3, y, *(pTrans+(3&(pixels))));
if (!--xsize)
return;
pixels = *(++p);
x+=4;
goto WriteBit0;
/*
Write with transparency
*/
WriteTBit0:
if (pixels&(3<<6))
SETPIXEL(x+0, y, *(pTrans+(pixels>>6)));
if (!--xsize)
return;
WriteTBit1:
if (pixels&(3<<4))
SETPIXEL(x+1, y, *(pTrans+(3&(pixels>>4))));
if (!--xsize)
return;
WriteTBit2:
if (pixels&(3<<2))
SETPIXEL(x+2, y, *(pTrans+(3&(pixels>>2))));
if (!--xsize)
return;
WriteTBit3:
if (pixels&(3<<0))
SETPIXEL(x+3, y, *(pTrans+(3&(pixels))));
if (!--xsize)
return;
pixels = *(++p);
x+=4;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -