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

📄 12864指针式时钟.txt

📁 LCM128*64指针式万年 硬件:LCM128*64 M16 DS1302 软件:WinAVR 2.0.6.1 时钟:内部4M
💻 TXT
📖 第 1 页 / 共 5 页
字号:
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,


/*--  文字:  .        11      --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,

/*--  文字:     --    12  (空白) */
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,


/*--  箭头            13    --*/
/*--  宽度x高度=8x16  --*/
0x00,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,

/*--  文字:  -        14    --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,

/*--  文字:  ,        15    --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,


/*--  箭头            16    --*/
/*--  宽度x高度=8x16  --*/
0x00,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,


/*--  箭头(向上)        17   --*/
/*--  宽度x高度=8x16  --*/
0x10,0x18,0x1C,0xFE,0xFE,0x1C,0x18,0x10,0x00,0x00,0x00,0x0F,0x0F,0x00,0x00,0x00,

/*--  文字:  !          18    --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,


/*--  文字:  >          19     --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,


/*-- 箭头(向下)        20      --*/
/*--  宽度x高度=8x16  --*/
0x00,0x00,0x00,0xFC,0xFC,0x00,0x00,0x00,0x08,0x18,0x38,0x7F,0x7F,0x38,0x18,0x08,

};

//指针时钟坐标

const unsigned char sec_x[] PROGMEM={
            32,35,38,41,43,
            45,48,50,52,54,
            56,58,59,60,60,
            60,60,60,59,58,
            56,54,52,50,48,
            45,43,41,38,35,
            32,29,26,23,21,
            19,16,14,12,10,
            8,6,5,4,4,
            4,4,4,5,6,
            8,10,12,14,16,
            19,21,23,26,29,
           };

const unsigned char sec_y[] PROGMEM={
            4,4,4,5,6,
            8,10,12,14,16,
            19,21,23,26,29,
            32,35,38,41,43,
            45,48,50,52,54,
            56,58,59,60,60,
            60,60,60,59,58,
            56,54,52,50,48,
            45,43,41,38,35,
            32,29,26,23,21,
            19,16,14,12,10,
            8,6,5,4,4,
           };
		  
const unsigned char min_x[] PROGMEM={
            32,34,36,38,40,
            41,42,44,46,48,
            49,50,51,52,53,
            54,53,52,51,50,
            49,46,45,44,42,
            40,39,38,37,35,
            32,29,27,26,25,
            24,22,20,19,18,
            15,14,13,12,11,
            10,11,12,13,14,
            15,16,18,20,22,
            23,24,26,28,30,
          };

const unsigned char min_y[] PROGMEM={
            10,10,10,11,13,
            14,15,17,19,21,
            23,24,26,28,30,
            32,34,36,38,40,
            41,44,45,46,48,
            49,50,51,52,53,
            54,53,52,51,50,
            49,48,46,45,44,
            41,40,38,36,34,
            32,30,28,26,24,
            23,21,19,17,15,
            14,13,11,10,10,
          };


const unsigned char hour_x[] PROGMEM={ 
             32,38,44,47,44,38,
             32.26,20,15,20,26,
           };


const unsigned char hour_y[] PROGMEM={ 
            17,19,26,32,38,45,
            47,45,38,32,26,19,
           };





/**************************************************************************** 
函 数 名:Delay()
功    能: 软件延时
说    明: 无
入口参数:count 
返 回 值:无
*****************************************************************************/
void Delay(unsigned int count)
 {
	 unsigned char i;                
	 while(--count != 0)
	  {            
		for(i = 0; i < 100; i++)
                  {
                     ;
                  }		
	  }                                	
 } 

/**************************************************************************** 
函 数 名:LCM12864_E()
功    能:LCM12864使能
说    明: 无
入口参数:无
返 回 值:无
*****************************************************************************/
void LCM12864_E(void)
 {
  CBI_E;
  _delay_us(10);
  SBI_E;
 }
 

/*********************************************************************************************

定义LCM12864的指令

*********************************************************************************************/
#define LCM12864_DISP_ON            0x3f          // 打开LCM12864显示
#define LCM12864_DISP_OFF           0x3e          // 关闭LCM12864显示
#define LCM12864_START_ROW          0xc0          // 显示起始行0,可以用LCM12864_START_ROW+x设置起始行。(x<64)
#define LCM12864_PAGE_START_ADDR    0xb8          // 页起始地址,可以用LCM12864_PAGE_START_ADDR+x设置当前页。(x<8)
#define LCM12864_COL_START_ADDR     0x40          // 列起始地址,可以用LCM12864_COL_START_ADDR+x设置当前列。(x<64)

//定义LCM12864的状态屏蔽码
//在BUSY和REST状态时,除读状态指令外,其他指令均不对LCM12864产生作用。
//在对LCM12864操作之前要查询BUSY状态,以确定是否可以对LCM12864进行操作。 

#define LCM12864_STATUS_BUSY        0x80          // LCM12864忙状态屏蔽码
#define LCM12864_STATUS_DISP_OFF    0x20          // LCM12864显示关闭状态屏蔽码
#define LCM12864_STATUS_REST        0x10          // LCM12864复位状态屏蔽码



/**************************************************************************** 
函 数 名:LCM12864_TestBusy()
功    能:LCM12864测忙
说    明: 无
入口参数:无
返 回 值:无
*****************************************************************************/
void LCM12864_TestBusy(void)
 {
    DDRA=0x7f;
	SBI_RW;
	CBI_RS;
	LCM12864_E();
	while(LCM12864_indatabus & LCM12864_STATUS_BUSY);
	DDRA=0xff;

 }


/**************************************************************************** 
函 数 名:LCM12864_WriteCMD()
功    能:写命令到LCM12864
说    明: 无
入口参数:LCM12864_data  欲写入命令
返 回 值:无
*****************************************************************************/
void LCM12864_WriteCMD(unsigned char LCM12864_command)		//LCM12864_command	欲写入指令	
 {	
 	LCM12864_TestBusy();
	CBI_RW; 
	CBI_RS; 
    LCM12864_databus = LCM12864_command;   
	LCM12864_E();  

 }


/**************************************************************************** 
函 数 名:LCM12864_WriteData()
功    能:写数据到LCM12864
说    明: 无
入口参数:LCM12864_data  欲写入数据	
返 回 值:无
*****************************************************************************/
void LCM12864_WriteData(unsigned char LCM12864_data)		//LCM12864_command	欲写入数据	
 {
    LCM12864_databus = LCM12864_data;
	CBI_RW; 
	SBI_RS; 
	LCM12864_E();
	
 }

/**************************************************************************** 
函 数 名:LCM12864_ReadData()
功    能:LCM12864读数据
说    明: 无
入口参数:无
返 回 值:LCM12864_data 读出数据
*****************************************************************************/
unsigned char LCM12864_ReadData(void)
 {
	unsigned char LCM12864_data;
	DDRA=0x00;
	PORTA=0xff;
	CBI_E;
	SBI_RW; 
	SBI_RS;
	Delay(10);
    SBI_E; 
	Delay(10);
	LCM12864_E();
	Delay(10);
	LCM12864_data = LCM12864_indatabus;		//读出8位数据
	LCM12864_TestBusy();					//读LCM忙
	DDRA=0xff;
	return LCM12864_data;
 }




/**************************************************************************** 
函 数 名:LCM12864_Fill_Screen()
功    能:LCM12864全屏填充数据
说    明: 无
入口参数:t,LCM12864_FillData
返 回 值:无
*****************************************************************************/
void LCM12864_Fill_Screen(	unsigned char t,						//设置写入速度
							      unsigned char LCM12864_FillData)		//欲写入的数据
  {
  	unsigned char x,y;
  	CBI_CS1;CBI_CS2;                   // 选中左右半屏
  	LCM12864_WriteCMD(LCM12864_START_ROW+0);           // 设置显示起始行为0
  	for(x=0;x<8;x++)
	 {
	  Delay(t);										   // 写入延时
          LCM12864_WriteCMD(LCM12864_PAGE_START_ADDR+x);   // 设置页地址
          LCM12864_WriteCMD(LCM12864_COL_START_ADDR);//    // 设置列地址
          for(y=0;y<64;y++) 
	   {
	     LCM12864_WriteData(LCM12864_FillData);
	   }
  	 }
  	SBI_CS1;                                    // 不选中左右半屏
  	SBI_CS2;                                   
 }


/**************************************************************************** 
函 数 名:LCM12864_Clear_Screen()
功    能:LCM12864清屏
说    明: 无
入口参数:无
返 回 值:无
*****************************************************************************/
void LCM12864_Clear_Screen(void)
 {
	LCM12864_Fill_Screen(10,0x00);			//写入0到每个显示区
 }
 
 
 

/**************************************************************************** 
函 数 名:LCM12864_Disp_Char_x_16()
功    能:在LCM12864的指定点显示点阵汉字16*16或8*16
说    明: 无
入口参数:t,b,Lcm12864_page,Lcm12864_col,x
返 回 值:无
*****************************************************************************/
void LCM12864_Disp_Char_x_16(unsigned char t,					      //设置写入速度(为1直接显示)
							  unsigned char b,					      //输入8:8*16字符,16:16*16字符
						      unsigned char LCM12864_page,		      //LCM12864的页地址(0~7)
						      unsigned char LCM12864_col,			//LCM12864的列地址(0~128)注意:右半屏起始是64 
						      unsigned char x)		//16*16点阵汉字字模(纵向取模,字节倒序)
  {
	unsigned char j=0,i=0,data;
	if(LCM12864_col < 64 )
	 {
		CBI_CS1; 
		SBI_CS2;		//判断屏幕使能
	 }
	else
	 {
		SBI_CS1; 
		CBI_CS2;
		LCM12864_col = LCM12864_col - 64;
	 }
		if(b==16)
		 {
		  for(j=0;j<2;j++)
	       {	
		    LCM12864_WriteCMD(LCM12864_PAGE_START_ADDR+LCM12864_page+j);
		    LCM12864_WriteCMD(LCM12864_COL_START_ADDR+LCM12864_col);
		   for(i=0;i<b;i++)
		    {
		     data=pgm_read_byte(hanzi+x*32+b*j+i);
			 LCM12864_WriteData(data);
			 _delay_us(t); 
		    }
		   }
		 }
		else
		 {
		  for(j=0;j<2;j++)
	       {	
		    LCM12864_WriteCMD(LCM12864_PAGE_START_ADDR+LCM12864_page+j);
		    LCM12864_WriteCMD(LCM12864_COL_START_ADDR+LCM12864_col);
		   for(i=0;i<b;i++)
		    {
		     data=pgm_read_byte(shuzi+x*16+b*j+i);
			 LCM12864_WriteData(data);
			 _delay_us(t); 
		    }
		   }
		 }
	 
  }


/******************************************************************** 
函 数 名:void LCM12864_dot()
功    能:画点
说    明:在12864屏的指定位置画一个点
          mode=0    画一个点 
          mode=1 	清除一个点
	      mode=2    反白显示一个点
入口参数:x : x座标
          y : y座标
		 mode  
返 回 值:无
***********************************************************************/

void LCM12864_dot(unsigned char x,unsigned char y,unsigned char mode)
 {
  unsigned char temp_y,read_data;
  temp_y = y%8;
  if(x<64)
   {
    CBI_CS1; SBI_CS2;		//判断屏幕位置
   }
  else 
   {
    SBI_CS1; CBI_CS2;
    x-=64;
   }

   LCM12864_WriteCMD(LCM12864_COL_START_ADDR+x);
   LCM12864_WriteCMD(LCM12864_PAGE_START_ADDR+(y/8));
   read_data=LCM12864_ReadData();
   switch(mode)
    {
     case 0:
	       read_data|=(0x01<<temp_y);
           break;
	 case 1:
	       read_data&=~(0x01<<temp_y);
           break;
	 case 2:
	       read_data^=(0x01<<temp_y);
           break;
    }
  
  LCM12864_WriteCMD(LCM12864_COL_START_ADDR+x);
  LCM12864_WriteCMD(LCM12864_PAGE_START_ADDR+(y/8));
  LCM12864_WriteData(read_data);
 }

/******************************************************************** 
函 数 名:line()
功    能:画线
说    明:在12864屏上画直线或清除
入口参数:x,y,tx,ty,xe,ye,incx,incy,dist,xerr,yerr,t
返 回 值:无
**********************************************************************/
void line(unsigned char tx,unsigned char ty,unsigned char xe,unsigned char ye,unsigned mode)
 {
  unsigned char xerr,yerr,t,dist;
  signed char incx,incy;
  

  if(xe>tx)
   incx=2;
  if(xe<tx)
   incx=0;
  if(xe==tx)
   incx=1;

  if(ye>ty)
   incy=2;
  if(ye<ty)
   incy=0;
  if(ye==ty)
   incy=1;

 if(xe>=tx&&ye<ty)            //第一象限
  {
   xe=xe-tx;
   ye=ty-ye;
  }
 else
  {
   if(xe>tx&&ye>=ty)            //第二象限
    {
     xe=xe-tx;
	 ye=ye-ty;
    }
   else
    {
	 if(tx>xe&&ye>ty)
	  {
	   xe=xe-tx;
	   ye=ye-ty;
	  }

⌨️ 快捷键说明

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