📄 lcdmem.c
字号:
/*DMF50172或MF50081Bit7654321*/
/*
*************************************************************************************************
Init & display control group
*************************************************************************************************
LCD_L0_Init() Initialize the display.
LCD_L0_ReInit() Reinitialize LCD without erasing the contents.
LCD_L0_Off() Switch LCD off.
LCD_L0_On() Switch LCD on.
*************************************************************************************************
Drawing group
*************************************************************************************************
LCD_L0_DrawBitmap() Universal draw bitmap routine.
LCD_L0_DrawHLine() Draw a horizontal line.
LCD_L0_DrawPixel() Draw a pixel in the current foreground color.
LCD_L0_DrawVLine() Draw a vertical line.
LCD_L0_FillRect() Fill a rectangular area.
LCD_L0_SetPixelIndex() Draw a pixel in a specified color.
LCD_L0_XorPixel() Invert a pixel.
*************************************************************************************************
"Get" group
*************************************************************************************************
LCD_L0_GetPixelIndex() Returs the index of the color of a specific pixel.
*************************************************************************************************
"Set" group
*************************************************************************************************
LCD_L0_SetOrg() Not yet used, reserved for future use (must exist in driver).
*************************************************************************************************
Lookup table group
*************************************************************************************************
LCD_L0_SetLUTEntry() Modifiy a single entry of LUT.
*************************************************************************************************
Misc. group (optional)
*************************************************************************************************
LCD_L0_ControlCache() Lock/unlock/flush LCD cache.
LCD_GetXSize() Return physical X-size of LCD in pixels.
LCD_GetYSize() Return physical Y-size of LCD in pixels.
LCD_GetVXSize() Return virtual X-size of LCD in pixels.
LCD_GetVYSize() Return virtual Y-size of LCD in pixels.
LCD_GetBitsPerPixel() Return the number of bits per pixel.
LCD_GetNumColors() Return the number of available colors.
LCD_GetFixedPalette() Return the fixed palette mode.
*************************************************************************************************
#include <string.h> /* for memset */
#include <stddef.h> /* needed for definition of NULL */
#include "LCD_Private.H" /* private modul definitions & config */
#include "GUI_Private.H"
#include "GUIDebug.h"
#include "LCD_0.h" /* Defines for first display */
#include "../../ucos_ii/includes.h"
INT32U aLcdActiveBuffer[LCD_YSIZE][LCD_XSIZE/4];
INT32U aLcdVirtualBuffer[LCD_YSIZE][LCD_XSIZE/4];
#define SCR_XSIZE (320)
#define SCR_YSIZE (240)
#define M5D(n) ((n) & 0x1fffff)
#define ARRAY_SIZE_COLOR (SCR_XSIZE/1*SCR_YSIZE)
#define HOZVAL (LCD_XSIZE/4-1)
#define HOZVAL_COLOR (LCD_XSIZE*3/8-1)
#define LINEVAL (LCD_YSIZE-1)
#define MVAL (13)
#define CLKVAL_COLOR (6) //60Mhz
#define MVAL_USED 0
#define LCD_BUF_SIZE (SCR_XSIZE * SCR_YSIZE)
//extern INT32U aLcdActiveBuffer[LCD_YSIZE][LCD_XSIZE/4];
//extern INT32U aLcdVirtualBuffer[LCD_YSIZE][LCD_XSIZE/4];
//#define LCD_ACTIVE_BUFFER 0xc200000
//#define LCD_VIRTUAL_BUFFER (LCD_ACTIVE_BUFFER + 2 * LCD_BUF_SIZE)
#define LCD_L0_DrawPixel(x, y, c)\
aLcdActiveBuffer[(y)][(x)/4]=(( aLcdActiveBuffer[(y)][(x)/4] & (~(0xff000000>>((x)%4)*8)) )\
| ( (c)<<((4-1-((x)%4))*8) ));
#define GUISWAP(a, b) {a^=b; b^=a; a^=b;}
#ifndef LCD_OPTIMIZE
#define LCD_OPTIMIZE (1)
#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 const LCD_PIXELINDEX aID[] = {
INTS(0),
#if LCD_MAX_LOG_COLORS > 0x10
INTS(0x10),
#endif
#if LCD_MAX_LOG_COLORS > 0x20
INTS(0x20),
INTS(0x30),
#endif
#if LCD_MAX_LOG_COLORS > 0x40
INTS(0x40),
INTS(0x50),
INTS(0x60),
INTS(0x70),
#endif
#if LCD_MAX_LOG_COLORS > 0x80
INTS(0x80),
INTS(0x90),
INTS(0xa0),
INTS(0xb0),
INTS(0xc0),
INTS(0xd0),
INTS(0xe0),
INTS(0xf0)
#endif
};
static int CurPosX;
static U8* pCurPos;
#define LCD_BYTESPERLINE (3*(((LCD_VXSIZE_PHYS)+7)/8))
#define XY2OFF(x,y) (y*LCD_BYTESPERLINE+3*(x>>3))
#define OFF2PTR(Off) &aLcdActiveBuffer[0][Off]
static void SetPosXY(int x, int y) {
CurPosX = x;
//pCurPos = OFF2PTR(XY2OFF(x,y));
pCurPos = (U8*)OFF2PTR(XY2OFF(x,y));//change by lcn
switch (x&7) {
case 3:
case 4:
case 5:
pCurPos++; break;
case 6:
case 7:
pCurPos+=2;
}
}
static void SetNextPixel(LCD_PIXELINDEX c) {
switch (CurPosX&7) {
case 0: *pCurPos = (*pCurPos&~(7<<5))|(c<<5); break;
case 1: *pCurPos = (*pCurPos&~(7<<2))|(c<<2); break;
case 2: *pCurPos = (*pCurPos&~(3))|(c>>1);
pCurPos++;
*pCurPos = (*pCurPos &~(1<<7))|(c<<7);
break;
case 3: *pCurPos = (*pCurPos&~(7<<4))|(c<<4); break;
case 4: *pCurPos = (*pCurPos&~(7<<1))|(c<<1); break;
case 5: *pCurPos = (*pCurPos&~(1))|(c>>2);
pCurPos++;
*pCurPos = (*pCurPos &~(3<<6))|(c<<6);
break;
case 6: *pCurPos = (*pCurPos&~(7<<3))|(c<<3); break;
case 7: *pCurPos = (*pCurPos&~(7<<0))|(c);
pCurPos++;
break;
}
CurPosX++;
}
int LCD_L0_Init (void)
{
rLCDCON1=(0x0)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12);
// disable,8B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
rLCDCON2=(LINEVAL)|(HOZVAL_COLOR<<10)|(10<<21);
//LINEBLANK=10 (without any calculation)
rLCDSADDR1= (0x3<<27) | ( ((unsigned int)aLcdActiveBuffer>>22)<<21 ) | M5D((unsigned int)aLcdActiveBuffer>>1);
// 256-color, LCDBANK, LCDBASEU
rLCDSADDR2= M5D((((unsigned int)aLcdActiveBuffer+(SCR_XSIZE*LCD_YSIZE))>>1)) | (MVAL<<21);
rLCDSADDR3= (LCD_XSIZE/2) | ( ((SCR_XSIZE-LCD_XSIZE)/2)<<9 );
//The following value has to be changed for better display.
rREDLUT =0xfdb96420;
rGREENLUT=0xfdb96420;
rBLUELUT =0xfb40;
rDITHMODE=0x0;
rDP1_2 =0xa5a5;
rDP4_7 =0xba5da65;
rDP3_5 =0xa5a5f;
rDP2_3 =0xd6b;
rDP5_7 =0xeb7b5ed;
rDP3_4 =0x7dbe;
rDP4_5 =0x7ebdf;
rDP6_7 =0x7fdfbfe;
rLCDCON1=(0x1)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12);
rPDATB &= 0xffef;
return 0;
// Lcd_Clr();
// Lcd_ActiveClr();
}
void LCD_L0_ReInit(void)
{
}
void LCD_L0_On(void)
{
}
void LCD_L0_Off(void)
{
}
void LCD_L0_FillRect(int x0, int y0, int x1, int y1)
{
for (; y0 <= y1; y0++) {
LCD_L0_DrawHLine(x0,y0, x1);
}
}
void LCD_L0_DrawHLine (int x0, int y,int x1)
{
if (x0>x1) return; /* Check if nothing to draw */
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
while (x0 <= x1) {
LCD_L0_XorPixel(x0,y);
// XORPIXEL(x0, y);
x0++;
}
} else {
while (x0 <= x1) {
LCD_L0_DrawPixel(x0,y,LCD_COLORINDEX);
// SETPIXEL(x0, y, COLOR);
x0++;
}
}
}
void LCD_L0_DrawVLine(int y0, int y1,int x )
{
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
while (y0 <= y1) {
LCD_L0_XorPixel(x,y0);
// XORPIXEL(x, y0);
y0++;
}
} else {
while (y0 <= y1) {
LCD_L0_DrawPixel(x,y0,LCD_COLORINDEX);
// SETPIXEL(x, y0, COLOR);
y0++;
}
}
}
/*
***************************************************************
* *
* 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 pixels;
LCD_PIXELINDEX Index0 = *(pTrans+0);
LCD_PIXELINDEX Index1 = *(pTrans+1);
/*
// Jump to right entry point
*/
pixels = *p;
switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS|LCD_DRAWMODE_XOR)) {
case 0:
#if (LCD_OPTIMIZE) \
&& (!LCD_MIRROR_X) \
&& (!LCD_MIRROR_Y) \
&& (!LCD_SWAP_XY) \
&& (!LCD_SUPPORT_COMTRANS) \
&& (!LCD_SUPPORT_SEGTRANS) \
&& ((LCD_BITSPERPIXEL == 3) || (LCD_BITSPERPIXEL == 6))
SetPosXY(x+(Diff&7),y);
#endif
switch (Diff&7) {
case 0:
goto WriteBit0;
case 1:
goto WriteBit1;
case 2:
goto WriteBit2;
case 3:
goto WriteBit3;
case 4:
goto WriteBit4;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -