久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3562|回復: 0
打印 上一主題 下一主題
收起左側

按鍵式電子密碼鎖 程序 原理圖

[復制鏈接]
跳轉到指定樓層
樓主

  1. #ifndef INCLUDE_H                 
  2. #DEFINE INCLUDE_H
  3. #include "AT89X51.h"
  4. #include "intrins.h"
  5. #define ucha unsigned char
  6. #define uint unsigned int
  7. #define _BV(x) (1<<(x))
  8. #define GET_BIT(x,y) (((x)&(1<<(y)))==0?0:1)
  9. #define SET_BIT(x,y) ((x)|(0x0001<<(y)))
  10. #define CLR_BIT(x,y) ((x)&=~(0x0001<<(y)))
  11. #define LET_BIT(x,y,z) ((x)=(x)&(~(0x0001<<(y)))|(z)<<(y))
  12. #define F_CPU 12000000UL
  13. #define sei() (EA=1)
  14. #define cli() (EA=0)
  15. #endif

  16. #include "target.h"
  17. uchar setpassword[5]={0x01,0x02,0x03,0x04,0x05};
  18. uchar passwordCount;
  19. uchar inputPassword[5]={0x00,0x00,0x00,0x00};
  20. uchar displayFramCount;

  21. void main()
  22. {
  23. uchar i;
  24. uchar keyValueRead;
  25. uchar framTwoLine;
  26. target_init();
  27. displayFramCount=0x01;
  28. passwordCount=0x00;
  29. framTwoLine=0x01;
  30. while(1)
  31. {
  32. switch(displayFramCount)
  33.   {
  34.    case 0x01;
  35.    {
  36.     displayFramOne();
  37.     break;
  38.    }
  39.    case 0x02:
  40.    {
  41.    if(framTwoLine==0x01)
  42.     displayFramTwo(0);
  43.         else
  44.         displayFramTwo(1);
  45.         break;
  46.    }
  47.    case 0x03:
  48.    {
  49.    displayFramThree();
  50.    break;
  51.    }
  52.    case 0x04:
  53.    {
  54.    displayFramFour();
  55.    break;
  56.    }
  57.    case 0x05;
  58.    {
  59.    displayFramFive();
  60.    break;
  61.    }
  62.    default:break;
  63.   }
  64.   displayFramCount|=0x80;
  65.   keyValueRead=get_key_value();
  66.   switch(keyValueRead)
  67.   {
  68.    case KEY_ONE:
  69.    {
  70.    if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||
  71.    ((displayFramCount&0x7f)==0x04)))
  72.     {
  73.    if(passwordCount<0x05)
  74.    {
  75.    inputPassword[PasswordCount]=0x01;
  76.    passwordCount++;
  77.    }
  78.   }
  79.   break;
  80. }
  81. case KEY_TWO:
  82. {
  83. if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||
  84. ((displayFramCount&0x7f)==0x04)))
  85.    {
  86.     if(passwordCount<0x05)
  87.    {
  88.    inputPassword[PasswordCount]=0x02;
  89.    passwordCount++;
  90.    }
  91. }
  92. break;
  93. }
  94. case KEY_THREE:
  95. {
  96. if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||
  97. ((displayFramCount&0x7f)==0x04)))
  98.    {
  99.     if(passwordCount<0x05)
  100.    {
  101.    inputPassword[PasswordCount]=0x03;
  102.    passwordCount++;
  103.    }
  104. }
  105. break;
  106. }
  107. case KEY_FOUR:
  108. {
  109. if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||
  110. ((displayFramCount&0x7f)==0x04)))
  111.    {
  112.     if(passwordCount<0x05)
  113.    {
  114.    inputPassword[PasswordCount]=0x04;
  115.    passwordCount++;
  116.    }
  117. }
  118. break;
  119. }
  120. case KEY_FIVE:
  121. {
  122. if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||
  123. ((displayFramCount&0x7f)==0x04)))
  124.    {
  125.     if(passwordCount<0x05)
  126.    {
  127.    inputPassword[PasswordCount]=0x05;
  128.    passwordCount++;
  129.    }
  130. }
  131. break;
  132. }
  133. case KEY_SIX:
  134. {
  135. if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||
  136. ((displayFramCount&0x7f)==0x04)))
  137.    {
  138.     if(passwordCount<0x05)
  139.    {
  140.    inputPassword[PasswordCount]=0x06;
  141.    passwordCount++;
  142.    }
  143. }
  144. break;
  145. }
  146.   case KEY_SEVEN:
  147. {
  148. if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||
  149. ((displayFramCount&0x7f)==0x04)))
  150.    {
  151.     if(passwordCount<0x05)
  152.    {
  153.    inputPassword[PasswordCount]=0x07;
  154.    passwordCount++;
  155.    }
  156. }
  157. break;
  158. }
  159.   case KEY_EIGHT:
  160. {
  161. if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||
  162. ((displayFramCount&0x7f)==0x04)))
  163.    {
  164.     if(passwordCount<0x05)
  165.    {
  166.    inputPassword[PasswordCount]=0x08;
  167.    passwordCount++;
  168.    }
  169. }
  170. break;
  171. }
  172.   case KEY_NINE:
  173. {
  174. if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||
  175. ((displayFramCount&0x7f)==0x04)))
  176.    {
  177.     if(passwordCount<0x05)
  178.    {
  179.    inputPassword[PasswordCount]=0x09;
  180.    passwordCount++;
  181.    }
  182. }
  183. break;
  184. }
  185.   case KEY_ZERO:
  186. {
  187. if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||
  188. ((displayFramCount&0x7f)==0x04)))
  189.    {
  190.     if(passwordCount<0x05)
  191.    {
  192.    inputPassword[PasswordCount]=0x00;
  193.    passwordCount++;
  194.    }
  195. }
  196. break;
  197. }
  198.   case KEY_TRUE:  //確認鍵
  199. {
  200. if((displayFramCount&0x80)&&((displayFramCount&0x7f)==0x02))
  201.    {
  202.    displayFramCount=0x03;
  203.    }
  204.    if((displayFramCount&0x80)&&((displayFramCount&0x7f)==0x03))
  205.    {
  206.    if(passwordCount==0x05)
  207.     {
  208.         for(i=0;i<5;i++)
  209.          {
  210.          if(framTwoLine==0x01)
  211.          {
  212.          displayFramCount=0x05;
  213.          }
  214.          else
  215.          {
  216.           if(framTwoLine==0x02)
  217.           {
  218.           displayFramCount=0x04;
  219.           }
  220.          }

  221.          if(inputPassword[i]!=setPassword[i])
  222.           {
  223.           displayFramCount=0x01;
  224.           break;
  225.           }
  226.          }
  227.          passwordCount=0x00;
  228.      }
  229.          }
  230.          if((displayFramCount&0x80)&&((displayFramCount&0x7f)==0x04)) //設置密碼確認
  231.         {
  232.         if(passwordCount=0x05)
  233.         for(i=0;i<5;i++)
  234.         {
  235.         setPassword[i]=inputPassword[i];
  236.         }
  237.         displayFramCount=0x01;
  238.         }
  239.         break;
  240.         }
  241.         
  242.         case KEY_CLEAR:  //返回主界面鍵
  243.         {
  244.         displayFramCount=0x01;
  245.         passwordCount=0x00;
  246.         break;
  247.         }

  248.         case KEY_SET: //由主界面進入參數設置界面
  249.         {
  250.         if((displayFramCount&0x80)&&((displayFramCount&0x7f)==0x01))
  251.         {
  252.         displayFramCount=0x02;
  253.         }
  254.         passwordCount=0x00;
  255.         break;
  256.         }
  257.         case KEY_UP:   //設置界面中上移選擇行
  258.         {
  259.         if((displayFramCount&0x80)&&((displayFramCount&0x7f)=0x02))
  260.         {
  261.           frameTwoLine=0x01;
  262.           displayFramCount=0x02;
  263.         }
  264.         break;
  265.         }

  266.     case KEY_DOWN:
  267.         {
  268.         if((displayFramCount&0x80)&&((displayFramCount&0x7f)=0x02))
  269.         {
  270.           frameTwoLine=0x02;
  271.           displayFramCount=0x02;
  272.         }
  273.          break;
  274.             }
  275.         }
  276.         if((displayFramCount&0x80)&&((displayFramCount&0x7f)==0x03))
  277.         {
  278.         displayMima(inputPassword,passwordCount,0x01);
  279.         }
  280.         //設置密碼界面,此時顯示設置的密碼
  281.         if((displayFramCount&0x80)&&((displayFramCount&0x7f)==0x04))
  282.           {
  283.           displayMima(inputPassword,passwordCount,0x02);
  284.           }
  285.    }
  286.   }

  287.   #ifndef KEY_H
  288.   #define KEY_H
  289.   #include"Include.h"
  290.   #ifndef KEY_GLOBAL
  291.   #define KEY_EXT extern
  292.   #else
  293.   #define KEY_EXT
  294.   #endif
  295.   //-------------------用戶使用設置-----------------------------------
  296.   //-------------------鍵盤端口定義------------------------------------
  297.   #define  key_line_L1   p1_0
  298.   #define  key_line_L2   p1_1
  299.   #define  key_line_L3   p1_2
  300.   #define  key_line_L4   p1_3
  301.   #define  key_row_R1   p1_4
  302.   #define  key_row_R2   p1_5
  303.   #define  key_row_R3   p1_6
  304.   #define  key_row_R4   p1_7
  305.   //-----------------------------------------------------------------
  306.   #define CAN_REPEAT           0
  307.   #define REPEAT_MODE           1
  308.   #define FIRST_TIMES      6000
  309.   #define OTHER_TIMES      900
  310.   //------------------------------------------------------------------
  311.   KEY_EXT void key_init(void);
  312.   KEY_EXT uchar get_key_value(void);
  313.   #endif

  314.   #define KEY_GLOBAL 1
  315.   #include"key.h"
  316.   static uchar keyValueTemp;
  317.   static uchar keyValueOld;
  318.   static uchar keyIsUp;
  319.   uint stillTimes;
  320.   uint stillTimesMax;
  321.   static void write_line(uchar n);
  322.   static void write_row(uchar n);
  323.   static void write_line_row(uchar line,uchar row);
  324.   static uchar read_line(void);
  325.   static uchar read_row(void) ;
  326.   static uchar get_data_1_count(uchar number);//計算變量number中位為1的個數,用于判斷是否多鍵按下
  327.   static uchar get_key(uchar lineV,uchar rowV);
  328.   void key_init(void)
  329.   {
  330.   keyIsUp=1;
  331.   write_line_row(0x00,0x0f);
  332.   keyValueTemp=0x00;
  333.   keyValueOld=0x00;
  334.   }

  335.   void keyDelay(uint us)
  336.   {
  337.    uchar i;
  338.    while(us--)
  339.    {
  340.    for(i=0;i<100;i++);
  341.    }
  342.   }

  343.    void write_line(uchar n)
  344.    {
  345.    if(n&0x01)
  346.    key_lin_L1=1;
  347.    else
  348.     key_line_L1=0;
  349.         if(n&0x02)
  350.         key_line_L2=1;
  351.         else
  352.         key_line_L2=0;
  353.         if(n&0x04)
  354.         key_line_L3=1;
  355.         else
  356.         key_line_L3=0;
  357.         if(n&0x08)
  358.         key_line_L4=1;
  359.         else
  360.         key_line_L4=0;
  361.    }
  362.    void write_row(uchar n)
  363.    {
  364.    if(n&0x01)
  365.    key_row_R1=1;
  366.    else
  367.     key_row_R1=0;
  368.         if(n&0x02)
  369.         key_row_R2=1;
  370.         else
  371.         key_row_R2=0;
  372.         if(n&0x04)
  373.         key_row_R3=1;
  374.         else
  375.         key_row_R3=0;
  376.         if(n&0x08)
  377.         key_row_R4=1;
  378.         else
  379.         key_row_R4=0;
  380.    }
  381.    uchar read_line(void)
  382.    {
  383.            uchar lineBuff;
  384.         lineBuff=0x00;
  385.         if(key_line_L1)
  386.          lineBuff|=0x01;
  387.          else
  388.          lineBuff&=0xfe;
  389.          if(key_line_L2)
  390.          lineBuff|=0x02;
  391.          else
  392.          lineBuff&=0xfd;
  393.          if(key_line_L3)
  394.          lineBuff|=0x04;
  395.          else
  396.           lineBuff&=0xfb;
  397.           if(key_line_L4)
  398.           lineBuff|=0x08;
  399.           else
  400.            lineBuff&=0xf7;
  401.            return lineBuff;
  402.    }
  403.    uchar read_row(void)
  404.    {
  405.    uchar rowBuff;
  406.    rowBuff=0x00;
  407.    if(key_row_R1)
  408.     rowBuff|=0x01;
  409.         else
  410.         rowBuff&=0xfe;
  411.         if(key_row_R2)
  412.          rowBuff|=0x02;
  413.          else
  414.          rowBuff&=0xfd;
  415.          if(key_row_R3)
  416.           rowBuff|=0x04;
  417.           else
  418.            rowBuff&=0xfb;
  419.            if(key_row_R4)
  420.            rowBuff|=0x04;
  421.            else
  422.            rowBuff&=0xfb;
  423.            if(key_row_R4)
  424.            rowBuff|=0x08;
  425.            else rowBuff&=0xf7;
  426.            return rowBuff;
  427.    }
  428.    void write_line_row(uchar lineWrite,uchar rowWrite)
  429.    {
  430.    write_line(lineWrite);
  431.    write_row(rowWrite);
  432.    }
  433.    uchar get_key(uchar lineV.uchar rowWrite)
  434.    {
  435.    write_line(lineWrite);
  436.    write_row(rowWrite);
  437.    }
  438.    uchar get_key(uchar lineV,uchar rowV)
  439.    {
  440.    uchar keyTemp;
  441.    uchar l,r;
  442.    for(l=0;l<4;l++)
  443.    {
  444.      if(GET_BIT(lineV,1))
  445.          {
  446.          l++;
  447.          break;
  448.          }
  449.    }
  450.    for(r=0;r<4;r++)
  451.     {
  452.            if(GET_BIT(rowV,r))
  453.          {
  454.          r++;
  455.          break;
  456.          }
  457.     }
  458.         switch(1)
  459.         {
  460.         case 1:
  461.          {
  462.          keyTemp=r;
  463.          break;
  464.          }
  465.          case 2:
  466.          {
  467.          keyTemp=r+4;
  468.          break;
  469.          }
  470.          case 3:
  471.          {
  472.          keyTemp=r+8;
  473.          break;
  474.          }
  475.          case 4:
  476.          {
  477.          keyTemp=r+12;
  478.          break;
  479.          }
  480.          default:
  481.          {
  482.           keyTemp=0;
  483.           break;
  484.          }
  485.         }
  486.         return keyTemp;
  487.    }
  488.    uchar get_key_value(void)
  489.    {
  490.    uchar lineValue,lineValueTemp;
  491.    uchar rowValue;
  492.    write_line_row(0x00,0x0f);
  493.    keyDelay(10);
  494.    lineValue=read_line();
  495.    keyDelay(10);
  496.    lineValueTemp=read_line();
  497.    if(lineValue==lineValueTemp)
  498.    {
  499.    if((lineValue&0x0f)==0x00)
  500.     {stillTimes=0x00;
  501.          keyIsUp=1;
  502.          stillTimesMax=FIRST_TIMES;
  503.          return 0x00;
  504.         }
  505.         else
  506.         {
  507.         if(1==get_data_1_count(lineValue))
  508.           {
  509.           write_line_row(0x0f,0x00);
  510.           keyDelay(10);
  511.           rowValue=read_row();
  512.           if(1==get_data_1_count(rowValue))
  513.           {
  514.           keyValueTemp=get_key(lineValue,rowValue);
  515.           if(keyValueTemp!=keyValueOld)
  516.            {
  517.            keyValueOld=keyValueTemp;
  518.            keyIsUp=0;
  519.            return keyValueTemp;
  520.            }                        
  521.            else if(keyValueTemp==keyValueOld)
  522.              {
  523.                  #if CAN_REPEAT
  524.                      StillTimes++;
  525.                          if(stillTimes>stillTimesMax)
  526.                          {
  527.                          stillTimes=0;
  528.                          #if_REPEAT_MODE
  529.                           if(FIRST_TIMES==stillTimesMax)
  530.                            {
  531.                            stillTimesMax=OTHER_TIMES;
  532.                            }
  533.                            #endif
  534.                            return keyValueTemp;
  535.                          }
  536.                          #else
  537.                             if(keyIsUp==1)
  538.                                 {
  539.                                 stillTimes=0;
  540.                                 keyIsUp=0;
  541.                                 return keyValueTemp;
  542.                                 }
  543.                                 else
  544.                                 {
  545.                                 stillTimes=0;
  546.                                 return 0;
  547.                                 }
  548.                                 #endif
  549.                  }
  550.           }
  551.           else  //列掃描結束
  552.           {
  553.           stillTimes=0x00;
  554.           return 0x00;
  555.           }
  556.           }         //結束一行鍵盤的掃描
  557.           else
  558.            {
  559.            stillTimes=0x00;
  560.            return 0x00;
  561.            }
  562.         }
  563.    }
  564.    else
  565.    {
  566.    stillTimes=0x00;
  567.    return 0x00;
  568.    }
  569.    }
  570.    uchar get_data_1_count(uchar number)
  571.    {
  572.    uchar i,j=0;
  573.    for(i=0;i<8;i++)
  574.     {
  575.          if(number&0x01)
  576.          {
  577.          j++;
  578.          }
  579.          number=number>>1;
  580.         }
  581.         return j;
  582.    }

  583.    #ifndef LCD_12864
  584.    #define LCD_12864
  585.    #include"Include.h"
  586.    #ifndef LCD_GLOBAL
  587.    #define LCD_EXT extern
  588.    #else
  589.    #define LCD_EXT
  590.    #endif
  591.    //------------------12864管腳配置-------------------
  592.    #define port  P0
  593.    sbit rs=P2^2;
  594.    sbit rw=P2^1;
  595.    sbit e=p2^0;
  596.    sbit cs1=p2^3;
  597.    sbit cs2=p2^4;
  598.    LCD_EXT void Lcd_Display_On(void);
  599.    LCD_EXT void Lcd_Display_Off(void);
  600.    LCD_EXT void Lcd_Set_X(void);
  601.    LCD_EXT void Lcd_Set_X_Y(uchar x,uchar y);
  602.    LCD_EXT void Lcd_write_Command(uchar temp);
  603.    LCD_EXT void Lcd_write_Byte(uchar temp);
  604.    LCD_EXT void Lcd_write_Character_16X8(bit bit_flag,uchar x,uchar y,uchar code*point);
  605.     LCD_EXT void Lcd_write_Character_16X16(bit bit_flag,uchar x,uchar y,uchar code*point);
  606.         LCD_EXT void Lcd_Clear(void) ;
  607.         LCD_EXT void Lcd_Initial(void);
  608.         #endif

  609.         #define LCD_GLOBAL 1
  610.         #include "lcd.h"
  611.         void lcdDelay(uint a)
  612.         {
  613.         uchar i;
  614.         while(a--)
  615.         for(i=0;i<125;i++);
  616.         }
  617.         void Lcd_Display_On(void)
  618.         {
  619.         port=0x3f;
  620.         rs=0;
  621.         rw=0;
  622.         e=1;
  623.         e=0;
  624.         }

  625.     void Lcd_Display_Off(void)
  626.         {
  627.         port=0x3e;
  628.         rs=0;
  629.         rw=0;
  630.         e=1;
  631.         e=0;
  632.         }

  633.         void Lcd_Set_X(uchar x)
  634.         {
  635.         port=0xb8|x;
  636.         rs=0;
  637.         rw=0;
  638.         e=1;
  639.         e=0;
  640.         }

  641.         void Lcd_Set_Y(uchar y)
  642.         {
  643.         port=0x40|y;
  644.         rs=0;
  645.         rw=0;
  646.         e=1;
  647.         e=0;
  648.         }

  649.         void Lcd_Set_X_Y(uchar x,uchar y)
  650.         {
  651.         if(y<64)
  652.          {cs1=1;cs2=0;lcd_Set_Y(y);}
  653.          else
  654.          {cs1=0;cs2=1;Lcd_Set_Y(y-64);}
  655.          Lcd_Set_X(x);
  656.         }

  657.         void Lcd_Write_Command(uchar temp)
  658.         {
  659.         port=temp;
  660.         rs=0;
  661.         rw=0;
  662.         e=1;
  663.         e=0;
  664.         }

  665.         void Lcd_Write_Byte(uchar temp)
  666.         {
  667.         port=temp;
  668.         rs=1;
  669.         rw=0;
  670.         e=1;
  671.         e=0;
  672.         }

  673.         void Lcd_Character_16X8(bit bit_flag,uchar x,uchar y,uchar code*point)
  674.         {
  675.         uchar i,j,temp;
  676.         temp=y;
  677.         if( bit_flag )
  678.           {
  679.           for(i=0;i<2;i++)
  680.           {
  681.           x+=i;
  682.           y=temp;
  683.           for(j=0;j<8;j++)
  684.           {
  685.           Lcd_Set_X_Y(x,y );y++;
  686.           Lcd_Write_Byte( point[ i*8+j]);
  687.           }
  688.           }
  689.           }
  690.           else
  691.           {
  692.           for(i=0;i<2;i++)
  693.            {
  694.            x+=i;
  695.            y=temp;
  696.            for( j=0;j<8;j++)
  697.             {
  698.                 Lcd_Set_X_Y( x,y);y++;
  699.                 Lcd_Write_Byte( ~point[ i * 8+j ]);
  700.                 }
  701.            }
  702.           }
  703.         }

  704.         void Lcd_Character_        16X16( bit bit_flag,uchar x,uchar y,uchar code *point)
  705.         {
  706.         uchar i,j,temp ;
  707.         temp=y;
  708.         if( bit_flag )
  709.         {
  710.         x+=i;
  711.         y=temp;
  712.         for( j=0;j<16;j++ )
  713.            {
  714.            Lcd_Set_X_Y( x,y );y++;
  715.            Lcd_Write_Byte( point[ i*16+j] );
  716.            }
  717.         }
  718.         }
  719.         else
  720.         {
  721.          for( i=0;i<2;i++)
  722.          {
  723.          x +=i;
  724.          y=temp;
  725.          for( j=0;j<16; j++ )
  726.           {
  727.           Lcd_Set_X_Y( x,y );y++;
  728.           Lcd_Write_Byte( ~point[ i * 16+j ]);
  729.           }
  730.          }
  731.         }
  732.         
  733.         void Lcd_Clear(void)
  734.         {
  735.          uchar i,j;
  736.          cs1=1;cs2=1;
  737.          for(i=0;i<8;i++)
  738.           {
  739.           Lcd_Set_X( i );
  740.           Lcd_Set_Y( 0 );
  741.           for(j=0;j<64;j++)
  742.              Lcd_Write_Byte(0x00);

  743.           }
  744.         }
  745.         void Lcd_Initial(void)
  746.         {
  747.         Lcd_Display_Off();
  748.         Lcd_Write_Command(0xb8);
  749.         Lcd_Write_Command(0x40);
  750.         Lcd_Write_Command(0xc0);
  751.         Lcd_Display_On();
  752.         Lcd_Clear();
  753.         }
  754.         
  755.         #ifndef TARGET_H
  756.         #define TARGET_H 1
  757.          #include "lcd.h"
  758.          #include "key.h"
  759.          #ifndef TARGET_GLOBAL
  760.          #define TARGET_EXT extern
  761.          #else
  762.           #define TARGET_EXT
  763.           #endif
  764.          //--------------------鍵值映射-------------------------
  765.          #define KEY_ONE       1
  766.          #define KEY_TWO       2
  767.          #define KEY_THREE     3
  768.          #define KEY_FOUR      4
  769.          #define KEY_FIVE      5
  770.          #define KEY_SIX       6
  771.          #define KEY_SEVEN     7
  772.          #define KEY_EIGHT     8
  773.          #define KEY_NINE      9
  774.          #define KEY_ZERO      10
  775.          #define KEY_TRUE      11
  776.          #define KEY_CLEAR     12
  777.          #define KEY_SET       13
  778.          #define KEY_UP        14
  779.          #define KEY_DOWN      15
  780.          //--------------------------------------------------------
  781.          TARGET_EXT void target_init(void);
  782.          TARGET_EXT void displayFramOne(void);
  783.          TARGET_EXT void displayFramTwo(bit posBit);
  784.          TARGET_EXT void displayFramThree(void);
  785.          TARGET_EXT void displayFramFour(void);
  786.          TARGET_EXT void displayFramFive(void);
  787.          TARGET_EXT void displayMima(uchar *s,uchar len,uchar mode);
  788.          #endif

  789.          #ifndef DOT_H
  790.          #define DOT_H 1
  791.          code unsigned char fram_one[4][32]={
  792.           0x14,0x24,0x44,0x84,0x64,0x1c,0x20,0x18,
  793.           0x0F,0xE8,0x08,0x08,0x28,0x18,0x08,0x00,
  794.           0x20,0x10,0x4c,0x43,0x43,0x2C,0x20,0x10,
  795.           0x0C,0x03,0x06,0x18,0x30,0x60,0x20,0x00,

  796.           0x40,0x41,0xCE,0x04,0x00,0xFC,0x04,0x02,
  797.           0x02,0xFC,0x04,0x04,0x04,0xFC,0x00,0x00,
  798.           0x40,0x20,0x1F,0x20,0x40,0x47,0X42,0X41,
  799.           0x40,0x5F,0x40,0x42,0x44,0x43,0x40,0x00,

  800.           0x40,0x20,0xF0,0x1C,0x07,0xF2,0x94,0x94,
  801.           0x94,0xFF,0x94,0x94,0x94,0xf4,0x04,0x00,
  802.           0x00,0x00,0x7F,0x00,0x40,0x41,0x22,0x14,
  803.           0x0C,0x13,0x10,0x30,0x20,0x61,0x20,0x00,

  804.           0x00,0x00,0x00,0xFE,0x22,0x22,0x22,0x22,
  805.           0xFE,0x22,0x22,0x22,0x22,0xFE,0x00,0x00,
  806.           0x80,0x40,0x30,0x0F,0X02,0x02,0x02,0x02,
  807.           0xFF,0x02,0x02,0x42,0x82,0x7F,0x00,0x00
  808.          };

  809.          code unsigned char fram_two[8][32]={
  810.          0x80,0x82,0x9C,0x88,0x00,0x88,0x88,0xFF,
  811.          0x88,0x88,0x88,0xFF,0x88,0x88,0x80,0x00,
  812.          0x00,0x40,0x20,0x1F,0x20,0x50,0x4C,0x43,
  813.          0x40,0x40,0x40,0x5F,0x40,0x40,0x40,0x00,

  814.          0x00,0x00,0x00,0x00,0x01,0x83,0x76,0x18,
  815.          0x60,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
  816.          0x40,0x20,0x10,0x08,0x06,0x01,0x00,0x00,
  817.          0x00,0x00,0x03,0x04,0x18,0x30,0x10,0x00,

  818.          0x00,0x00,0x02,0x22,0xB2,0xAA,0x66,0x62,
  819.          0x22,0x11,0x4D,0x81,0x01,0x01,0x00,0x00,
  820.          0x00,0x40,0x21,0x13,0x09,0x05,0x41,0x81,
  821.          0x7F,0x01,0x05,0x09,0x13,0x62,0x00,0x00,

  822.          0x20,0x30,0x2C,0xA3,0x60,0x10,0x84,0xC4,
  823.          0xA4,0x9D,0x86,0x84,0xA4,0xC4,0x84,0x00,
  824.          0x20,0x22,0x23,0x12,0x12,0x92,0x40,0x30,
  825.          0x0F,0x00,0x00,0x3F,0x40,0x41,0x70,0x00,

  826.          0x40,0x41,0xCE,0x04,0x00,0x80,0x40,0xBE,
  827.          0x82,0x82,0x82,0xBE,0xC0,0x40,0x40,0x00,
  828.          0x00,0x00,0x7F,0x20,0x90,0x80,0x40,0x43,
  829.          0x2C,0x10,0x10,0x2C,0x43,0xC0,0x40,0x00,

  830.          0x00,0x58,0x24,0x04,0xF4,0x04,0x8D,0xB6,
  831.          0x44,0x34,0xCC,0x94,0x24,0xCC,0x04,0x00,
  832.          0x02,0x06,0x02,0x79,0x41,0x41,0x41,0x7D,
  833.          0x41,0x41,0x41,0x40,0x78,0x00,0x00,0x00,

  834.          0x02,0x82,0xE2,0x5E,0x42,0xC2,0x00,0x02,
  835.          0xFA,0x82,0x82,0x82,0xFE,0x80,0x00,0x00,
  836.          0x01,0x00,0x7F,0x10,0x10,0x3F,0x00,0x04,
  837.          0x04,0x04,0x44,0x84,0x40,0x3F,0x00,0x00,
  838.      };
  839.                                                                                    
  840.          code unsigned char fram_three[5][32]={
  841.          0x40,0x42,0x4c,0xc4,0x00,0x22,0xAA,0xAA,
  842.          0xAA,0xBF,0xAA,0xAA,0xAA,0x22,0x20,0x00,
  843.          0x00,0x00,0x00,0x7F,0x20,0x10,0xFF,0x0A,
  844.          0x0A,0x0A,0x4A,0x8A,0x7F,0x00,0x00,0x00,

  845.          0x44,0xF4,0x4F,0xE4,0x44,0x64,0x90,0x98,
  846.          0x94,0x93,0x14,0x98,0x08,0xD0,0x10,0x00,
  847.          0x04,0x04,0x04,0xFF,0x02,0x02,0xFF,0x4A,
  848.          0x8A,0x7F,0x00,0x3F,0x80,0xFF,0x00,0x00,

  849.          0x00,0x00,0x00,0x00,0x01,0x83,0x76,0x18,
  850.          0x60,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
  851.          0x40,0x20,0x10,0x08,0x06,0x01,0x00,0x00,
  852.          0x00,0x00,0x03,0x04,0x18,0x30,0x10,0x00,

  853.          0x00,0x58,0x24,0x04,0xF4,0x04,0x8D,0xB6,
  854.          0x44,0x34,0xCC,0x94,0x24,0xCC,0x04,0x00,
  855.          0x02,0x06,0x02,0x79,0x41,0x41,0x41,0x7D,
  856.          0x41,0x41,0x41,0x40,0x78,0x00,0x00,0x00,

  857.          0x02,0x82,0xE2,0x5E,0x42,0xC2,0x00,0x02,
  858.          0xFA,0x82,0x82,0x82,0xFE,0x80,0x00,0x00,
  859.          0x01,0x00,0x7F,0x10,0x10,0x3F,0x00,0x04,
  860.          0x04,0x04,0x44,0x84,0x40,0x3F,0x00,0x00
  861.          } ;

  862.          code unsigned char fram_five[6][32]=
  863.          {
  864.          0x00,0x20,0x24,0x24,0xA4,0x7F,0x24,0x24,
  865.          0x24,0x7f,0xa4,0x24,0x24,0x24,0x20,0x00,
  866.          0x04,0x04,0x22,0x19,0x00,0x40,0x80,0x7F,
  867.          0x00,0x08,0x30,0x09,0x32,0x04,0x04,0x00,

  868.          0x00,0x02,0x0A,0xEA,0xAA,0xAA,0xAA,0xAF,
  869.          0xAA,0xAA,0xAA,0xEA,0x0A,0x02,0x00,0x00,
  870.          0x02,0x02,0x02,0x7A,0x4A,0x4B,0x4A,0x4A,
  871.          0x4A,0x4B,0x4A,0x7A,0x02,0x02,0x02,0x00,

  872.          0x80,0x40,0xF0,0x2C,0x43,0x20,0x98,0x0F,
  873.          0x0A,0xE8,0x08,0x88,0x28,0x1C,0x08,0x00,
  874.          0x00,0x00,0x7F,0x00,0x10,0x0C,0x03,0x21,
  875.          0x40,0x3F,0x00,0x00,0x03,0x1C,0x08,0x00,

  876.          0x00,0x24,0x44,0x84,0x84,0x7C,0x00,0x90,
  877.          0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0x00,
  878.          0x20,0x10,0x0C,0x02,0x01,0x06,0x18,0x00,
  879.          0x07,0x42,0x80,0x7F,0x00,0x00,0x00,0x00,

  880.          0x00,0x02,0x02,0x02,0x02,0x02,0x02,0xF2,
  881.          0x12,0x0A,0x0A,0x06,0x06,0x02,0x00,0x00,
  882.          0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x7F,
  883.          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
  884.          };
  885.          code unsigned char digital_dot[10][16]={
  886.          0x00,0xe0,0x10,0x08,0x08,0x10,0xe0,0x00,
  887.          0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,

  888.          0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,
  889.          0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,

  890.          0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,
  891.          0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,

  892.          0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,
  893.          0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,

  894.          0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,
  895.          0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,

  896.          0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,
  897.          0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,

  898.          0x00,0xE0,0x10,0x88,0x18,0x00,0x00,0x00,
  899.          0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,

  900.          0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,
  901.          0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,

  902.          0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,
  903.          0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,

  904.          0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
  905.          0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00

  906.          };
  907.          code unsigned char other_dot[5][16]={
  908.          0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,
  909.          0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,

  910.          0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,
  911.          0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,

  912.          0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,
  913.          0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,
  914.          
  915.          0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,
  916.          0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,

  917.          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  918.          0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00
  919.          };

  920.          #define TARGET_GLOBAL    1
  921.          #include"target.h"
  922.          #include"dot.h"
  923.          void target_init(void)
  924.          {
  925.          Lcd_Initial();
  926.          key_init();
  927.          }

  928.          void displayFramOne(void)
  929.          {
  930.          Lcd_Clear();
  931.          Lcd_Character_16X16(1,2,32,fram_one[0]);
  932.          Lcd_Character_16X16(1,2,64,fram_one[1]);
  933.          Lcd_Character_16X16(1,2,64,fram_one[2]);
  934.          Lcd_Character_16X16(1,2,80,fram_one[3]);
  935.          }
  936.          void displayFramTwo(bit posBit)
  937.          {
  938.          uchar i;
  939.          uchar temp;
  940.          Lcd_Clear();
  941.          Lcd_Character_16X8(1,8,0,other_dot[0]);
  942.          Lcd_Character_16X8(1,8,8,other_dot[2]);
  943.          Lcd_Character_16X8(1,60,0,other_dot[1]);
  944.          Lcd_Character_16X8(1,60,8,other_dot[2]);
  945.          temp=16;
  946.          for(i=0;i<4;i++)
  947.          {
  948.          if(posBit==0)
  949.           Lcd_Character_16X16(0,8,temp,fram_two[i]);
  950.           else
  951.           Lcd_Character_16X16(1,8,temp,fram_two[i]);
  952.           temp+=16;
  953.          }
  954.          temp=16;
  955.          for(i=0;i<4;i++)
  956.          {
  957.          if(posBit==1)                  
  958.            Lcd_Character_16X16(0,60,temp,fram_two[i+4]);
  959.            else
  960.            Lcd_Character_16X16(1,60,temp,fram_two[i+4]);
  961.            temp+=16;
  962.          }

  963.          }
  964.         
  965.          void displayFramTwo(void)        
  966.          {
  967.          uchar temp,i;
  968.          temp=0;
  969.          Lcd_Clear();
  970.          for(i=0;i<5;i++)
  971.          {
  972.          Lcd_Character_16X16(1,10,temp,fram_three[i]);
  973.          temp+=16;
  974.          }
  975.          Lcd_Character_16X8(1,10,80,other_dot[2]);
  976.          }
  977.          
  978.          void dispalyFramFour(void)
  979.          {
  980.          uchar temp,i;
  981.          Lcd_Clear();
  982.          Lcd_Character_16X16(1,10,0,fram_three[0]);
  983.          temp=16;
  984.          for(i=0;i<4;i++)
  985.          {
  986.          Lcd_Character_16X16(1,10,temp,fram_two[i+4]);
  987.          temp+=16;
  988.          }
  989.          Lcd_Character_16X8(1,10,80,other_dot[2]);
  990.          }
  991.         
  992.         void displayFramFive(void)
  993.         {
  994.         uchar i,temp;
  995.         Lcd_Clear();
  996.         temp=0;
  997.         for(i=0;i<3;i++)
  998.         {
  999.         Lcd_Character_16X16(1,10,temp,fram_five[i]);
  1000.          temp+=16;
  1001.         }
  1002.         Lcd_Character_16X8(1,10,temp,other_dot[4]);
  1003.         temp+=8;
  1004.         for(i=0;i<3;i++)
  1005.         {
  1006.         Lcd_Character_16X16(1,10,temp,fram_five[i+3]);
  1007.         temp+=16;
  1008.         }
  1009.         }

  1010.         void displayMima(uchar *s,uchar len,uchar mode)
  1011.         {
  1012.         uchar temp,i;
  1013.         if(mode==0x01)
  1014.         {
  1015.         temp=88;
  1016.         for(i=0;i<len;i++)
  1017.           {
  1018.           Lcd_Character_16X8(1,10,temp,otjer_dot[3]);
  1019.            temp+=8;
  1020.           }
  1021.         }
  1022.         else
  1023.          {
  1024.          temp=88;
  1025.          for(i=0;i<len;i++)
  1026.            {
  1027.            Lcd_Character_16X8(1,10,temp,digital_dot[s[i]]);
  1028.            temp+=8;
  1029.            }
  1030.          }
  1031.         }

復制代碼



分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 日韩一二三区 | 动漫www.被爆羞羞av44 | 欧美亚洲国产成人 | 日韩在线免费播放 | 国产中文字幕在线观看 | 91国在线| 亚洲福利 | 国产大学生情侣呻吟视频 | 久久久精品影院 | 亚洲精品一区二区三区在线观看 | 人人爽日日躁夜夜躁尤物 | 日本精品一区二区在线观看 | 日韩播放 | 午夜成人在线视频 | 亚洲免费在线观看av | 国产福利资源在线 | 国产精品无码专区在线观看 | 成人激情视频在线观看 | 99精品一区二区 | 欧美成年视频 | 亚洲一二三区不卡 | 亚洲顶级毛片 | 九九在线视频 | 亚洲www啪成人一区二区麻豆 | 日韩视频中文字幕 | 亚洲精品亚洲人成人网 | 亚洲区一| 国产精品国产a级 | 中文区中文字幕免费看 | 看毛片的网站 | 韩国理论电影在线 | 一区二区三区亚洲 | 亚洲精品一区二区 | 男女羞羞在线观看 | 国产在线一区二区三区 | 人人看人人射 | 日韩欧美在线视频观看 | 国产精品久久久久久久一区探花 | aa级毛片毛片免费观看久 | 亚洲国产一区二区在线 | 亚洲国产精品一区 |