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

📄 lcd.c

📁 keil 环境下44B0X调试模板
💻 C
字号:
/**************************************************************************************
//文件:LCD.C
//作者:sac
//日期:2008年9月7日
//版本:V1.0
//描述:
//版本更新描述
**************************************************************************************/
//=====================================================================================
//包含文件申明
#include	"S3C44B0X.h"                       /* S3C44B0X definitions */
#include 	"LCD_Pic.lib"
#include	"mylcd.h"
#include 	"stdio.h"   
//=====================================================================================
//预定义申明	
#define		LCD_Width	240
#define		LCD_Height	320
//=====================================================================================
//函数申明区
void LcdDrv_Init( void );
void LcdPic_Disp( unsigned int cs );
void Lcd_Clear( void );
//=====================================================================================
//全局变量定义
unsigned int frameBuffer16[320*120*4];//(*frameBuffer16)[SCR_XSIZE/8];
//=====================================================================================
//函数原型:void LcdDrv_Init( void )
//输入参数:无
//返回参数:无
//功能描述:LCD控制器初始化 
//版本说明:V1.0/SAC/2008年9月7日
//更新说明:

void LcdDrv_Init( void )
{
	//160x240 1bit/1pixel LCD
    #define MVAL_USED 0
    /* if((unsigned int)frameBuffer16==0)
	{
	  if (( frameBuffer16=(unsigned int (*)[SCR_XSIZE/8])malloc(ARRAY_SIZE_G16))== '\0')
	     {
	        printf("ERROR !!!!!!!! NO MEMERY !!!!!!! \n");
	      }
	  else 
	       {
	         printf("ARRAY_SIZE_g16= %d \n", ARRAY_SIZE_G16);
	        }
         }	 */

	pLCD->LCDCON1 = (0)|(1<1)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_G16<<12);
	    // disable,4B_SNGL_SCAN,WDLY=8clk,WLH=8clk,	   
    pLCD->LCDCON2 = (LINEVAL)|(HOZVAL<<10)|(10<<21);  
	    //LINEBLANK=10 (without any calculation) 
	pLCD->LCDSADDR1 = (0x2<<27) | ( ((unsigned int)frameBuffer16>>22)<<21 ) | M5D((unsigned int)frameBuffer16>>1);
	    // 16-lever gray  mode , LCDBANK, LCDBASEU
	pLCD->LCDSADDR2 = M5D (((unsigned int)frameBuffer16+(SCR_XSIZE*(LINEVAL+1))/2)>>1) | (MVAL<<21) |(0<<29);//MVAL
	pLCD->LCDSADDR3 = (LCD_XSIZE/4) | ( ((SCR_XSIZE-LCD_XSIZE)/4)<<9 );
	pLCD->LCDCON1 = (1)|(1<<1)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_G16<<12);
	    // enable,4B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
	return;
}
//=====================================================================================
//函数原型:void LcdPic_Disp( unsigned int cs )
//输入参数:unsigned int cs
//返回参数:无
//功能描述:LCD显示一个图片 
//版本说明:V1.0/SAC/2008年9月7日
//更新说明:

void LcdPic_Disp( unsigned int cs )
{
	/*unsigned int *pbuffer,temp_data;
    int i,j=0;
    pbuffer =(unsigned int*) frameBuffer16;
      
    //Lcd_Clear();
    for(i = 0; i< (38400/4) ;i++)
    {
       temp_data = (plmmBitmap[i*4] << 24) + (plmmBitmap[i*4+1] << 16) + (plmmBitmap[i*4+2] << 8) +(plmmBitmap[i*4+3]);
        pbuffer[i] = temp_data;

    }*/
	unsigned int *pbuffer;
    int i,j;     
    pbuffer =(unsigned int*) frameBuffer16;
    /*
	for(i = 0; i< (38400/4) ;i++)
    {
        pbuffer[i] = cs;//((i%64)>32)?0xffffffff:0x00000;
 	} 
	*/
	switch( cs )
	{
		case	0://8×8棋盘
			for( i=0; i< LCD_YSIZE ; i++)//(LCD_YSIZE/2)
				for( j=0 ; j< LCD_XSIZE/8 ; j++)//LCD_XSIZE/2
					if( (i%8) < 4)
		 				pbuffer[i*LCD_XSIZE/8 +j] = 0xffff0000;
					else
						pbuffer[i*LCD_XSIZE/8 +j] = 0x0000ffff;
			break;
		case	1://8×8棋盘(反色)
			for( i=0; i< LCD_YSIZE ; i++)//(LCD_YSIZE/2)
				for( j=0 ; j< LCD_XSIZE/8 ; j++)//LCD_XSIZE/2
					if( (i%8) < 4)
		 				pbuffer[i*LCD_XSIZE/8 +j] = 0x0000ffff;
					else
						pbuffer[i*LCD_XSIZE/8 +j] = 0xffff0000;
			break;	
		case	2://16×16棋盘
			for( i=0; i< LCD_YSIZE ; i++)//(LCD_YSIZE/2)
				for( j=0 ; j< LCD_XSIZE/8 ; j++)//LCD_XSIZE/2
					if( (i%16) < 8 )
		 				pbuffer[i*LCD_XSIZE/8 +j] = (j%2==0)?0xffffffff:0x00000000;
					else
						pbuffer[i*LCD_XSIZE/8 +j] = (j%2==1)?0xffffffff:0x00000000;
			break;	
		case	3://16×16棋盘(反色)
			for( i=0; i< LCD_YSIZE ; i++)//(LCD_YSIZE/2)
				for( j=0 ; j< LCD_XSIZE/8 ; j++)//LCD_XSIZE/2
					if( (i%16) < 8 )
		 				pbuffer[i*LCD_XSIZE/8 +j] = (j%2==1)?0xffffffff:0x00000000;
					else
						pbuffer[i*LCD_XSIZE/8 +j] = (j%2==0)?0xffffffff:0x00000000;
			break;
		case	4://图片1
			for( i=0; i< LCD_YSIZE ; i++)//320
				for( j=0 ; j< LCD_XSIZE/8 ; j++)//240
					pbuffer[i*LCD_XSIZE/8 +j] =   (Bitmap1[(i*LCD_XSIZE/8 +j)*4] << 24) 
												+ (Bitmap1[(i*LCD_XSIZE/8 +j)*4 +1] << 16) 
												+ (Bitmap1[(i*LCD_XSIZE/8 +j)*4 +2] << 8) 
												+ (Bitmap1[(i*LCD_XSIZE/8 +j)*4 +3]);;
			break;	
		case	5://图片2
			for( i=0; i< LCD_YSIZE ; i++)//320
				for( j=0 ; j< LCD_XSIZE/8 ; j++)//240
					pbuffer[i*LCD_XSIZE/8 +j] =   (Bitmap2[(i*LCD_XSIZE/8 +j)*4] << 24) 
												+ (Bitmap2[(i*LCD_XSIZE/8 +j)*4 +1] << 16) 
												+ (Bitmap2[(i*LCD_XSIZE/8 +j)*4 +2] << 8) 
												+ (Bitmap2[(i*LCD_XSIZE/8 +j)*4 +3]);;
			break;
		case	6://图片3
			for( i=0; i< LCD_YSIZE ; i++)//320
				for( j=0 ; j< LCD_XSIZE/8 ; j++)//240
					pbuffer[i*LCD_XSIZE/8 +j] =   (Bitmap3[(i*LCD_XSIZE/8 +j)*4] << 24) 
												+ (Bitmap3[(i*LCD_XSIZE/8 +j)*4 +1] << 16) 
												+ (Bitmap3[(i*LCD_XSIZE/8 +j)*4 +2] << 8) 
												+ (Bitmap3[(i*LCD_XSIZE/8 +j)*4 +3]);;
			break;
		case	7://图片4
			for( i=0; i< LCD_YSIZE ; i++)//320
				for( j=0 ; j< LCD_XSIZE/8 ; j++)//240
					pbuffer[i*LCD_XSIZE/8 +j] =   (Bitmap4[(i*LCD_XSIZE/8 +j)*4] << 24) 
												+ (Bitmap4[(i*LCD_XSIZE/8 +j)*4 +1] << 16) 
												+ (Bitmap4[(i*LCD_XSIZE/8 +j)*4 +2] << 8) 
												+ (Bitmap4[(i*LCD_XSIZE/8 +j)*4 +3]);;
			break;	 
		case	8://图片5
			for( i=0; i< LCD_YSIZE ; i++)//320
				for( j=0 ; j< LCD_XSIZE/8 ; j++)//240
					pbuffer[i*LCD_XSIZE/8 +j] =   (Bitmap5[(i*LCD_XSIZE/8 +j)*4] << 24) 
												+ (Bitmap5[(i*LCD_XSIZE/8 +j)*4 +1] << 16) 
												+ (Bitmap5[(i*LCD_XSIZE/8 +j)*4 +2] << 8) 
												+ (Bitmap5[(i*LCD_XSIZE/8 +j)*4 +3]);;
			break;	
		case	9://图片6
			for( i=0; i< LCD_YSIZE ; i++)//320
				for( j=0 ; j< LCD_XSIZE/8 ; j++)//240
					pbuffer[i*LCD_XSIZE/8 +j] =   (gImage_bb[(i*LCD_XSIZE/8 +j)*4] << 24) 
												+ (gImage_bb[(i*LCD_XSIZE/8 +j)*4 +1] << 16) 
												+ (gImage_bb[(i*LCD_XSIZE/8 +j)*4 +2] << 8) 
												+ (gImage_bb[(i*LCD_XSIZE/8 +j)*4 +3]);;
			break;
		default:
			break;
	}
	return;	
}
//=====================================================================================
void Lcd_Clear( void )
{
    unsigned int *pbuffer;
     int i,j;
     
    pbuffer =(unsigned int*) frameBuffer16;
    for(i = 0; i< (38400/4) ;i++)
    {
        pbuffer[i] = 0xffffffff;//((i%64)>32) ? 0xffffff : 0x00000;
 	}
	return;
}

⌨️ 快捷键说明

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