📄 lcdwin.c
字号:
return;
x+=2;
pixels = *(++p);
goto WriteTBit0;
}
#endif
/*
*********************************************************
* *
* Draw Bitmap 8 BPP (256 colors) *
* *
* Default (no optimization) *
* *
*********************************************************
*/
#if (LCD_MAX_LOG_COLORS > 16)
static void DrawBitLine8BPP(int x, int y, U8 const*p, int xsize, const LCD_PIXELINDEX*pTrans) {
LCD_PIXELINDEX pixel;
/*
Do x-Clipping
*/
if ((GUI_Context.DrawMode & LCD_DRAWMODE_TRANS)==0) {
while (xsize > 0) {
pixel = *p;
SETPIXEL(x+0, y, *(pTrans+pixel));
xsize--;
x++;
p++;
}
} else { /* Handle transparent bitmap */
while (xsize > 0) {
pixel = *p;
if (pixel)
SETPIXEL(x+0, y, *(pTrans+pixel));
xsize--;
x++;
p++;
}
}
}
#endif
/*
*********************************************************
* *
* Universal draw Bitmap routine *
* *
*********************************************************
*/
void LCD_L0_DrawBitmap (int x0, int y0,
int xsize, int ysize,
int BitsPerPixel,
int BytesPerLine,
const U8* pData, int Diff,
const LCD_PIXELINDEX* pTrans)
{
int i;
if (!pTrans)
pTrans = LCD_ConversionTable;
/*
Use DrawBitLineXBPP
*/
for (i=0; i<ysize; i++) {
switch (BitsPerPixel) {
case 1:
DrawBitLine1BPP(x0, i+y0, pData, Diff, xsize, pTrans);
break;
#if (LCD_MAX_LOG_COLORS > 2)
case 2:
DrawBitLine2BPP(x0, i+y0, pData, Diff, xsize, pTrans);
break;
#endif
#if (LCD_MAX_LOG_COLORS > 4)
case 4:
DrawBitLine4BPP(x0, i+y0, pData, Diff, xsize, pTrans);
break;
#endif
#if (LCD_MAX_LOG_COLORS > 16)
case 8:
DrawBitLine8BPP(x0, i+y0, pData, xsize, pTrans);
break;
#endif
}
pData += BytesPerLine;
}
}
/********************************************************
*
* LCD_L0_SetOrg
*
*********************************************************
Purpose: Sets the original position of the virtual display.
Has no function at this point with the PC-driver.
*/
int OrgX, OrgY;
void LCD_L0_SetOrg(int x, int y) {
OrgX = x;
OrgY = y;
}
/*
*********************************************************
* *
* Support for verification *
* *
*********************************************************
The following routines are implemented, but have no functionility
at this point. The reason is that these functions are supposed
to supervise the hardware, which for obvious reasons can not be
done in a simulation.
*/
#if LCD_SUPPORT_VERIFY
int LCD_GetErrStat(void) {
return 0;
}
void LCD_ClrErrStat(void) {
}
int LCD_GetErrCnt (void) {
return 0;
}
#endif
/*
*********************************************************
* *
* Copy rectangle *
* *
*********************************************************
This function is used for scrolling. If scrolling is not required
(as is sometimes the case) this routine can be eliminated via
configuration switch.
*/
#if LCD_SUPPORT_COPYRECT
static void Copy_Line (int y,int x0,int x1,int dx,int dy) {
if (dy >=0) {
int x;
for (x=x0; x<=x1; x++) {
_SetPixel(x+dx, y+dy, _GetPixel(x,y));
}
} else {
int x;
for (x=x1; x>=x0; x--) {
_SetPixel(x+dx, y+dy, _GetPixel(x,y));
}
}
}
void LCD_CopyRect (int x0, int y0, int x1, int y1, int dx, int dy) {
if (dy >=0) {
int y;
for (y=y0; y<=y1; y++) {
Copy_Line (y,x0,x1,dx,dy);
}
} else {
int y;
for (y=y1; y>=y0; y--) {
Copy_Line (y,x0,x1,dx,dy);
}
}
}
#endif
/*
*********************************************************
* *
* LCD_SetPaletteEntry *
* *
*********************************************************
*/
void LCD_L0_SetLUTEntry(U8 Pos, LCD_COLOR color) {
Pos=Pos;
color=color;
}
/*
*********************************************************
* *
* LCD_On *
* LCD_Off *
* *
*********************************************************
*/
void LCD_Off (void) {
#ifdef LCD_OFF
LCD_OFF();
#endif
}
void LCD_On (void) {
#ifdef LCD_ON
LCD_ON();
#endif
}
unsigned int LCD_L0_GetPixelIndex(int x, int y) {
return GETPIXEL(x,y);
}
/*
*********************************************************
* *
* LCD_Init : Init the display *
* *
*********************************************************
*/
int LCD_L0_Init(void) {
/* Controller independent */
#if LCD_WATCHDOG_TRIGGERCNT
WatchdogTriggerCnt =0;
#endif
/* Controller initialisation */
//LCD_FirstInit();
//LCD_L0_ReInit();
LCD_L0_ReInit();
/* Init successfull */
return 0;
}
#else
void LCDSLin(void) { } /* avoid empty object files */
#endif
//Init Driver
void LCD_L0_ReInit(void) {
// LCD_ENABLE_REG_ACCESS();
//LCD_INIT_CONTROLLER(); /* macro defined in config */
//#if LCD_USE_BITBLT
// WRITE_REG(0x10c/2,WORDSPERLINE); /* Write Bit blit engine line offset */
//WRITE_REG(0x100/2,0x0); /* Stop engine (to be on the safe side ...) */
//#endif
//LCD_ENABLE_MEM_ACCESS();
LCD_Reset();
LCD_Initial();
LCD_Clear_1();
LCD_Clear_2();
LCD_CmdWrite(0x00,0xCD);
}
void LCD_Reset(void)
{
int i;
//LCD_READY = 0xff;
SET_LCD_CS();
delay(100000);
FIO4CLR = (1<<10);
for(i=0;i<5;i++)
{
delay(1100000);
}
FIO4SET = (1<<10);
for(i=0;i<5;i++)
{
delay(100000);
}
}
void LCD_Initial(void)
{
//bit7-6: "00" 关闭模式 "11" 正常模式 bit3: "1" 文字模式 "0" 绘图模式 bit2:"1"屏幕开启 "0"屏幕关闭
//bit1: "1" 闪烁模式 "0" 正常显示 bit0: "1" 正常显示 "0" 反白显示
LCD_CmdWrite(0x00,0xC9); // LCD 基本显示功能设定-1 C9
LCD_CmdWrite(0x01,0xF2); // 系统工作频率与中断准位设定 F1
LCD_CmdWrite(0x02,0x10); // LCD 内存读写速度与功能设定
LCD_CmdWrite(0x03,0x80); // LCD 特殊显示功能
//bit7: "1"读DDRAM时光标移位 "0"反之 bit5: "1" 数据正向存储 "0" 数据反向存储
//bit4: "0" 正常字形 "1" 粗体字形 bit3: "1"写DDRAM时光标移位 "0"反之
//bit6: "1"使能中英文对齐 "0"不使能 bit2: "1"光标显示 "0" 光标不显示
//bit1: "1"光标闪烁 "0"光标不闪烁 bit0: "1"光标 宽度随着输入数据变化动 "0" 反之
LCD_CmdWrite(0x10,0x6F); // LCD 基本显示功能设定-2
LCD_CmdWrite(0x11,0x20); // 设定光标高度与行距
//bit7: "1"先水平再垂直 "0"反之 bit6-4:"011"两层都显示
//bit1-0:设定在哪个图层运行
LCD_CmdWrite(0x12,0xB3); // LCD 显示图层设定
LCD_CmdWrite(0x20,0x1D); // 设定实际显示窗口垂直起始地址(X1) 240*128 = 0x1D
LCD_CmdWrite(0x30,0x7F); // 设定实际显示窗口水平起始地址(Y1) 240*128 = 0x7F
LCD_CmdWrite(0x40,0x00); // 设定实际显示窗口垂直结束地址(X2)
LCD_CmdWrite(0x50,0x00); // 设定实际显示窗口水平结束地址(Y2)
LCD_CmdWrite(0x21,0x1D); // 设定LCD 模块垂直起始地址(X1) 240*128 = 0x1D
LCD_CmdWrite(0x31,0x7F); // 设定LCD 模块水平起始地址(Y1) 240*128 = 0x7F
LCD_CmdWrite(0x41,0x00); // 设定LCD 模块垂直结束地址(X2)
LCD_CmdWrite(0x51,0x00); // 设定LCD 模块水平结束地址(Y2)
LCD_CmdWrite(0x60,0x00); // 设定光标水平地址(Common)
LCD_CmdWrite(0x61,0x00); // 设定垂直开始显示地址(Segment)
LCD_CmdWrite(0x70,0x00); // 设定光标垂直地址(Segment)
LCD_CmdWrite(0x71,0x00); // 设定于水平区块移动模式下,起始地址
LCD_CmdWrite(0x72,0x7F); // 设定于水平区块移动模式下,结束地址
LCD_CmdWrite(0x80,0x33); // 光标闪烁时间设定
LCD_CmdWrite(0x81,0x00); // 变换FRM 极性的起始地址(Common)
LCD_CmdWrite(0x91,0x00); // 变换FRM 极性的结束地址(Common)
LCD_CmdWrite(0x90,0x0C);
LCD_CmdWrite(0xA0,0x11); // 中断功能设定
LCD_CmdWrite(0xA1,0x00); // 键盘扫描控制缓存器
LCD_CmdWrite(0xA2,0x00); // 键盘扫描控制输出数据
LCD_CmdWrite(0xA3,0x00); // 键盘扫描控制输入数据
LCD_CmdWrite(0xB0,0x1D); // 设定水平方向断点的地址
LCD_CmdWrite(0xB1,0x7F); // 设定垂直方向断点的地址
LCD_CmdWrite(0xC0,0x00); // 触控屏幕功能设定
LCD_CmdWrite(0xC1,0x0A); // 读写并可侦测触控屏幕的状态
LCD_CmdWrite(0xC8,0x80); // 读取触控屏幕水平轴的数据(高字节)
LCD_CmdWrite(0xC9,0x80); // 读取触控屏幕水平轴的数据(高字节)
LCD_CmdWrite(0xCA,0x00); // 读取触控屏幕水平轴与垂直轴的数据(低字节)
LCD_CmdWrite(0xD0,0x0C); // 设定DAC 电流输出,可调整LCD 亮度
LCD_CmdWrite(0xE0,0x00); // 设定写入显示内存的数据(需搭配缓存器[F0]使用
LCD_CmdWrite(0xF0,0xA0); // 设定中文字型为”BIG5” // A0-GB 90-BIG5 80-ENG
LCD_CmdWrite(0xF1,0x0F); // 改变字型垂直与水平显示大小
}
void LCD_Clear_1(void)
{
unsigned int i;
LCD_CmdWrite(0x00,0xCD);
LCD_CmdWrite(0x12,0xB1); // LCD 显示图层设定1层
GotoXY(0, 0);
for(i=0; i<240; i++)
{
LCD_DataWrite(' ');
}
LCD_CmdWrite(0x12,0xB1);
LCD_CmdWrite(0x00,0xCD);
}
void LCD_Clear_2(void)
{
unsigned int i;
LCD_CmdWrite(0x00,0xCD);
LCD_CmdWrite(0x12,0xB2); // LCD 显示图层设定2层
GotoXY(0,0);
for(i=0; i<240; i++)
{
LCD_DataWrite(' ');
}
LCD_CmdWrite(0x12,0xB1);
LCD_CmdWrite(0x00,0xCD);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -