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

📄 lcd.c

📁 c51和汇编混合编程
💻 C
字号:
/************************************************
*** Lcd testing source file
*** Editted by shang
*** 2005-6-15
************************************************/
#include "lcd.h"
extern fill();
extern initial();
uint8 idata prepixelx _at_  0x30;
uint8 idata prepixely _at_  0x31;
uint8 idata predata _at_  0x32;


//
//************************* SHOW_STRING **************************
//Discription:show a string on character screen start at (cx,cy)
//Input: x, y, *p
//
//
void SHOW_STRING(uint8 x,uint8 y,char *p)
{
   while(*p)
   SHOW_DATA(*p++);

}

//
//*********************** LINE ******************************
//
//Condition: x1<=x2, 0<=x1,x2<192, 0<=y1,y2<64
//Discription: draw a line from (x1,y1) to (x2,y2)
//
//

uint8 SHOW_LINE(uint8 x1, uint8 y1, uint8 x2, uint8 y2)
{
 uint8 t,col,row;
 int16 xerr=0,yerr=0;
 int16 delta_x,delta_y,distance;
 int16 incx,incy;

 delta_x=x2-x1;    /*计算坐标增量 */
 delta_y=y2-y1;
 col = x1;
 row = y1;
 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++ ) { /*画线输出 */
  PIXEL_ON(col,row);   /*画点  */
  xerr += delta_x ;
  yerr += delta_y ;

  if( xerr > distance ) {
   xerr-=distance;
   col+=incx;
  }
  if( yerr > distance ) {
   yerr-=distance;
   row+=incy;
  }
 }//end of for

return(0);
}//end of function LINE


void main(void)
{
  prepixelx = 0x00;
  prepixely = 0x00;
  predata   = 0x00;
  
    Initial();
    LcdCLR();
  
   SHOW_LINE(30,0,30,63);
    SHOW_LINE(0,63,0,0);
    SHOW_LINE(0,0,63,63);

    SHOW_LINE(150,0,150,63);
    SHOW_LINE(0,0,63,63);
    SHOW_LINE(50,63,191,0);
    SHOW_LINE(100,0,100,63);




}






















⌨️ 快捷键说明

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