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

📄 main_1.c

📁 93cxx读写驱动程序.51单片机的驱动程序
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "zhaobin.h"
unsigned char xdata  address_377 _at_ 0x07ff;

void delay ( unsigned char dk)
{
 unsigned char tt;
 for (tt=0;tt<dk;tt++)
 { _nop_ ();  _nop_ ();
 }
}

void delay_long ( unsigned char sb,unsigned int nba)
{
 unsigned char qq;
 unsigned int  tm;
 for (qq=0;qq<sb;qq++)
  {
    for (tm=0;tm<nba;tm++)
     { _nop_ ();  _nop_ ();  _nop_ ();  _nop_ ();  _nop_ ();  _nop_ ();  _nop_ ();  _nop_ (); }
  }
}




unsigned char read_key (void)
{
 unsigned char temp,temp1;
 temp=1;  temp1=0;
  if (key1!=1)  
  {
   delay (50);
   for (temp1=1;temp1<9;temp1++)
   {
    address_377=temp;  _nop_ ();
	_nop_ ();  _nop_ ();  _nop_ ();  _nop_ ();
    if (key1==1) 
	{ address_377=0;   _nop_ ();   _nop_ ();   _nop_ ();
      while (~key1);  delay (100);  return (temp1);
	 } 
	temp=temp<<1;
   }
  }

  if (key2!=1)
  {
   delay (50);
   for (temp1=1+8;temp1<9+8;temp1++)
   {
    address_377=temp;  _nop_ ();
	_nop_ ();  _nop_ ();  _nop_ ();  _nop_ ();
    if (key2==1) 
	{ address_377=0;   _nop_ ();   _nop_ ();   _nop_ ();
      while (~key2);  delay (100);  return (temp1);
	 } 
	temp=temp<<1;
   }
  }
  return (temp1);
}

unsigned char sec_10 (void)
{ unsigned char temp;
  temp=(read_sec ()&0x70)*10;
  temp=(read_sec ()&0x0f)+temp;
  return (temp);
}

unsigned char min_10 (void)
{ unsigned char temp;
  temp=(read_min ()&0x70)*10;
  temp=(read_min ()&0x0f)+temp;
  return (temp);
}

unsigned char hour_10 (void)
{ unsigned char temp;
  temp=(read_hour ()&0x30)*10;
  temp=(read_hour ()&0x0f)+temp;
  return (temp);
}





void main (void)
{
  unsigned char temp_sec,temp_min,temp_hour;
  unsigned char temp1,temp2,temp4,temp5,temp7,temp8;
  unsigned char clock_1,clock_2,clock_4,clock_5,clock_7,clock_8;
  unsigned char dbd,clock_hour,clock_min;
  unsigned char key14,m2,temp,temp11;
  bit flage_clock;
  flage_clock=0;
  clock_hour=clock_min=clock_1=clock_2=clock_4=clock_5=clock_7=clock_8=dbd=key14=m2=0;
  _nop_ ();
  _nop_ ();
  speak0=0;  speak1=0;  speak2=0;
 init_max7219 ();
 init_ht1380 ();
   _nop_ ();
  address_377=0;
 write_max7219 (0x030a);
 write_max7219 (0x060a);
 display_sec ();
 display_min ();
 display_hour ();
 _nop_ ();

 temp_sec=sec_10 ();
 temp_min=min_10 ();
 temp_hour=hour_10 ();




 while (1)
{
main_loop:
speak0=0;  speak1=0;  speak2=0;
 key14=0;
 _nop_ ();
 /*
 if (temp_sec!=read_sec ())  display_sec ();
 if (temp_min!=read_min ())  display_min ();
 if (temp_hour!=read_hour ()) display_hour ();
 temp_sec=read_sec ();
 temp_min=read_min ();
 temp_hour=read_hour ();
 */
 display_sec ();
 display_min ();
 display_hour ();
 address_377=0;
 _nop_ ();  _nop_ ();  _nop_ ();
 dbd=0;
 dbd=read_key ();
 if (dbd!=0)
  { 
     address_377=0;   _nop_ ();   _nop_ ();   _nop_ ();
	 temp_sec=sec_10 ()+3;
     if ((dbd>=11)&&(dbd<=16))   
	   {
	     if (dbd==14)                                               /////////看日期和星期
		   { 
		     while (1)
			 {
		      display_year ();  display_month ();  display_date ();  temp=sec_10 ();  
			  delay (100);

 			  if (read_key ()==14)                             //////////看星期  
			     { display_day ();  temp_sec=sec_10 ()+3;   temp=sec_10 ();  
			        while (1)
				    { temp=sec_10 ();   delay (100);
					  if (temp>temp_sec)  goto main_loop;
					  if (read_key ()==14)                     ///////////看闹钟
					    { temp11=clock_hour&0x0f;
   						  write_max7219 (256*2|temp11);
  						  temp11=clock_hour&0x70;
  						  temp11=temp11>>4;
  						  temp11=0x0f&temp11;
   						  write_max7219 (256*1|temp11);

						  temp11=clock_min&0x0f;
   						  write_max7219 (256*5|temp11);
  						  temp11=clock_min&0x70;
  						  temp11=temp11>>4;
  						  temp11=0x0f&temp11;
   						  write_max7219 (256*4|temp11);
						  if (flage_clock)  { write_max7219 (0x0700);    write_max7219 (0x080e); }
						  else { write_max7219 (0x070b);    write_max7219 (0x080b); }
						 temp_sec=sec_10 ()+3;
						  while (1)
						   { temp=sec_10 ();  delay (100);
						     if (temp>temp_sec)  goto main_loop;
							 if (read_key ()==14)  goto main_loop;
						   }
				         }
    		      }   }
				 
		      if (temp>temp_sec)  goto main_loop;
		     }
		    }



//////////////////////////////////////////////////////////////////////////////////////////////////////////////





		 if (dbd==13)                                       /////////闹铃是否打开
		   {  flage_clock=~flage_clock;   
              if (flage_clock)
   		        { write_max7219 (0x0100);  write_max7219 (0x020e);  write_max7219 (0x030a);  write_max7219 (0x040a);  
				  write_max7219 (0x050a);  write_max7219 (0x060a);  write_max7219 (0x070a);  write_max7219 (0x080a);  
				}
			  else
			    { write_max7219 (0x010b);  write_max7219 (0x020b);  write_max7219 (0x030e);  write_max7219 (0x040a);  
				  write_max7219 (0x050a);  write_max7219 (0x060a);  write_max7219 (0x070a);  write_max7219 (0x080a);  
				}
			  temp=sec_10 ();   temp=temp+2;   delay (100);
  			  while (1)
			   {  temp_sec=sec_10 ();    delay (100);
			      if (temp_sec>temp) 
				   { write_max7219 (0x030a);  goto main_loop; }
				  _nop_ ();  _nop_ ();
				  if (read_key ()==14)  
                   { write_max7219 (0x030a);  goto main_loop; }
				  _nop_ ();  _nop_ ();

			  }
		  }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////








		 if (dbd==11)                                      ///////////////设置时间
           { 
		     temp_sec=read_sec ();    temp_min=read_min ();    temp_hour=read_hour ();
		     write_max7219 (0x0100);  write_max7219 (0x0200);  write_max7219 (0x0400);
 			 write_max7219 (0x0500);  write_max7219 (0x0700);  write_max7219 (0x0800);
			 while (1)
			   { dbd=read_key ();
			     if ((dbd==1)||(dbd==11)||(dbd==2)||(dbd==6))   break;
			   }
		      if (dbd==11)  goto main_loop;
              switch (dbd)
			   {
			    case 1:  temp1=1;  break;
				case 2:  temp1=2;  break;
				case 6:  temp1=0;  break;
				default:  _nop_ (); break;
			   }
			   write_max7219 (256*1+temp1);
			 while (1)
			   { dbd=read_key ();
			     if ((dbd>=1)&&(dbd<=11))   break;
			   }
		      if (dbd==11)  goto main_loop;
              switch (dbd)
			   {
			    case 1:  temp2=1;  break;
				case 2:  temp2=2;  break;
				case 3:  temp2=3;  break;
				case 4:  temp2=4;  break;
				case 5:  temp2=5;  break;
				case 6:  temp2=0;  break;
				case 7:  temp2=9;  break;
				case 8:  temp2=8;  break;
				case 9:  temp2=6;  break;
				case 10:  temp2=7;  break;
				default:  _nop_ (); break;
			   }
			   write_max7219 (256*2+temp2);
			   temp1=temp1<<4;  temp1=temp1|temp2;
			   write_time (temp1*256+0x84);

             ///////////////////////////////////////////////////  hour
			 while (1)
			   { dbd=read_key ();
			     if ((dbd==1)||(dbd==11)||(dbd==2)||(dbd==3)||(dbd==4)||(dbd==5)||(dbd==6))   break;
			   }
		      if (dbd==11)  goto main_loop;
              switch (dbd)
			   {
			    case 1:  temp4=1;  break;
				case 2:  temp4=2;  break;
				case 3:  temp4=3;  break;
				case 4:  temp4=4;  break;
				case 5:  temp4=5;  break;
				case 6:  temp4=0;  break;
				default:  _nop_ (); break;
			   }
			   write_max7219 (256*4+temp4);
            while (1)
			   { dbd=read_key ();
			     if ((dbd>=1)&&(dbd<=11))   break;
			   }
		      if (dbd==11)  goto main_loop;
              switch (dbd)
			   {
			    case 1:  temp5=1;  break;
				case 2:  temp5=2;  break;
				case 3:  temp5=3;  break;
				case 4:  temp5=4;  break;
				case 5:  temp5=5;  break;
				case 6:  temp5=0;  break;
				case 7:  temp5=9;  break;
				case 8:  temp5=8;  break;
				case 9:  temp5=6;  break;
				case 10:  temp5=7;  break;
				default:  _nop_ (); break;
			   }
			   write_max7219 (256*5+temp5);
			   temp4=temp4<<4;  temp4=temp4|temp5;
			   write_time (temp4*256+0x82);
                //////////////////////////////    /               ///min

            while (1)
			   { dbd=read_key ();
			     if ((dbd==1)||(dbd==11)||(dbd==2)||(dbd==3)||(dbd==4)||(dbd==5)||(dbd==6))   break;
			   }
		      if (dbd==11)  goto main_loop;
              switch (dbd)
			   {
			    case 1:  temp7=1;  break;
				case 2:  temp7=2;  break;
				case 3:  temp7=3;  break;
				case 4:  temp7=4;  break;
				case 5:  temp7=5;  break;
				case 6:  temp7=0;  break;
				default:  _nop_ (); break;
			   }
			   write_max7219 (256*7+temp7);
            while (1)
			   { dbd=read_key ();
			     if ((dbd>=1)&&(dbd<=11))   break;
			   }
		      if (dbd==11)  goto main_loop;
              switch (dbd)
			   {
			    case 1:  temp8=1;  break;
				case 2:  temp8=2;  break;
				case 3:  temp8=3;  break;
				case 4:  temp8=4;  break;
				case 5:  temp8=5;  break;
				case 6:  temp8=0;  break;
				case 7:  temp8=9;  break;
				case 8:  temp8=8;  break;

⌨️ 快捷键说明

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