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

📄 lcd.c

📁 使用RTX-51 tiny操作系统的em12864液晶驱动程序
💻 C
字号:
/*""FILE COMMENT""*****************************************************
 * System Name : QXSP
 * File Name   : LCD_DRV.C
 * Version     : 1.00
 * Contents    : The lcd Driver for EM12864LCD 
 * Customer    : CREAT Company
 * Model       : C-100
 * Order       : 121429
 * CPU         : 89s52 (12MHz)
 * Compiler    : keill V5.10 
 * OS          : Tin
 * Programmer  : Zhaoyun
 * Note        : When reading continuously even if it exceeds the maximum address of EEPROM,
 *             : the following data is read from address 0x0000.
 *             : In this processing, judge so as not to cross a maximum address
 *             : on the side which accesses because it isn't doing this judgement.
 ***********************************************************************
 * Copyright 2004 Zhaoyun ELETECH CO., LTD.
 ***********************************************************************
 * History     :
 *             : Ver 1.00  2004.11.11  1st input
 *""FILE COMMENT END""*************************************************/

//===========================================================================
//		include
//===========================================================================
#define IN_LCD

//#define USE_RW /*when use Ad_bus,Da_buss,P3.6_WR P3.7_RD*/  
#include <reg52.h>                    /* special function register 8052       */
//#include <ABSACC.H>
#include <LCD\ZK.H>	
#include <LCD\LCD.H>	
#include <INTRINS.h>


//===========================================================================
//	Local symbol
//===========================================================================
//===========================================================================
//	Macro define
//---------------------------------------------------------------------------
// define I/O bits


//===========================================================================
// NOTE:


//===========================================================================
//	prototype
//===========================================================================
// Global Function



// Static Function






//===========================================================================
//	program
//===========================================================================
/*""FUNC COMMENT""***********************************************************
 * ID          : LCD.D.01.00
 * Overview    : 画圆。数学方程(X-Ox)^2+(Y-Oy)^2=Rx^2	
 *---------------------------------------------------------------------------
 * Include     : nothing
 *---------------------------------------------------------------------------
 * Prototype   : void circle(Uchar Ox,Uchar Oy,Uchar Rx)
 *---------------------------------------------------------------------------
 * Feature     : 
 *---------------------------------------------------------------------------
 * Argument    :Uchar Ox = 
 				Uchar Oy = 
 				Uchar Rx = 
 *---------------------------------------------------------------------------
 * ReturnValue : void
 *---------------------------------------------------------------------------
 * Input       : 
 * Output      : 
 *---------------------------------------------------------------------------
 * UseFunction : 
 *---------------------------------------------------------------------------
 * Note        : 
 *             : 
 *---------------------------------------------------------------------------
 * History     : 
 *             : Ver.1.00  2004.12.14  1st. input
 *""FUNC COMMENT END""*******************************************************/
void circle(Uchar Ox,Uchar Oy,Uchar Rx)
{
	unsigned int xx,rr,xt,yt,rs;
	yt=Rx;
	rr=Rx*Rx+1;			//补偿 1 修正方形
	rs=(yt+(yt>>1))>>1;		//(*0.75)分开1/8圆弧来画
	for (xt=0;xt<=rs;xt++)
	{
		xx=xt*xt;
		while ((yt*yt)>(rr-xx))yt--;
		col=Ox+xt;		//第一象限
		row=Oy-yt;
		point();
		col=Ox-xt;		//第二象限
		point();
		row=Oy+yt;		//第三象限
		point();
		col=Ox+xt;		//第四象限
		point();
/***************45度镜象画另一半***************/
		col=Ox+yt;		//第一象限
		row=Oy-xt;
		point();
		col=Ox-yt;		//第二象限
		point();
		row=Oy+xt;		//第三象限
		point();
		col=Ox+yt;		//第四象限
		point();
	}
}
/*""FUNC COMMENT""***********************************************************
 * ID          : LCD.D.01.00
 * Overview    : 画线。任意方向的斜线,直线数学方程 aX+bY=1
 *---------------------------------------------------------------------------
 * Include     : nothing
 *---------------------------------------------------------------------------
 * Prototype   : void Linexy(Uchar x0,Uchar y0,Uchar xt,Uchar yt)
 *---------------------------------------------------------------------------
 * Feature     : 
 *---------------------------------------------------------------------------
 * Argument    : void
 *---------------------------------------------------------------------------
 * ReturnValue : void
 *---------------------------------------------------------------------------
 * Input       : 
 * Output      : 
 *---------------------------------------------------------------------------
 * UseFunction : 
 *---------------------------------------------------------------------------
 * Note        : 
 *             : 
 *---------------------------------------------------------------------------
 * History     : 
 *             : Ver.1.00  2004.12.14  1st. input
 *""FUNC COMMENT END""*******************************************************/
void Linexy(Uchar x0,Uchar y0,Uchar xt,Uchar yt)
{
	register Uchar t;
	int xerr=0,yerr=0,delta_x,delta_y,distance;
	int incx,incy;

	delta_x=xt-x0;				/*计算坐标增量	*/
	delta_y=yt-y0;
	col = x0;
	row = y0;
	if(delta_x>0) incx=1;			/*设置单步方向	*/
	else if( delta_x==0 ) incx=0;		/*垂直线	*/
	else 
	{
		incx=-1;
		delta_x=-delta_x;
	}

	if(delta_y>0) incy=1;
	else if( delta_y==0 ) incy=0;		/*水平线	*/
	else
	{
		incy=-1;
		delta_y=-delta_y;
	}

	if( delta_x > delta_y )	distance=delta_x; /*选取基本增量坐标轴*/
	else distance=delta_y;

	for( t=0;t <= distance+1; t++ )	
	{	/*画线输出	*/
		point();			/*画点		*/
		xerr +=	delta_x	;
		yerr +=	delta_y	;
		if( xerr > distance )
		{
			xerr-=distance;
			col+=incx;
		}
		if( yerr > distance )
		{
			yerr-=distance;
			row+=incy;
		}
	}
}
/*""FUNC COMMENT""***********************************************************
 * ID          : LCD.D.01.00
 * Overview    : 画点	
 *---------------------------------------------------------------------------
 * Include     : nothing
 *---------------------------------------------------------------------------
 * Prototype   : void point(void)
 *---------------------------------------------------------------------------
 * Feature     : 
 *---------------------------------------------------------------------------
 * Argument    : void
 *---------------------------------------------------------------------------
 * ReturnValue : void
 *---------------------------------------------------------------------------
 * Input       : 
 * Output      : 
 *---------------------------------------------------------------------------
 * UseFunction : 
 *---------------------------------------------------------------------------
 * Note        : 
 *             : 
 *---------------------------------------------------------------------------
 * History     : 
 *             : Ver.1.00  2004.12.14  1st. input
 *""FUNC COMMENT END""*******************************************************/
void point(void)
{
	Uchar	x1,y1,y;
	x1=col;
	y1=row;
	row=y1>>3;				/*取Y方向分页地址	*/
	Read_lcd_data();
	y=y1&0x07;				/*字节内位置计算	*/
	Locatexy();			/*坐标定位,保留分区状态不变	*/
	Write_LCD((cbyte|(1<<y)),n_LCDaAdr,n_LCD_DATA);	/*画上屏幕*/	
	col=x1;					/*恢复xy坐标		*/
	row=y1;
}
/*""FUNC COMMENT""***********************************************************
 * ID          : LCD.D.01.00
 * Overview    : 屏幕滚动定位		
 *---------------------------------------------------------------------------
 * Include     : nothing
 *---------------------------------------------------------------------------
 * Prototype   : void Rollscreen(Uchar x)
 *---------------------------------------------------------------------------
 * Feature     : 
 *---------------------------------------------------------------------------
 * Argument    : void
 *---------------------------------------------------------------------------
 * ReturnValue : void
 *---------------------------------------------------------------------------
 * Input       : 
 * Output      : 
 *---------------------------------------------------------------------------
 * UseFunction : 
 *---------------------------------------------------------------------------
 * Note        : 
 *             : 
 *---------------------------------------------------------------------------
 * History     : 
 *             : Ver.1.00  2004.12.14  1st. input
 *""FUNC COMMENT END""*******************************************************/
void Rollscreen(Uchar x)
{
	cbyte =n_DISPFIRST|x;	/*定义显示起始行为x

⌨️ 快捷键说明

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