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

📄 lcd.c

📁 包括DSP实验测试程序、实验示例、应用程序以及经典的DSP的C程序和汇编程序库
💻 C
📖 第 1 页 / 共 2 页
字号:
#include	"cpu_reg.h"

extern const  Uint16 LIB16x24[];
extern const  Uint16 LIB24x24[];
extern const  Uint16 LIB16x16[];
extern const  Uint16 LIB8x16[];
extern const  Uint16 LIB64[];

extern const  Uint16 *WhiteList[];
extern const  Uint16 *WordList1[];
extern const  Uint16 *WordList2[];
extern const  Uint16 *IconList[];	

void	delay(Uint16  k)
		{
			Uint16	i;
			for (i=0;i<k;i++) { i = i;  }
		}
//LCD初始化
void	lcd_init(void)
		{
			LCD_COM = 0x40;
			LCD_DAT = 0x30;
			LCD_DAT = 0x87;
			LCD_DAT = 0x07;
			LCD_DAT = 0x27;
			LCD_DAT = 0x2B;
			LCD_DAT = 0xEF;
			LCD_DAT = 0x29;
			LCD_DAT = 0x00;
			
			LCD_COM = 0x44;
			LCD_DAT = 0x00;
			LCD_DAT = 0x00;
			LCD_DAT = 0xF0;
			LCD_DAT = 0x00;
			LCD_DAT = 0x2A;
			LCD_DAT = 0xF0;
			LCD_DAT = 0x00;
			LCD_DAT = 0x54;
			LCD_DAT = 0x00;
			LCD_DAT = 0x00;
			
			LCD_COM = 0x5A;
			LCD_DAT = 0x00;
			
			LCD_COM = 0x5B;
			LCD_DAT = 0x1C;
						
			LCD_COM = 0x59;
			LCD_DAT = 0x54;
			
		}
//清除第一显示缓冲区		
void	clearscr1(void)
		{
			Uint16	i;
			LCD_COM = 0x46;
			LCD_DAT = 0x00;
			LCD_DAT = 0x00;
			LCD_COM = 0x4c;
			delay(10);
			LCD_COM = 0x42;
			delay(10);
			for (i=0;i<0x2A00;i++) LCD_DAT=0x00;
		}

//清除第二显示缓冲区		
void	clearscr2(void)
		{
			Uint16	i;
			LCD_COM = 0x46;
			LCD_DAT = 0x00;
			LCD_DAT = 0x2A;
			LCD_COM = 0x4c;
			delay(10);
			LCD_COM = 0x42;
			delay(10);
			for (i=0x2A00;i<0x5400;i++) LCD_DAT=0x00;
		}
//清除第三显示缓冲区		
void	clearscr3(void)
		{
			Uint16	i;
			LCD_COM = 0x46;
			LCD_DAT = 0x00;
			LCD_DAT = 0x54;
			LCD_COM = 0x4c;
			delay(10);
			LCD_COM = 0x42;
			delay(10);
			for (i=0x5400;i<0x8000;i++) LCD_DAT=0x00;
		}

void	clearline(Uint16 x1, Uint16 y1,Uint16  x2, Uint16  y2, Uint16 partition)
		{
			union
				{
					Uint16	total;
					struct
						{
							Uint16	high:8;
							Uint16	low:8;							
						}e;
				}d;
			Uint16	i,k;
			if (x1>x2) {i=x1;x1=x2;x2=i;}
            if (y1>y2) {i=y1;y1=y2;y2=i;}
            k = x2-x1 ;
		    while(y1<y2)
		    	{
			   		d.total=x1+y1*41;
            	    if (partition==2) d.total=d.total+0x2a00;
         			if (partition==3) d.total=d.total+0x5400;
					LCD_COM = 0x46;
					LCD_DAT = d.e.low;
					LCD_DAT = d.e.high;
					LCD_COM = 0x4c;
					LCD_COM = 0x42;
      	 			for (i=0;i<k;i++) LCD_DAT = 0x00;
                	y1++; 
           }
       }
//画点
void	dot(Uint16 x, Uint16 y, Uint16  partition)
		{
			union
				{
					Uint16	total;
					struct
						{
							Uint16	high:8;
							Uint16	low:8;							
						}e;
				}d;
			Uint16	i,j,dot1;
 	     	d.total=(y-1)*41+(x-1)/8;
    	  	dot1=(x-1)%8;
      		if (partition==2) d.total=d.total+0x2a00;
      		if (partition==3) d.total=d.total+0x5400;
      		LCD_COM = 0x46;
      		LCD_DAT = d.e.low;
      		LCD_DAT = d.e.high;
			LCD_COM = 0x43;
			i = LCD_COM;
			j = 0x8000;
			j = j>>(dot1+8);
			i = i|j;
			LCD_COM = 0x46;
			LCD_DAT = d.e.low;
			LCD_DAT = d.e.high;
			LCD_COM = 0x42;
			LCD_DAT = i;
      	}
//消点      	
void	NoDot(Uint16 x, Uint16 y, Uint16  partition)
		{
			union
				{
					Uint16	total;
					struct
						{
							Uint16	high:8;
							Uint16	low:8;							
						}e;
				}d;
			Uint16	i,j,dot1;
 	     	d.total=(y-1)*41+(x-1)/8;
    	  	dot1=(x-1)%8;
      		if (partition==2) d.total=d.total+0x2a00;
      		if (partition==3) d.total=d.total+0x5400;
      		LCD_COM = 0x46;
      		LCD_DAT = d.e.low;
      		LCD_DAT = d.e.high;
			LCD_COM = 0x43;
			i = LCD_COM;
			j = 0x8000;
			j = j>>(dot1+8);
			i = i & ~j;
			LCD_COM = 0x46;
			LCD_DAT = d.e.low;
			LCD_DAT = d.e.high;
			LCD_COM = 0x42;
			LCD_DAT = i;
      	}
//画横线(实线)    	   
void	drawabscissa(Uint16  y, Uint16 x1, Uint16 x2, Uint16  partition)
		{
			Uint16	i;
			if (x1>x2) { i=x1; x1=x2; x2=i;}     		
    		if (x2>320) x2=320;
    		if (y>240) y=240;
    		for( i=x1;i<=x2;i++) dot(i,y,partition);
   		}	
//画横线(虚线)
void	drawabscissa1(Uint16  y,Uint16  x1, Uint16  x2, Uint16  space, Uint16  partition)
		{
			Uint16	i;
			if (x1>x2) { i=x1; x1=x2; x2=i;}     		
    		if (x2>320) x2=320;
    		if (y>240) y=240;
    		for( i=x1;i<=x2;i+=space) dot(i,y,partition);
   		}	
//画竖线(实线)
void	drawordinate(Uint16 x, Uint16 y1, Uint16  y2, Uint16 partition)
		{
			Uint16	i;
			if (y1>y2) { i=y1; y1=y2; y2=i;}	
    		if (x>320) x=320;
    		if (y2>240) y2=240;
    		for(i=y1;i<=y2;i++) dot(x,i,partition);
    	}
//画竖线(虚线线)
void	drawordinate1(Uint16 x, Uint16 y1, Uint16  y2, Uint16  space,Uint16 partition)
		{
			Uint16	i;
			if (y1>y2) { i=y1; y1=y2; y2=i;}	
    		if (x>320) x=320;
    		if (y2>240) y2=240;
    		for(i=y1;i<=y2;i+=space) dot(x,i,partition);
    	}
//画矩形
void 	drawarea(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2, Uint16 partition) 
 		{     
     		drawabscissa(y1,x1,x2,partition);
     		drawordinate(x1,y1,y2,partition);
    		drawordinate(x2,y1,y2,partition);
     		drawabscissa(y2,x1,x2,partition);
 		}

//画曲线
void	liner(Uint16 x1,Uint16 y1,Uint16 x2,Uint16 y2, Uint16  Dsp,Uint16 partition)
		{
			int	dx,dy;
			int t1,t2;
			int	e,i;
			int	x,y;
			int	sx,sy;
			dx=abs(x2-x1);
			dy=abs(y2-y1);
			if (x2 > x1)
				sx=1;
		 	else
				sx=-1;
			if (y2 > y1)
				sy=1;
		 	else
				sy=-1;

			x=x1;
			y=y1;
			if (dx > dy) {
				t1=2*dy;
				t2=2*(dy-dx);
				e=2*dy-dx;
				for ( i=0;i<dx;i++)
				  {
				      if (Dsp) dot(x,y,partition);
				      else  NoDot(x,y,partition);
				      x=x+sx;
				      if ( e>=0 )
					 {
					    y=y+sy;
					    e=e+t2;
					  }
				      else
					  e=e+t1;
				    }
			     }
		       else{
			      t1=2*dx;
			      t2=2*(dx-dy);
			      e=2*dx-dy;
			      for(i=0;i<dy;i++)
				{
				    if (Dsp) dot(x,y,partition);
				    else  NoDot(x,y,partition);
				     y=y+sy;
				     if (e>=0)
					{
					   x=x+sx;
					   e=e+t2;
					 }
				      else { e=e+t1;}
				  }
			  }
		 }

//画条形图
void	DrawBar(Uint16	x, Uint16 y,Uint16  high, Uint16  partition)
		{
			union{
					Uint16	total;
					struct{
							Uint16	high:8;
							Uint16	low:8;							
						  }e;
				 }d;
			Uint16	j;
	        d.total=x+(y-high)*41;
   	        if (partition==2) d.total=d.total+0x2a00;

⌨️ 快捷键说明

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