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

📄 lcd.c

📁 ads环境下把uc/gui移植到44b0上的源代码. 硬件使用优龙开发板.
💻 C
字号:
#include "inc\44b0x.h"
#include "DataType.h"
#include "console.h"

//液晶类型
#define LCD_BLACK
//液晶参数
#define SCR_XSIZE 	(320)  
#define SCR_YSIZE 	(240)

#define LCD_XSIZE 	(320)
#define LCD_YSIZE 	(240)

#define M5D(n) ((n) & 0x1fffff)

#ifdef LCD_BLACK
	#define ARRAY_SIZE_MONO 	(SCR_XSIZE/8*SCR_YSIZE)
	#define HOZVAL				(LCD_XSIZE/4-1)	
//	unsigned int (*VideoBuffer)[SCR_XSIZE/32];  //显存	
	#define MVAL_USED 			1
	#define CLKVAL	(20)
#endif



#define LINEVAL			(LCD_YSIZE-1)
#define MVAL			(13)

U32 VideoBuffer[SCR_YSIZE][SCR_XSIZE/32];
#define clBlack 	0x0

void _LCD_InitialReg( void)
{
#ifdef LCD_BLACK
    rLCDCON1=(0)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL<<12);
    // disable,4B_SNGL_SCAN,WDLY=16clk,WLH=16clk,
    rLCDCON2=(LINEVAL)|(HOZVAL<<10)|(10<<21);  
    // LINEBLANK=10

	rLCDSADDR1= (0x0<<27) | ( ((U32)VideoBuffer>>22)<<21 ) | M5D((U32)VideoBuffer>>1);
    // monochrome, LCDBANK, LCDBASEU
    
	rLCDSADDR2= M5D( (((U32)VideoBuffer+(SCR_XSIZE*LCD_YSIZE/8))>>1) ) | (MVAL<<21);
	// LCDBASSEL, MVAL
	rLCDSADDR3= (LCD_XSIZE/16) | ( ((SCR_XSIZE-LCD_XSIZE)/16)<<9 );
	// PAGEWIDTH, OFFSIZE (the number of halfwords)
	// No virtual screen. 
	
	rLCDCON1=(1)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL<<12);
	// enable,4B_SNGL_SCAN,WDLY=16clk,WLH=16clk,
	rPCONC= rPCONC &~ (0xff<<8);
#endif



	rPCONE = rPCONE & (~(0xf<<6)) | (0x5<<6) ;
    rPDATE = ( rPDATE | (3<<3) );    
}

void LcdInitial(void)
{
	_LCD_InitialReg();	
}

void LcdPutPixel(register int x, register int y, int c) 
{
   
   
#ifdef LCD_BLACK
   register U32 *buf = (U32*)&(VideoBuffer[(y)][(x)/32]);
    
       if (x>320 || y>240) return;   
   

   *buf=( *buf & ~(0x80000000>>((x)%32)*1) )
            | ( (c)<< ((32-1-((x)%32))*1) );
#endif

        
}

void LcdInitVideoBuf(void)
{ 
  register int x,y;
#ifdef LCD_BLACK  
  for (x=0;x<(SCR_XSIZE/32);x++)
    for (y=0;y<240;y++)
     VideoBuffer[y][x]  = clBlack;
#endif


}





⌨️ 快捷键说明

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