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

📄 adjust.c

📁 用单片机做的数字万年历
💻 C
字号:
	
#include <includes.h>	
sbit sw1=P1^5;
sbit sw2=P1^6;
sbit sw3=P1^7;

void adjustfunction(void)//时间调整都比原来少1,请思考为什么?因为是先判断,后加.

{	   extern unsigned char adjust,DisBuffer[];
     
     
if(sw1==0) 
	{	      delayX10ms(2);
  if(sw1==0)  ;
  else
 {
 if(adjust==7)   adjust=1;
  adjust=adjust+1;
 WriteWord_2(Digit6,adjust);
 }
 }
             if(sw2==0)   
	{	     delayX10ms(2);
 if(sw2==0)   ;
 else
{
 switch (adjust)
      { case 1:{  unsigned char year;
	             year=chYearChannel;
               
			   if(year>0x98)  
            {
			 year=0;
			}
               else   year=year+1;
            if((year&0x0a)>=0x0a) 
			year=(year+6);
            chYearChannel=year;
            year_l=(year&0x0f);
			year_h=((year&0xf0)>>4);
             disp_year_h;
             disp_year_l;
		 break;
                 }
       case 2:{  unsigned char month;
	             month=chMonthChannel;
               
			   if(month>0x11)  
            {
			 month=1;
			}
               else   month=month+1;
            if((month&0x0a)>=0x0a) 
			month=(month+6);
            chMonthChannel=month;
            month_l=(month&0x0f);
			month_h=((month&0xf0)>>4);
             disp_month_h;
               disp_month_l;

break;
                 }
       case 3:{ unsigned char day;
	             day=chDateChannel;
               
			   if(day>0x30)  
            {
			 day=1;
			}
               else   day=day+1;
            if((day&0x0a)>=0x0a) 
			day=(day+6);
            chDateChannel=day;
            date_l=(day&0x0f);
			date_h=((day&0xf0)>>4);
             disp_date_h;
               disp_date_l;

break;
                 }
       case 4:{

		  unsigned char week;
	             week=chDofWChannel;
               
			   if(week>0x7)  
            {
			 week=1;
			}
               else   week=week+1;
			   
            
            chDofWChannel=week;

			if(week==7)   week=8;  //星期显示调整,7显示为8即"日"
            week_l=(week&0x0f);
			
              disp_week_l;

break;
                 }
       case 5:{
               unsigned char hour;
	             hour=chHoursChannel;
               
			   if(hour>0x11)  
            {
			 hour=1;
			}
               else   hour=hour+1;
            if((hour&0x0a)>=0x0a) 
			hour=(hour+6);
            chHoursChannel=hour;
            hour=hour&0x7f;//去掉12小时制的下午的最高位
            hour_l=(hour&0x0f);
			hour_h=((hour&0xf0)>>4);
			if(hour_h==0)  hour_h=0x0f;
             disp_hour_h;
              disp_hour_l;
break;
                 }
       case 6:{
                unsigned char minu;
	             minu=chMinutesChannel;
               
			   if(minu>0x58)  
            {
			 minu=0;
			}
               else   minu=minu+1;
            if((minu&0x0a)>=0x0a) 
			minu=(minu+6);
            chMinutesChannel=minu;
            minu_l=(minu&0x0f);
			minu_h=((minu&0xf0)>>4);
             disp_minu_h;
             disp_minu_l;
break;
                 }
    default  :break;
}
}
}
if(sw3==0)  
{
delayX10ms(2);
if(sw3==0)  ;
else
{
 adjust=0;

}
}
}

⌨️ 快捷键说明

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