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

📄 key.c

📁 MSP430F1611+LCD12864_st7920+Key刚完成调试.请有需要的朋下载!
💻 C
📖 第 1 页 / 共 2 页
字号:
        }      //  break;
        
      }
      //flagA=0x00;
    }
}

void Intrrupt_Key_Pro()
{
  // Delay_Interrupt_MS(10);
   Count=K1_Count%7;   
    if(flagA&0x01)
    {
      // 得到K1_Count 的值将之放到相应用的LCD12864的显示位置.
     // Count=K1_Count%6;     //是总数年的和才会显示正确
       Delay_Interrupt_MS(10);
      flagA=0x00;
      switch(Count)
      {
      case 1:     //直接先将所有清0 再将选定的区域画面
        { 
          Lcd_Fill_Area_AllWhite();
          Fill_Area(16,16,2,16,1);   
        }         break;//黑背景
      case 2: 
        {
          Lcd_Fill_Area_AllWhite();
          Fill_Area(16,48,2,16,1);    
        }         break;
      case 3: 
        {
          Lcd_Fill_Area_AllWhite();
          Fill_Area(16,80,2,16,1);    
        }         break; 
      case 4:
        {
          Lcd_Fill_Area_AllWhite();
          Fill_Area(32,16,2,16,1);    
        }         break; 
      case 5: 
        { 
          Lcd_Fill_Area_AllWhite();
          Fill_Area(32,48,2,16,1);    
        }         break;
      case 6: 
        {
          Lcd_Fill_Area_AllWhite();
          Fill_Area(32,80,2,16,1);   
        }         break;
      default:
        {
           for(unsigned char i=0;i<0x10;i++);
            //  Lcd_Fill_Area_AllWhite();
            //  Fill_Area(16,16,2,16,1);    //默认为'年'字背景为黑  
        }      //  break;
        
      }
      //flagA=0x00;
    }
    
   // GetTime();
    
    if(flagB&0x02)
    {  Delay_Interrupt_MS(10);
      flagB=0x00;
      //得到K2_Value的真值.
      if(K2_Value)
      { 
         K2_Value=false; 
        //GetTime();
        switch(Count)
        {
        case 1:        //将值加工1后再写入到PCF8563
          {
            PCF_time[5]=PCF_time[5]+1;     //如果大于9,为10 如>19 则为20 .>29 则为30. >39 则为40 . >49 为50  >59 则为 00 
            //SetTime();
             //Time_Add_Chk(*PCF_time);
            if(PCF_time[5]==0x0A)
            {
              PCF_time[5]=0x10; 
            }
            else if(PCF_time[5]==0x1A)
            {
             PCF_time[5]=0x20;  
            }
            else if(PCF_time[5]==0x2A)
            {
              PCF_time[5]=0x30; 
            }
            else if(PCF_time[5]==0x3a)
            {
              PCF_time[5]=0x40; 
            }
            else if(PCF_time[5]==0x4A)
            {
              PCF_time[5]=0x50; 
            }
            else if(PCF_time[5]==0x5A)
            {
              PCF_time[5]=0x60; 
            }
            else if(PCF_time[5]==0x6A)
            {
              PCF_time[5]=0x70; 
            }
            else if(PCF_time[5]==0x7A)
            {
              PCF_time[5]=0x80; 
            }
            else if(PCF_time[5]==0x8A)
            {
              PCF_time[5]=0x90; 
            }
            else if(PCF_time[5]==0x9A)
            {
              PCF_time[5]=0x00; 
            }                
            SetTime();
          }   ;      break;
        case 2:         // 月
          {
            PCF_time[4]=PCF_time[4]+1;
           
            if(PCF_time[4]==0x0A)
            {
              PCF_time[4]=0x10;
            }
            else if(PCF_time[4]==0x13||PCF_time[4]==0x14||PCF_time[4]==0x15||PCF_time[4]==0x16)
            {
             PCF_time[4]=0x00; 
            }                     
            SetTime();
          } ;        break;
        case 3:     //   日
          {
            PCF_time[3]=PCF_time[3]+1;
            if(PCF_time[3]==0x0A)
            {
              PCF_time[3]=0x10;
            }
            else if(PCF_time[3]==0x1A)
            {
             PCF_time[3]=0x20; 
            }
            else if(PCF_time[3]==0x2A)
            {
              PCF_time[3]=0x30;
            }
            else if(PCF_time[3]==0x31)
            {
              PCF_time[3]=0x00;
            }
            SetTime();     
          }     ;    break;
        case 4:       //  时
          {
            PCF_time[2]=PCF_time[2]+1;
            if(PCF_time[2]==0x0A)
            {
              PCF_time[2]=0x10;
            }
            else if(PCF_time[2]==0x1A)
            {
             PCF_time[2]=0x20; 
            }
            else if(PCF_time[2]==0x24)
            {
              PCF_time[2]=0x00;
            }
            
            SetTime();
          }     ;    break;
        case 5:     //  分
          {
            PCF_time[1]=PCF_time[1]+1;
            if(PCF_time[1]==0x0A)
            {
              PCF_time[1]=0x10;
            }
            else if(PCF_time[1]==0x1A)
            {
             PCF_time[1]=0x20; 
            }
            else if(PCF_time[1]==0x2A)
            {
              PCF_time[1]=0x30;
            }
            else if(PCF_time[1]==0x3a)
            {
              PCF_time[1]=0x40; 
            }
            else if(PCF_time[1]==0x4A)
            {
              PCF_time[1]=0x50; 
            }
            else if(PCF_time[1]==0x5A)
            {
              PCF_time[1]=0x00; 
            }
            SetTime();
          }      ;   break;
        case 6:   //   秒
          {
            PCF_time[0]=PCF_time[0]+1;
            if(PCF_time[0]==0x0A)
            {
             PCF_time[0]=0x10;
            }
            else if(PCF_time[0]==0x1A)
            {
             PCF_time[0]=0x20; 
            }
            else if(PCF_time[0]==0x2A)
            {
              PCF_time[0]=0x30;
            }
            else if(PCF_time[0]==0x3a)
            {
              PCF_time[0]=0x40; 
            }
            else if(PCF_time[0]==0x4A)
            {
              PCF_time[0]=0x50; 
            }
            else if(PCF_time[0]==0x5A)
            {
              PCF_time[0]=0x00; 
            }
            SetTime();
          }      ;   break;
        default:
          {
            for(unsigned char i=0;i<0x10;i++); 
          }        // break;
                      
        }
        // K2_Value=false;  
      }
         
      //flagB=0x00;
    }
    
    if(flagC&0x04)
    {  //Delay_Interrupt_MS(10);
      flagC=0x00;
      //得到K3_Value的真值
      
      if(K3_Value)
      {
        K3_Value=false;
        switch(Count)     //值减1后再从新设置
        {
        case 1:
          {
            PCF_time[5]=PCF_time[5]-1;   //年月日的显示是倒的 如果是Count+5的话刚永远写的是"年"
            if(PCF_time[5]>=0x0a&&PCF_time[5]<=0x0f)
            {
              PCF_time[5]=0x09;
            }
            else if(PCF_time[5]>=0x1a&&PCF_time[5]<=0x1f)
            {
              PCF_time[5]=0x19; 
            }
            else if(PCF_time[5]>=0x2a&&PCF_time[5]<=0x2f)
            {
              PCF_time[5]=0x29; 
            }
            else if(PCF_time[5]>=0x3a&&PCF_time[5]<=0x3f)
            {
              PCF_time[5]=0x39;
            }
            else if(PCF_time[5]>=0x4a&&PCF_time[5]<=0x4f)
            {
              PCF_time[5]=0x49; 
            }
            else if(PCF_time[5]>=0x5a&&PCF_time[5]<=0x5f)
            {
              PCF_time[5]=0x59; 
            }
            else if(PCF_time[5]>=0x6a&&PCF_time[5]<=0x6f)
            {
              PCF_time[5]=0x69; 
            }
            else if(PCF_time[5]>=0x7a&&PCF_time[5]<=0x7f)
            {
              PCF_time[5]=0x79; 
            }
            else if(PCF_time[5]>=0x8a&&PCF_time[5]<=0x8f)
            {
              PCF_time[5]=0x80; 
            }
            else if(PCF_time[5]>=0x9a&&PCF_time[5]<=0x9f)
            {
              PCF_time[5]=0x00; 
            }
            //PCF_time[Count+5]=PCF_time[Count+5]-1;   //年月日的显示是倒的
            SetTime();
          }        break;
        case 2:
          {
            PCF_time[4]=PCF_time[4]-1;
            if(PCF_time[4]>=0x0a&&PCF_time[4]<=0x0f)
            {
              PCF_time[4]=0x09;
            }
            SetTime();
          }          break;
        case 3:
          {
            PCF_time[3]=PCF_time[3]-1;
            if(PCF_time[3]>=0x0a&&PCF_time[3]<=0x0f)
            {
              PCF_time[3]=0x09;
            }
            else if(PCF_time[3]>=0x1a&&PCF_time[3]<=0x1f)
            {
              PCF_time[3]=0x19; 
            }
            else if(PCF_time[3]>=0x2a&&PCF_time[3]<=0x2f)
            {
              PCF_time[3]=0x29; 
            }
            SetTime();
          }          break;
        case 4:
          {
            PCF_time[2]=PCF_time[2]-1;
            if(PCF_time[2]>=0x0a&&PCF_time[2]<=0x0f)
            {
              PCF_time[2]=0x09;
            }
            else if(PCF_time[2]>=0x1a&&PCF_time[2]<=0x1f)
            {
              PCF_time[2]=0x19; 
            }
            
            SetTime();
          }          break;
        case 5:    // 分
          {
            PCF_time[1]=PCF_time[1]-1;
            if(PCF_time[1]>=0x0a&&PCF_time[1]<=0x0f)
            {
              PCF_time[1]=0x09;
            }
            else if(PCF_time[1]>=0x1a&&PCF_time[1]<=0x1f)
            {
              PCF_time[1]=0x19; 
            }
            else if(PCF_time[1]>=0x2a&&PCF_time[1]<=0x2f)
            {
              PCF_time[1]=0x29; 
            }
            else if(PCF_time[1]>=0x3a&&PCF_time[1]<=0x3f)
            {
              PCF_time[1]=0x39;
            }
            else if(PCF_time[1]>=0x4a&&PCF_time[1]<=0x4f)
            {
              PCF_time[1]=0x49; 
            }
            else if(PCF_time[1]>=0x5a&&PCF_time[1]<=0x5f)
            {
              PCF_time[1]=0x59; 
            }
            SetTime();
          }          break;
        case 6:
          {
            PCF_time[0]=PCF_time[0]-1;
            if(PCF_time[0]>=0x0a&&PCF_time[0]<=0x0f)
            {
              PCF_time[0]=0x09;
            }
            else if(PCF_time[0]>=0x1a&&PCF_time[0]<=0x1f)
            {
              PCF_time[0]=0x19; 
            }
            else if(PCF_time[0]>=0x2a&&PCF_time[0]<=0x2f)
            {
              PCF_time[0]=0x29; 
            }
            else if(PCF_time[0]>=0x3a&&PCF_time[0]<=0x3f)
            {
              PCF_time[0]=0x39;
            }
            else if(PCF_time[0]>=0x4a&&PCF_time[0]<=0x4f)
            {
              PCF_time[0]=0x49; 
            }
            else if(PCF_time[0]>=0x5a&&PCF_time[0]<=0x5f)
            {
              PCF_time[0]=0x59; 
            }
            SetTime();
          }           break;    
        default :
          {
            for(unsigned char t=0;t<0x10;t--);
          }         // break;
                    
        }        
       // K3_Value=false;     // 直接从default 跳出从而没有将K3_Value赋值
      }
      
      //flagC=0x00;
    }
    
    if(flagD&0x08)
    {   Delay_Interrupt_MS(10);
      //WriteCommand(0x90);
      //for(i=0;i<16;i++) WriteData(Data4[i]);
      //得到K4_Value的真值   确认后将所有黑幕 清除
      if(K4_Value)
      {
       Lcd_Fill_Area_AllWhite();
        //将所有的整数值及布尔值 清0及
       K1_Count=0;
       K2_Value=false;
       K3_Value=false;
       K4_Value=false;
      }
      flagD=0x00;
    }
}

#pragma vector=PORT1_VECTOR
__interrupt void PORT1_ISR(void)
{
  Delay_Interrupt_MS(100);     // 值太少会产生跳变.使得值不能确定.
 if((P1IFG&BIT4))       //向下
 {
   flagA=0x01;
   //flagC=0x00;
   K1_Count++;
   
   P1IFG&=~BIT4;
   
   //Intrrupt_K1_Count();
   
   
 }
 else if((P1IFG&BIT5))  //增大  
 {
   flagB=0x02;
   //flagD=0x00;
   K2_Value=true;
   
    P1IFG&=~BIT5;
   
   //Intrrupt_K2_Value();
   
  
 }
 else if(P1IFG&BIT6)   //减少
 {
   flagC=0x04;
   //flagA=0x00;
   K3_Value=true;
   
   P1IFG&=~BIT6;
   
   //Intrrupt_K3_Value();
   
   
 }
 else if(P1IFG&BIT7)   // 确认.
 {
   flagD=0x08;
   //flagB=0x00;
   K4_Value=true;
   
   P1IFG&=~BIT7;
   
   //Intrrupt_K4_Value();
   
   
 }
 else
 {
   P4OUT &=~BIT1;
 }  
  
}


⌨️ 快捷键说明

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