?? lcd.c
字號(hào):
int i;
GotoXY(x,y);
LCDWriteCmd(MWRITE); // LCD WRITE MEMORY
//while(*ptr != 0x00)
//LCDWriteData(*ptr++);
i=0;
while(1)
{
if(i<16)
{
LCDWriteData(*ptr++);
i++;
}
else
break;
}
}
/**********************************************************
Name: void Cursor(unsigned char)
Description: 0-> Cursor off
1-> Cursor on
Input: ON/OFF
Output: none
Misc:
**********************************************************/
void Cursor(unsigned char cursor)
{
LCDWriteCmd(DISP_ON); // DISPLAY ON COMMAND
if (cursor == 0)
LCDWriteData(0x14);
else
LCDWriteData(0x16);
}
/**********************************************************
Name: void GClrSCR(void)
Description: Clear Graphic Screen layer 2
Input: none
Output: none
Misc:
**********************************************************/
void GClrSCR(void)
{
int i,j;
LCDWriteCmd(CSRW); // CURSOR WRITE COMMAND
LCDWriteData(0x00); // Cursor position low byte
LCDWriteData(0x10); // Cursor position high byte
LCDWriteCmd(MWRITE); // LCD WRITE MEMORY COMMAND
DATAOUT = 0x00;
A0_L; // A0 -> 0
j = ((GUI_LCM_XMAX/8)*GUI_LCM_YMAX);
for (i=0;i<j;i++)
{
WR_L; // WR -> 0 & WR -> 1
WDR();
WR_H;
}
LCDWriteCmd(CSRW); // CURSOR WRITE COMMAND
LCDWriteData(0x00); // Cursor position low byte
LCDWriteData(0x10); // Cursor position high byte
}
/**********************************************************
Name: void GClrPART(void)
Description: Clear Graphic Screen layer 2
Input: none
Output: none
Misc:
**********************************************************/
void GClrPART(int x1, int y1, int x2, int y2)
{
int startAddr=0x0000;
unsigned char LSBa, MSBa,len,wid;
startAddr+=40*y1+x1/8;
for(wid=0;wid<(y2-y1);wid++)
{
LSBa=startAddr&0x00FF;
MSBa=(startAddr>>8)+0x10;
LCDWriteCmd(CSRW);
LCDWriteData(LSBa);
LCDWriteData(MSBa);
LCDWriteCmd(CSRDIR1);
LCDWriteCmd(MWRITE);
for(len=0;len<(x2-x1)/8;len++)
{
LCDWriteData(0x00);
}
startAddr+=40;
}
}
/**********************************************************
Name: void GFullPART(void)
Description: Clear Graphic Screen layer 2
Input: none
Output: none
Misc:
**********************************************************/
void GFullPART(int x1, int y1, int x2, int y2)
{
int startAddr=0x0000;
unsigned char LSBa, MSBa,len,wid;
startAddr+=40*y1+x1/8;
for(wid=0;wid<(y2-y1);wid++)
{
LSBa=startAddr&0x00FF;
MSBa=(startAddr>>8)+0x10;
LCDWriteCmd(CSRW);
LCDWriteData(LSBa);
LCDWriteData(MSBa);
LCDWriteCmd(CSRDIR1);
LCDWriteCmd(MWRITE);
for(len=0;len<(x2-x1)/8;len++)
{
LCDWriteData(0xFF);
}
startAddr+=40;
}
}
/**********************************************************
Name: void GPix(int x, int y, unsigned char stat)
Description: Set of Clear a pixel
Input: none
Output: none
Misc:
**********************************************************/
void GPix(int x, int y, unsigned char stat)
{
unsigned int Address;
unsigned char Offset;
unsigned char low;
unsigned char high;
unsigned char byte;
x--;
y--;
Address = (y * (GUI_LCM_XMAX/8)) + (x / 8);
Offset = x - ((x / 8) * 8);
low = (unsigned char) (Address & 0x00ff);
high = (unsigned char) (((Address & 0xff00) >> 8) + 0x10);
LCDWriteCmd(CSRW); // CURSOR WRITE COMMAND
LCDWriteData(low); // Cursor position low byte
LCDWriteData(high); // Cursor position high byte
LCDWriteCmd(MREAD); // READ LCD MEMORY COMMAND
byte = LCDReadData(); // Read data at position
if (stat != 0)
byte |= (0x80 >> Offset);
else
byte &= (~(0x80 >> Offset));
LCDWriteCmd(CSRW); // CURSOR WRITE COMMAND
LCDWriteData(low); // Cursor position low byte
LCDWriteData(high); // Cursor position high byte
LCDWriteCmd(MWRITE); // LCD WRITE MEMORY COMMAND
LCDWriteData(byte); // Write byte
}
/**********************************************************
Name: void GBox(int x1, int y1, int x2, int y2)
Description: draw a box
Input: none
Output: none
Misc:
**********************************************************/
void GBox(int x1, int y1, int x2, int y2,int stat)
{
int i;
for (i=x1;i<=x2;i++)
GPix(i,y1,stat); // Top line
for (i=x1;i<=x2;i++)
GPix(i,y2,stat); // Bottom line
for (i=y1;i<=y2;i++)
GPix(x1,i,stat); // Left side
for (i=y1;i<=y2;i++)
GPix(x2,i,stat); // Right side
}
/**********************************************************
Name: void TextBox(int x, int y, int length,int stat)
Description:
Input: none
Output: none
Misc:
**********************************************************/
void TextBox(int x, int y, int length,int stat)
{
GBox(((x-1)*8),((y-1)*8),(((length*8)+((x-1)*8))-2),(y*12),stat);
}
/**********************************************************
Name: void GLine(int x1, int y1, int x2, int y2)
Description: draw a line
Input: none
Output: none
Misc:
**********************************************************/
void GLine(int x1, int y1, int x2, int y2)
{
int dx,dy,stepx,stepy,fraction;
dy = y2 - y1;
dx = x2 - x1;
if (dy < 0)
{
dy = -dy;
stepy = -1;
}
else
{
stepy = 1;
}
if (dx < 0)
{
dx = -dx;
stepx = -1;
}
else
{
stepx = 1;
}
dy <<= 1;
dx <<= 1;
GPix(x1,y1,1);
if (dx > dy)
{
fraction = dy - (dx >> 1);
while (x1 != x2)
{
if (fraction >= 0)
{
y1 += stepy;
fraction -= dx;
}
x1 += stepx;
fraction += dy;
GPix(x1,y1,1);
}
}
else
{
fraction = dx - (dy >> 1);
while (y1 != y2)
{
if (fraction >= 0)
{
x1 += stepx;
fraction -= dy;
}
y1 += stepy;
fraction += dx;
GPix(x1,y1,1);
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -