📄 lcd_vga_640_480.c
字号:
{
PutPixel(x1,y1,color);
if(e>0){x1+=1;e-=dy;}
y1+=1;
e+=dx;
}
}
}
else // dy<0
{
dy=-dy; // dy=abs(dy)
if(dx>=dy) // 8/8 octant
{
e=dy-dx/2;
while(x1<=x2)
{
PutPixel(x1,y1,color);
if(e>0){y1-=1;e-=dx;}
x1+=1;
e+=dy;
}
}
else // 7/8 octant
{
e=dx-dy/2;
while(y1>=y2)
{
PutPixel(x1,y1,color);
if(e>0){x1+=1;e-=dy;}
y1-=1;
e+=dx;
}
}
}
}
else //dx<0
{
dx=-dx; //dx=abs(dx)
if(dy >= 0) // dy>=0
{
if(dx>=dy) // 4/8 octant
{
e=dy-dx/2;
while(x1>=x2)
{
PutPixel(x1,y1,color);
if(e>0){y1+=1;e-=dx;}
x1-=1;
e+=dy;
}
}
else // 3/8 octant
{
e=dx-dy/2;
while(y1<=y2)
{
PutPixel(x1,y1,color);
if(e>0){x1-=1;e-=dy;}
y1+=1;
e+=dx;
}
}
}
else // dy<0
{
dy=-dy; // dy=abs(dy)
if(dx>=dy) // 5/8 octant
{
e=dy-dx/2;
while(x1>=x2)
{
PutPixel(x1,y1,color);
if(e>0){y1-=1;e-=dx;}
x1-=1;
e+=dy;
}
}
else // 6/8 octant
{
e=dx-dy/2;
while(y1>=y2)
{
PutPixel(x1,y1,color);
if(e>0){x1-=1;e-=dy;}
y1-=1;
e+=dx;
}
}
}
}
}
/**************************************************************
在LCD屏幕上画一个矩形
**************************************************************/
extern void Glib_Rectangle(int x1,int y1,int x2,int y2, U16 color)
{
Glib_Line(x1,y1,x2,y1,color);
Glib_Line(x2,y1,x2,y2,color);
Glib_Line(x1,y2,x2,y2,color);
Glib_Line(x1,y1,x1,y2,color);
}
/**************************************************************
在LCD屏幕上用颜色填充一个矩形
**************************************************************/
extern void Glib_FilledRectangle(int x1,int y1,int x2,int y2, U16 color)
{
int i;
for(i=y1;i<=y2;i++)
Glib_Line(x1,i,x2,i,color);
}
/**************************************************************
在LCD屏幕上指定坐标点画一个指定大小的图片
**************************************************************/
static void Paint_Bmp(int x0,int y0,int h,int l,unsigned char bmp[])
{
int x,y;
U32 c;
int p = 0;
for( y = 0 ; y < l ; y++ )
{
for( x = 0 ; x < h ; x++ )
{
c = bmp[p+1] | (bmp[p]<<8) ;
if ( ( (x0+x) < SCR_XSIZE_TFT_640480) && ( (y0+y) < SCR_YSIZE_TFT_640480) )
LCD_BUFER[y0+y][x0+x] = c ;
p = p + 2 ;
}
}
}
/**************************************************************
**************************************************************/
/*void Test_Lcd_VGA_640_480(void)
{
#ifdef DEBUG
Uart_Printf("\nTest TFT LCD 640×480(VGA)!\n");
#endif
Lcd_Port_Init();
Lcd_Init();
Lcd_EnvidOnOff(1); //turn on vedio
*/
/*
Lcd_ClearScr( (0x00<<11) | (0x00<<5) | (0x00) ) ; //clear screen
Uart_Printf( "\nLCD clear screen is finished! press any key to continue!\n" );
Uart_Getch() ; //wait uart input
Lcd_ClearScr( (0x1f<<11) | (0x3f<<5) | (0x1f) ) ; //clear screen
Uart_Printf( "LCD clear screen is finished! press any key to continue!\n" );
Uart_Getch() ; //wait uart input
Lcd_ClearScr( (0x00<<11) | (0x00<<5) | (0x1f) ) ; //clear screen
Uart_Printf( "LCD clear screen is finished! press any key to continue!\n" );
Uart_Getch() ; //wait uart input
Lcd_ClearScr( (0x00<<11) | (0x3f<<5) | (0x00) ) ; //clear screen
Uart_Printf( "LCD clear screen is finished! press any key to continue!\n" );
Uart_Getch() ; //wait uart input
Lcd_ClearScr( (0x1f<<11) | (0x00<<5) | (0x00) ) ; //clear screen
Uart_Printf( "LCD clear screen is finished! press any key to continue!\n" );
Uart_Getch() ; //wait uart input
Lcd_ClearScr( (0x00<<11) | (0x3f<<5) | (0x1f) ) ; //clear screen
Uart_Printf( "LCD clear screen is finished! press any key to continue!\n" );
Uart_Getch() ; //wait uart input
Lcd_ClearScr( (0x1f<<11) | (0x00<<5) | (0x1f) ) ; //clear screen
Uart_Printf( "LCD clear screen is finished! press any key to continue!\n" );
Uart_Getch() ; //wait uart input
Lcd_ClearScr( (0x1f<<11) | (0x3f<<5) | (0x00) ) ; //clear screen
Uart_Printf( "LCD clear screen is finished! press any key to continue!\n" );
Uart_Getch() ; //wait uart input
*/
/* Lcd_ClearScr(0xffff); //fill all screen with some color
#define LCD_BLANK 30
#define C_UP ( LCD_XSIZE_TFT_640480 - LCD_BLANK*2 )
#define C_RIGHT ( LCD_XSIZE_TFT_640480 - LCD_BLANK*2 )
#define V_BLACK ( ( LCD_YSIZE_TFT_640480 - LCD_BLANK*4 ) / 6 )
Glib_FilledRectangle( LCD_BLANK, LCD_BLANK, ( LCD_XSIZE_TFT_640480 - LCD_BLANK ), ( LCD_YSIZE_TFT_640480 - LCD_BLANK ),0x0000); //fill a Rectangle with some color
Glib_FilledRectangle( (LCD_BLANK*2), (LCD_BLANK*2 + V_BLACK*0), (C_RIGHT), (LCD_BLANK*2 + V_BLACK*1),0x001f); //fill a Rectangle with some color
Glib_FilledRectangle( (LCD_BLANK*2), (LCD_BLANK*2 + V_BLACK*1), (C_RIGHT), (LCD_BLANK*2 + V_BLACK*2),0x07e0); //fill a Rectangle with some color
Glib_FilledRectangle( (LCD_BLANK*2), (LCD_BLANK*2 + V_BLACK*2), (C_RIGHT), (LCD_BLANK*2 + V_BLACK*3),0xf800); //fill a Rectangle with some color
Glib_FilledRectangle( (LCD_BLANK*2), (LCD_BLANK*2 + V_BLACK*3), (C_RIGHT), (LCD_BLANK*2 + V_BLACK*4),0xffe0); //fill a Rectangle with some color
Glib_FilledRectangle( (LCD_BLANK*2), (LCD_BLANK*2 + V_BLACK*4), (C_RIGHT), (LCD_BLANK*2 + V_BLACK*5),0xf81f); //fill a Rectangle with some color
Glib_FilledRectangle( (LCD_BLANK*2), (LCD_BLANK*2 + V_BLACK*5), (C_RIGHT), (LCD_BLANK*2 + V_BLACK*6),0x07ff); //fill a Rectangle with some color
Uart_Printf( "LCD color test, please look! press any key to continue!\n" );
Uart_Getch() ; //wait uart input
*/
/*
Paint_Bmp(0,0,640,480, girl0_640_480); //paint a bmp
Uart_Printf( "LCD paint a bmp, please look! press any key to continue! \n" );
Uart_Getch() ; //wait uart input
Paint_Bmp(0,0,640,480, girl1_640_480); //paint a bmp
Uart_Printf( "LCD paint a bmp, please look! press any key to continue! \n" );
Uart_Getch() ; //wait uart input
Paint_Bmp(0,0,640,480, flower1_640_480); //paint a bmp
Uart_Printf( "LCD paint a bmp, please look! press any key to continue! \n" );
Uart_Getch() ; //wait uart input
Paint_Bmp(0,0,640,480, girl2_640_480); //paint a bmp
Uart_Printf( "LCD paint a bmp, please look! press any key to continue! \n" );
Uart_Getch() ; //wait uart input
*/
//Paint_Bmp(0,0,640,480, girl3_640_480); //paint a bmp
/* Glib_Rectangle(10,10,100,100, 0x001f);
Uart_Printf( "LCD paint a Rectangle, please look! press any key to continue! \n" );
Uart_Printf( "ha ha!!!\n" );
Uart_Getch() ; //wait uart input
Glib_Rectangle(200,200,400,400, 0x001f);
Uart_Printf( "LCD paint a Rectangle, please look! press any key to continue! \n" );
Uart_Printf( "ha ha!!!\n" );
Uart_Getch() ; //wait uart input
Lcd_EnvidOnOff(0); //turn on vedio
Lcd_Tft_240X320_Init() ; //
}
*/
//*************************************************************
void WriteLcdMems( U32 off, U32 c )
{
U32 x, y ;
y = off/640 ; x = off%640 ;
PutPixel(x,y,c);
/*if(x<SCR_XSIZE_TFT_640480 && y<SCR_YSIZE_TFT_640480)
LCD_BUFER[(y)][(x)/2]=( LCD_BUFER[(y)][x/2]
& ~(0xffff0000>>((x)%2)*16) ) | ( (c&0x0000ffff)<<((2-1-((x)%2))*16) );*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -