⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd.c

📁 优龙 320X240灰度屏测试程序源码
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "44b.h"
#include "44blib.h"
#include "def.h"

#include "lcd.h"
#include "lcdlib.h"
#include "glib.h"

#include "Bmp_Color256_320_240.h"
#include "Bmp_G16_240_320.h"

void Test_LcdMono(void);
void Test_LcdG4(void);
void Test_LcdG16(void);
void Test_LcdColor(void);

void Test_LcdMono(void)
{
    int i,j;
    Lcd_Init(MODE_MONO);
    Lcd_DispON();
    Glib_Init(MODE_MONO);
    Uart_Printf("[Mono(1bit/1pixel) LCD Test]: Press Any Key!\n");              

    Glib_ClearScr(0);
    for(j=0;j<LCD_YSIZE;j+=16)
	for(i=0;i<LCD_XSIZE;i+=16)
	    Glib_FilledRectangle(i,j,i+15,j+15,((j+i)/16)%2);
    Uart_Printf("Mono test 1. Press any key!\n");
    Uart_Getch();  	

    Glib_ClearScr(0);
    Glib_FilledRectangle(160,0,319,239,1);
    Uart_Printf("Mono test 2. Press any key!\n");
    Uart_Getch();  	

    Glib_ClearScr(0); 
    Glib_Rectangle(0,0,319,239,1);   // #0
    Glib_Line(0,0,319,239,1);        // 00
    Glib_Line(0,239,319,0,1);

    Glib_Rectangle(0+320,0,319+320,239,1);   // 0#
    Glib_Line(0+320,0,319+320,239,1);        // 00
    Glib_Line(0+320,239,319+320,0,1);
    Glib_FilledRectangle(50+320,50,269+320,189,1);

    Glib_Rectangle(0,0+240,319,239+240,1);   // 00
    Glib_Line(0,0+240,319,239+240,1);        // #0
    Glib_Line(0,239+240,319,0+240,1);
    Glib_FilledRectangle(50,50+240,269,189+240,1);
    
    Glib_Rectangle(0+320,0+240,319+320,239+240,1);   // 00	
    Glib_Line(0+320,0+240,319+320,239+240,1);        // 0#
    Glib_Line(0+320,239+240,319+320,0+240,1);
    Glib_Rectangle(50+320,50+240,269+320,189+240,1);

    Uart_Printf("Virtual Screen Test(Mono). Press any key[ijkm\\r]!\n");
    MoveViewPort(MODE_MONO);

    Lcd_MoveViewPort(0,0,MODE_MONO);
}





void Test_LcdG4(void)
{
    int i,j,k;

    Lcd_Init(MODE_G4);
    Lcd_DispON();
    Glib_Init(MODE_G4);

    Uart_Printf("[4gray(2bit/1pixel) LCD Test]: Press Any Key!\n");

    Glib_ClearScr(0);


    j=0;
    for(i=0;i<320;i+=80)
        Glib_FilledRectangle(0+i,0,79+i,239,j++);
    Uart_Printf("4 gray mode test 1. Press any key!\n");
    Uart_Getch();  	


    Glib_ClearScr(0);
    j=0;
    for(i=0;i<320;i+=80)
    {
    	Glib_FilledRectangle(0+i,0,79+i,119,j);
    	Glib_FilledRectangle(0+i,120,79+i,239,3-j);
    	j++;
    }
    Uart_Printf("4 gray mode test 2. Press any key!\n");
    Uart_Getch();  	


    Glib_ClearScr(0);
    j=0;
    for(i=0;i<240;i+=60)
    {
    	Glib_FilledRectangle(i,i,i+59,i+59,j);
    	j++;
    }
    Uart_Printf("4 gray mode test 3. Press any key!\n");
    Uart_Getch();  	


    Glib_ClearScr(0);
    k=0;
    for(i=160;i<480;i+=80)
    {
    	for(j=120;j<360;j+=60)
    	{
    	    Glib_FilledRectangle(i,j,i+79,j+59,k%4);
    	    k++;
    	}
    	k+=2;;
    }

    // #0
    // 00
    Glib_Rectangle(0,0,319,239,3);   
    Glib_Line(0,0,319,239,3);        
    Glib_Line(0,239,319,0,3);

    // 0#
    // 00
    Glib_Rectangle(0+320,0,319+320,239,3);          
    Glib_Line(0+320,0,319+320,239,3);        
    Glib_Line(0+320,239,319+320,0,3);

    // 00
    // #0
    Glib_Rectangle(0,0+240,319,239+240,3);          
    Glib_Line(0,0+240,319,239+240,3);        
    Glib_Line(0,239+240,319,0+240,3);

    // 00
    // 0#
    Glib_Line(0+320,0+240,319+320,239+240,3);        
    Glib_Line(0+320,239+240,319+320,0+240,3);
    Glib_Rectangle(50+320,50+240,269+320,189+240,3);

    Uart_Printf("Virtual Screen Test(4 gray). Press any key[ijkm\\r]!\n");
    MoveViewPort(MODE_G4);

    Lcd_MoveViewPort(0,0,MODE_G4);

}


void Test_LcdG16(void)
{
    int x, y, m ;

    Lcd_Init(MODE_G16);
    Lcd_DispON();
    Glib_Init(MODE_G16);

    Uart_Printf("[16 gray(4bit/1pixel) LCD Test]: Press Any Key!\n");

    Glib_ClearScr(0);
    m = 0;
    for( y = 0; y < LCD_YSIZE; y+=40 )
    {
    	for( x = 0; x < LCD_XSIZE; x+=40 )
    	{
    	    Glib_FilledRectangle( x, y, (x+39), (y+39), (m&0xf) );
    	    m++ ;
    	}
    }    
    Uart_Printf("Virtual Screen Test(16 gray). Press any key[ijkm\\r]!\n");
    MoveViewPort(MODE_G16);

    Glib_ClearScr(0xf);
    m = 0;
    for( y = 0; y < SCR_YSIZE; y+=40 )
    {
    	for( x = 0; x < SCR_XSIZE; x+=40 )
    	{
    	    Glib_FilledRectangle( x, y, (x+39), (y+39), (m&0xf) );
    	    m++ ;
    	}
    }    
    Uart_Printf("Virtual Screen Test(16 gray). Press any key[ijkm\\r]!\n");
    MoveViewPort(MODE_G16);
    Lcd_MoveViewPort(0,0,MODE_G16);
/*
    Glib_ClearScr(0x0);
    m = 0;
    for( y = 0; y < 320; y++ )		//画16色图片
    {
    	for( x = 0; x < 240; x+=2 )
    	{
			PutPixel( (x+1), y, (ac1_Ucdragon16[m]&0x0f) );    	    
			PutPixel( (x+0), y, (ac1_Ucdragon16[m]>>4) );    	    
    	    m++ ;
    	}
    }    
    Uart_Printf("paint bmp 1 !\n");   Uart_Getch();  	

    Glib_ClearScr(0x0);
    m = 0;
    for( y = 0; y < 320; y++ )		//画16色图片
    {
    	for( x = 0; x < 240; x+=2 )
    	{
			PutPixel( (x+1), y, (acBRUCELEE[m]&0x0f) );    	    
			PutPixel( (x+0), y, (acBRUCELEE[m]>>4) );    	    
    	    m++ ;
    	}
    }    
    Uart_Printf("paint bmp 2 !\n");   Uart_Getch();  	

    Glib_ClearScr(0x0);
    m = 0;
    for( y = 0; y < 320; y++ )		//画16色图片
    {
    	for( x = 0; x < 240; x+=2 )
    	{
			PutPixel( (x+1), y, (acHEBEN[m]&0x0f) );    	    
			PutPixel( (x+0), y, (acHEBEN[m]>>4) );    	    
    	    m++ ;
    	}
    }    
    Uart_Printf("paint bmp 3 !\n");   Uart_Getch();  	

    Glib_ClearScr(0x0);
    m = 0;
    for( y = 0; y < 320; y++ )		//画16色图片
    {
    	for( x = 0; x < 240; x+=2 )
    	{
			PutPixel( (x+1), y, (acLDH[m]&0x0f) );    	    
			PutPixel( (x+0), y, (acLDH[m]>>4) );    	    
    	    m++ ;
    	}
    }    
    Uart_Printf("paint bmp 4 !\n");   Uart_Getch();  	

    Glib_ClearScr(0x0);
    m = 0;
    for( y = 0; y < 320; y++ )		//画16色图片
    {
    	for( x = 0; x < 240; x+=2 )
    	{
			PutPixel( (x+1), y, (acMAO[m]&0x0f) );    	    
			PutPixel( (x+0), y, (acMAO[m]>>4) );    	    
    	    m++ ;
    	}
    }    
    Uart_Printf("paint bmp 5 !\n");   Uart_Getch();  	

    Glib_ClearScr(0x0);
    m = 0;
    for( y = 0; y < 320; y++ )		//画16色图片
    {
    	for( x = 0; x < 240; x+=2 )
    	{
			PutPixel( (x+1), y, (acSCHOOL[m]&0x0f) );    	    
			PutPixel( (x+0), y, (acSCHOOL[m]>>4) );    	    
    	    m++ ;
    	}
    }    
    Uart_Printf("paint bmp 6 !\n");   Uart_Getch();  	
*/
}

void LcdG16_Bmp( unsigned char bmp[] )
{
    int x, y, m ;

    Lcd_Init(MODE_G16);
    Lcd_DispON();
    Glib_Init(MODE_G16);

    m = 0;
    for( y = 0; y < 320; y++ )		//画16色图片
    {
    	for( x = 0; x < 240; x+=2 )
    	{
			PutPixel( (x+1), y, (bmp[m]&0x0f) );    	    
			PutPixel( (x+0), y, (bmp[m]>>4) );    	    
    	    m++ ;
    	}
    }    
}

//*****************************************************************************
void LcdG16_Bmp_Overturn( unsigned char bmp[] )
{
    int x, y, m ;

    Lcd_Init(MODE_G16);
    Lcd_DispON();
    Glib_Init(MODE_G16);

    m = 0;
    for( y = 319; y >= 0; y-- )		//画16色图片
    {
    	for( x = 238; x >= 0; x-=2 )
    	{
			PutPixel( (x+0), y, (bmp[m]&0x0f) );    	    
			PutPixel( (x+1), y, (bmp[m]>>4) );    	    
    	    m++ ;
    	}
    }    
}

//*****************************************************************************
U8 High_Low( U8 x )
{
	x = ( (x>>1)&0x1c ) | (x>>6) | (x<<5);
	return x ;
}

void Test_LcdColor(void)
{
    int i,j,k;

    rPDATE=rPDATE&~(1<<5)|(1<<5);	//GPE5=H	 
    rPCONE=rPCONE&~(3<<10)|(1<<10);	//GPE5=output
    rPCONC=rPCONC&~(0xff<<8)|(0xff<<8);	//GPC[4:7] => VD[7:4]
    
    Uart_Printf("[(240x3)x320 COLOR STN LCD TEST]\n");
 
    Uart_Printf("     R:0   ...    7 \n");
    Uart_Printf("G:0  B0:1 B0:1 B0:1 \n");
    Uart_Printf("G:.   2:3  2:3  2:3 \n");
    Uart_Printf("G:.  B0:1 B0:1 B0:1 \n");
    Uart_Printf("G:.   2:3  2:3  2:3 \n");
    Uart_Printf("G:.  B0:1 B0:1 B0:1 \n");
    Uart_Printf("G:7   2:3  2:3  2:3 \n");

    Lcd_Init(MODE_COLOR);
    Lcd_DispON();
    Glib_Init(MODE_COLOR);

    Glib_ClearScr(0);
    Uart_Printf("The screen is clear!\n");
    Uart_Getch();  	

    k=0;
    for(i=0;i<320;i+=20)
	    for(j=0;j<240;j+=15)
	    {
    	    Glib_FilledRectangle(i,j,(i+20),(j+15),k);
    	    k++ ;
    	}
    Uart_Printf("color mode test 0. Press any key!\n");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -