📄 lcd.c
字号:
}
y_sign = (usY1 - usY0) / usDy;
x_sign = (usX1 - usX0) / usDx;
if( usDx >= usDy )
{
for( wCurx = usX0, wCury = usY0, wNextx = usX1,
wNexty = usY1, decision = (usDx >> 1);
wCurx <= wNextx; wCurx++, wNextx--, decision += usDy )
{
if( decision >= usDx )
{
decision -= usDx;
wCury += y_sign;
wNexty -= y_sign;
}
for( wpy = wCury - usWidth / 2;
wpy <= wCury + usWidth / 2; wpy++ )
{
LCD_PutPixel(wCurx, wpy, ucColor);
}
for( wpy = wNexty - usWidth / 2;
wpy <= wNexty + usWidth / 2; wpy++ )
{
LCD_PutPixel(wNextx, wpy, ucColor);
}
}
}
else
{
for( wCurx = usX0, wCury = usY0, wNextx = usX1,
wNexty = usY1, decision = (usDy >> 1);
wCury <= wNexty; wCury++, wNexty--, decision += usDx )
{
if( decision >= usDy )
{
decision -= usDy;
wCurx += x_sign;
wNextx -= x_sign;
}
for( wpx = wCurx - usWidth / 2;
wpx <= wCurx + usWidth / 2; wpx++ )
{
LCD_PutPixel(wpx, wCury, ucColor);
}
for( wpx = wNextx - usWidth / 2;
wpx <= wNextx + usWidth / 2; wpx++ )
{
LCD_PutPixel(wpx, wNexty, ucColor);
}
}
}
}
/*********************************************************************************************
* name: Lcd_Draw_HLine()
* func: Draw horizontal line with appointed color
* para: usX0,usY0 -- line's start point coordinate
* usX1 -- line's end point X-coordinate
* ucColor -- appointed color value
* usWidth -- line's width
* ret: none
* modify:
* comment:
*********************************************************************************************/
void Lcd_Draw_HLine(INT16 usX0, INT16 usX1, INT16 usY0, INT8U ucColor, INT16U usWidth)
{
INT16 usLen;
if( usX1 < usX0 )
{
GUISWAP (usX1, usX0);
}
while( (usWidth--) > 0 )
{
usLen = usX1 - usX0 + 1;
while( (usLen--) > 0 )
{
LCD_PutPixel(usX0 + usLen, usY0, ucColor);
}
usY0++;
}
}
/*********************************************************************************************
* name: Lcd_Draw_VLine()
* func: Draw vertical line with appointed color
* para: usX0,usY0 -- line's start point coordinate
* usY1 -- line's end point Y-coordinate
* ucColor -- appointed color value
* usWidth -- line's width
* ret: none
* modify:
* comment:
*********************************************************************************************/
void Lcd_Draw_VLine (INT16 usY0, INT16 usY1, INT16 usX0, INT8U ucColor, INT16U usWidth)
{
INT16 usLen;
if( usY1 < usY0 )
{
GUISWAP (usY1, usY0);
}
while( (usWidth--) > 0 )
{
usLen = usY1 - usY0 + 1;
while( (usLen--) > 0 )
{
LCD_PutPixel(usX0, usY0 + usLen, ucColor);
}
usX0++;
}
}
/*********************************************************************************************
* name: Lcd_DspAscII6x8()
* func: display 6x8 ASCII character string
* para: usX0,usY0 -- ASCII character string's start point coordinate
* ForeColor -- appointed color value
* pucChar -- ASCII character string
* ret: none
* modify:
* comment:
*********************************************************************************************/
void Lcd_DspAscII6x8(INT16U usX0, INT16U usY0,INT8U ForeColor, INT8U* pucChar)
{
INT32U i,j;
INT8U ucTemp;
while( *pucChar != 0 )
{
for( i=0; i < 8; i++ )
{
ucTemp = g_auc_Ascii6x8[(*pucChar) * 8 + i];
for( j = 0; j < 8; j++ )
{
if( (ucTemp & (0x80 >> j)) != 0 )
{
LCD_PutPixel(usX0 + i, usY0 + 8 - j, (INT8U)ForeColor);
}
}
}
usX0 += XWIDTH;
pucChar++;
}
}
/*********************************************************************************************
* name: ReverseLine()
* func: Reverse display some lines
* para: ulHeight -- line's height
* ulY -- line's Y-coordinate
* ret: none
* modify:
* comment:
*********************************************************************************************/
void ReverseLine(INT32U ulHeight, INT32U ulY)
{
INT32U i, j, temp;
for( i = 0; i < ulHeight; i++ )
{
for( j = 0; j < (SCR_XSIZE/4/2) ; j++ )
{
temp = *(INT32U*)(LCD_VIRTUAL_BUFFER + (ulY+i)*SCR_XSIZE/2 + j*4);
temp ^= 0xFFFFFFFF;
*(INT32U*)(LCD_VIRTUAL_BUFFER + (ulY+i)*SCR_XSIZE/2 + j*4) = temp;
}
}
}
/*********************************************************************************************
* name: Zdma0Done()
* func: LCD dma interrupt handle function
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
static INT8U ucZdma0Done=1; //When DMA is finish,ucZdma0Done is cleared to Zero
void Zdma0Done(void)
{
rI_ISPC=BIT_ZDMA0; //clear pending
ucZdma0Done=0;
}
/*********************************************************************************************
* name: Lcd_Dma_Trans()
* func: dma transport virtual LCD screen to LCD actual screen
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void Lcd_Dma_Trans(void)
{
INT8U err;
ucZdma0Done=1;
//#define LCD_VIRTUAL_BUFFER (0xc400000)
//#define LCD_ACTIVE_BUFFER (LCD_VIRTUAL_BUFFER+(SCR_XSIZE*SCR_YSIZE/2)) //DMA ON
//#define LCD_ACTIVE_BUFFER LCD_VIRTUAL_BUFFER //DMA OFF
//#define LCD_BUF_SIZE (SCR_XSIZE*SCR_YSIZE/2)
//So the Lcd Buffer Low area is from LCD_VIRTUAL_BUFFER to (LCD_ACTIVE_BUFFER+(SCR_XSIZE*SCR_YSIZE/2))
rNCACHBE1=(((unsigned)(LCD_ACTIVE_BUFFER)>>12) <<16 )|((unsigned)(LCD_VIRTUAL_BUFFER)>>12);
rZDISRC0=(DW<<30)|(1<<28)|LCD_VIRTUAL_BUFFER; // inc
rZDIDES0=( 2<<30) |(1<<28)|LCD_ACTIVE_BUFFER; // inc
rZDICNT0=( 2<<28)|(1<<26)|(3<<22)|(0<<20)|(LCD_BUF_SIZE);
// | | | | |---->0 = Disable DMA
// | | | |------------>Int. whenever transferred
// | | |-------------------->Write time on the fly
// | |---------------------------->Block(4-word) transfer mode
// |------------------------------------>whole service
//reEnable ZDMA transfer
rZDICNT0 |= (1<<20); //after ES3
rZDCON0=0x1; // start!!!
Delay(500);
//while(ucZdma0Done); //wait for DMA finish
}
/*********************************************************************************************
* name: Lcd_Test()
* func: LCD test function
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void Lcd_Test(void)
{
/* initial LCD controller */
Lcd_Init();
/* clear screen */
Lcd_Clr();
Lcd_Active_Clr(WHITE);
/* draw rectangle pattern */
#if(LCD_TYPE==TLCD_160_240)
Lcd_Draw_Box(0,0,150,230,15);
Lcd_Draw_Box(10,10,140,220,14);
Lcd_Draw_Box(20,20,130,210,13);
Lcd_Draw_Box(30,30,120,200,12);
Lcd_Draw_Box(40,40,110,190,11);
Lcd_Draw_Box(50,50,100,180,10);
Lcd_Draw_Box(60,60,90,170,9);
Lcd_Draw_Box(70,70,80,160,8);
#else
Lcd_Draw_Box(1,1,319,239,15);
Lcd_Draw_Box(10,10,310,230,15);
Lcd_Draw_Box(20,20,300,220,14);
Lcd_Draw_Box(30,30,290,210,13);
Lcd_Draw_Box(40,40,280,200,12);
Lcd_Draw_Box(50,50,270,190,11);
Lcd_Draw_Box(60,60,260,180,10);
Lcd_Draw_Box(70,70,250,170,9);
Lcd_Draw_Box(80,80,240,160,8);
Lcd_Draw_Box(90,90,230,150,7);
Lcd_Draw_Box(100,100,220,140,6);
Lcd_Draw_Box(110,110,210,130,5);
#endif
/* output ASCII symbol */
Lcd_DspAscII6x8(15,30,BLACK,"Embest Info&Tech Co,. LTD. Press any key to exit...");
//ReverseLine(24,200);
Lcd_Dma_Trans();
Delay(500);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -