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

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 9294|回復(fù): 10
打印 上一主題 下一主題
收起左側(cè)

單片機(jī)+直流電機(jī)測速+160128中文液晶顯示 帶proteus仿真及源程序

  [復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主




仿真工程文件及所有完整程序等資料下載地址:
http://www.zg4o1577.cn/bbs/dpj-56304-1.html

源程序:
  1. #include <showfun.h>
  2. #include <stdio.h>

  3. extern char fnLCMInit(); // LCM 初始化
  4. extern void at(unsigned char x,unsigned char y);/*設(shè)定文本x,y值*/
  5. extern void cls();         // 清屏
  6. extern void charout(unsigned char *str); //ASCII(8*8) 顯示函數(shù)
  7. extern void fnSetPos(unsigned char urow, unsigned char  ucol);        // 設(shè)置當(dāng)前地址
  8. extern uchar dprintf(uchar x,uchar y,char *fmt);// ASCII(8*16) 及 漢字(16*16) 顯示函數(shù)
  9. extern uchar fnPR12(uchar uCmd); // 寫無參數(shù)的指令
  10. extern uchar fnPR13(uchar uData); // 寫數(shù)據(jù)
  11. extern unsigned int Adc0832(unsigned char channel);
  12. extern void Line( unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, bit Mode);
  13. extern void Pixel(unsigned char PointX,unsigned char PointY, bit Mode);



  14. uchar dsp[10]={0,0,0,0,0,0,0,0,0,0,};
  15. char abc[3]={0,0,0,};
  16. uchar key=0;
  17. uint a=100;
  18. uchar n=5;
  19. uchar count=1;
  20. uint k1=0;

  21. uchar GeyKey();
  22. void delay(uchar i);
  23. void control();


  24. main()
  25. {  
  26.      
  27.          fnLCMInit();
  28.         fnSetPos(0,0);
  29.         dprintf(0,0,"直流電機(jī)加-減速及測速系統(tǒng)");
  30.         dprintf(0,12,"鍵盤+:步長加速");
  31.         dprintf(0,24,"鍵盤-:步長減速");
  32.         dprintf(0,36,"鍵盤=:順時(shí)針轉(zhuǎn)");
  33.         dprintf(0,48,"鍵盤on/c:逆時(shí)針轉(zhuǎn)");
  34.      
  35.      dprintf(0,72,"方向:");
  36.            dprintf(0,84,"轉(zhuǎn)速:");  
  37.    
  38.          P1_1=0;
  39.      TMOD=0x15;
  40.          TH1=0x3c;
  41.          TL1=0xb0;
  42.      TH0=0x00;
  43.          TL0=0x00;
  44.          ET0=1;
  45.          ET1=1;
  46.          TR0=1;
  47.          TR1=1;
  48.    
  49.     while(1)
  50.         {  key=GeyKey();
  51.       switch(key)
  52.        {   case '1': {          a=10;
  53.                                     //sprintf(abc,"%3.2f",a/255.0);
  54.                                         dprintf(0,96,"  5    r/min");   
  55.                                 //dprintf(0,96,abc);  
  56.                                 dprintf(60,96,"r/min");
  57.                                     break;      }
  58.                case '2': {          a=25;dprintf(0,96,"  25    r/min");    break;      }
  59.                    case '3': {          a=40; dprintf(0,96," 40    r/min");   break;      }
  60.                    case '4': {          a=55; dprintf(0,96," 60    r/min");   break;      }
  61.                    case '5': {          a=70; dprintf(0,96," 80    r/min");   break;      }
  62.                    case '6': {          a=90; dprintf(0,96,"100    r/min");   break;      }
  63.                    case '7': {          a=110; dprintf(0,96,"120    r/min");   break;      }
  64.                    case '8': {          a=130; dprintf(0,96,"135    r/min");   break;      }
  65.                    case '9': {          a=150; dprintf(0,96,"150    r/min");   break;      }
  66.                case '+': {          dprintf(0,72,"方向: 順時(shí)針");
  67.                                     control();
  68.                                                                 break;
  69.                                                 }
  70.            case '-': {         P1_0=0;
  71.                                         dprintf(0,72,"方向: 逆時(shí)針");
  72.                                          control();
  73.                                         break;
  74.                                         }
  75.            case '=': {P1_0=1;dprintf(0,72,"方向: 順時(shí)針");break;}
  76.            case 'c': {P1_0=0;dprintf(0,72,"方向: 逆時(shí)針");break;}
  77.            case '/': {dprintf(0,72,"方向: 順時(shí)針");
  78.                                     control();}
  79.                    default:  break;
  80.         }
  81.     }
  82. }


  83. uchar GeyKey()
  84. {
  85.          P1_4=0;
  86.          P1_5=1;
  87.          P1_6=1;
  88.          P1_7=1;
  89.         P3_0=1;
  90.         P3_1=1;
  91.         P3_2=1;
  92.     P3_3=1;
  93.         _nop_();_nop_();
  94.         if(!P3_0)return '7';
  95.          if(!P3_1)return '8';
  96.          if(!P3_2)return '9';
  97.     if(!P3_3)return '/';
  98.          P1_4=1;
  99.          P1_5=0;
  100.          P1_6=1;
  101.          P1_7=1;
  102.         _nop_();_nop_();
  103.         if(!P3_0)return '4';
  104.          if(!P3_1)return '5';
  105.          if(!P3_2)return '6';
  106.     if(!P3_3)return '*';

  107.          P1_4=1;
  108.          P1_5=1;
  109.          P1_6=0;
  110.          P1_7=1;
  111.         _nop_();_nop_();
  112.         if(!P3_0)return '1';
  113.          if(!P3_1)return '2';
  114.          if(!P3_2)return '3';
  115.     if(!P3_3)return '-';


  116.          P1_4=1;
  117.          P1_5=1;
  118.          P1_6=1;
  119.          P1_7=0;
  120.         _nop_();_nop_();
  121.         if(!P3_0)return 'c';
  122.          if(!P3_1)return '0';
  123.          if(!P3_2)return '=';
  124.     if(!P3_3)return '+';

  125.         return 0;
  126. }


  127. void delay(uchar i)
  128. {  uchar j,k;
  129.     for(;i>0;i--)
  130.     for(j=15;j>0;j--)
  131.     for(k=11;k>0;k--);
  132. }
  133.         
  134.         
  135.         
  136. void time()interrupt 3
  137. {   
  138.      TR1=0;
  139.      count++;
  140.      k1+=TL0;
  141.          if(count==51)
  142.          {     
  143.               sprintf(dsp,"%3d",k1);
  144.                   dprintf(0,108,dsp);   
  145.           dprintf(60,108,"r/min");   
  146.                   count=1;
  147.           k1=0;
  148.       }
  149.           TH1=0x3c;
  150.           TL1=0xb0;
  151.           TH0=0x00;
  152.           TL0=0x00;
  153.           TR1=1;

  154. }

  155. void control()
  156. {                           
  157.        EA=1;
  158.            while(1)
  159.            {    if(a>=150)
  160.                a=150;
  161.                         if(a<=10)
  162.                             a=10;
  163.                          P1_1=0;
  164.                          delay(160-a);
  165.                          P1_1=1;
  166.                          delay(a);
  167.                          key=GeyKey();
  168.                          if(key=='-') a-=n;
  169.                          else
  170.                            if(key=='+') a+=n;
  171.                          else
  172.                            if(key=='=')
  173.                            {  P1_0=1;
  174.                                    dprintf(0,72,"方向: 順時(shí)針");
  175.                          }
  176.                          else
  177.                          if(key=='c')
  178.                          {  P1_0=0;
  179.                            dprintf(0,72,"方向: 逆時(shí)針");
  180.                          }
  181.                          else  
  182.                           if(key=='*')
  183.                           {   P1_1=0;
  184.                               break;
  185.                           }
  186.                           else
  187.                          if(key!=0)
  188.                            break;
  189.                          }
  190.                  EA=0;
  191. }

復(fù)制代碼



  1. /************************************************************************************/
  2. /* LCM 240128 顯示程序 */
  3. /* MCU 型號(hào): Winbond W78E58-24 */
  4. /* 時(shí)鐘頻率: 22.1184 MHz */
  5. /* 接口方式: 直接接口(掛總線) */
  6. /* 開發(fā)環(huán)境: Keil C51 V6.14 */
  7. /* 開發(fā)日期: .06.12- */
  8. /* 程序編寫: Youth */
  9. /************************************************************************************/

  10. #include <stdarg.h>
  11. #include <stdio.h>
  12. #include <math.h>
  13. #include <intrins.h>
  14. #include <absacc.h>
  15. #include <string.h>
  16. #include <showfun.h>



  17. code uchar const uPowArr[] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};

  18. // ASCII 字模寬度及高度定義
  19. #define ASC_CHR_WIDTH 8
  20. #define ASC_CHR_HEIGHT 12
  21. #define HZ_CHR_HEIGHT 12
  22. #define HZ_CHR_WIDTH 12

  23. char code MSK1[]={0x00,0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff};
  24. char code MSK2[]={0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff};
  25. char code ASC_MSK[96*12] = {
  26. // Terminal9; 此字體下對(duì)應(yīng)的點(diǎn)陣為:寬x高=8x12
  27. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff, // < 0x20時(shí),打印此字
  28. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// ' '
  29. 0x00,0x30,0x78,0x78,0x78,0x30,0x30,0x00,0x30,0x30,0x00,0x00,// '!'
  30. 0x00,0x66,0x66,0x66,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// '"'
  31. 0x00,0x6c,0x6c,0xfe,0x6c,0x6c,0x6c,0xfe,0x6c,0x6c,0x00,0x00,// '#'
  32. 0x30,0x30,0x7c,0xc0,0xc0,0x78,0x0c,0x0c,0xf8,0x30,0x30,0x00,// '



  33. 0x00,0x00,0x00,0xc4,0xcc,0x18,0x30,0x60,0xcc,0x8c,0x00,0x00,// '%'
  34. 0x00,0x70,0xd8,0xd8,0x70,0xfa,0xde,0xcc,0xdc,0x76,0x00,0x00,// '&'
  35. 0x00,0x30,0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// '''
  36. 0x00,0x0c,0x18,0x30,0x60,0x60,0x60,0x30,0x18,0x0c,0x00,0x00,// '('
  37. 0x00,0x60,0x30,0x18,0x0c,0x0c,0x0c,0x18,0x30,0x60,0x00,0x00,// ')'
  38. 0x00,0x00,0x00,0x66,0x3c,0xff,0x3c,0x66,0x00,0x00,0x00,0x00,// '*'
  39. 0x00,0x00,0x00,0x18,0x18,0x7e,0x18,0x18,0x00,0x00,0x00,0x00,// '+'
  40. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x60,0x00,// ','
  41. 0x00,0x00,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,// '-'
  42. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x00,0x00,// '.'
  43. 0x00,0x00,0x02,0x06,0x0c,0x18,0x30,0x60,0xc0,0x80,0x00,0x00,// '/'
  44. 0x00,0x7c,0xc6,0xce,0xde,0xd6,0xf6,0xe6,0xc6,0x7c,0x00,0x00,// '0'
  45. 0x00,0x10,0x30,0xf0,0x30,0x30,0x30,0x30,0x30,0xfc,0x00,0x00,// '1'
  46. 0x00,0x78,0xcc,0xcc,0x0c,0x18,0x30,0x60,0xcc,0xfc,0x00,0x00,// '2'
  47. 0x00,0x78,0xcc,0x0c,0x0c,0x38,0x0c,0x0c,0xcc,0x78,0x00,0x00,// '3'
  48. 0x00,0x0c,0x1c,0x3c,0x6c,0xcc,0xfe,0x0c,0x0c,0x1e,0x00,0x00,// '4'
  49. 0x00,0xfc,0xc0,0xc0,0xc0,0xf8,0x0c,0x0c,0xcc,0x78,0x00,0x00,// '5'
  50. 0x00,0x38,0x60,0xc0,0xc0,0xf8,0xcc,0xcc,0xcc,0x78,0x00,0x00,// '6'
  51. 0x00,0xfe,0xc6,0xc6,0x06,0x0c,0x18,0x30,0x30,0x30,0x00,0x00,// '7'
  52. 0x00,0x78,0xcc,0xcc,0xec,0x78,0xdc,0xcc,0xcc,0x78,0x00,0x00,// '8'
  53. 0x00,0x78,0xcc,0xcc,0xcc,0x7c,0x18,0x18,0x30,0x70,0x00,0x00,// '9'
  54. 0x00,0x00,0x00,0x38,0x38,0x00,0x00,0x38,0x38,0x00,0x00,0x00,// ':'
  55. 0x00,0x00,0x00,0x38,0x38,0x00,0x00,0x38,0x38,0x18,0x30,0x00,// ';'
  56. 0x00,0x0c,0x18,0x30,0x60,0xc0,0x60,0x30,0x18,0x0c,0x00,0x00,// '<'
  57. 0x00,0x00,0x00,0x00,0x7e,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,// '='
  58. 0x00,0x60,0x30,0x18,0x0c,0x06,0x0c,0x18,0x30,0x60,0x00,0x00,// '>'
  59. 0x00,0x78,0xcc,0x0c,0x18,0x30,0x30,0x00,0x30,0x30,0x00,0x00,// '?'
  60. 0x00,0x7c,0xc6,0xc6,0xde,0xde,0xde,0xc0,0xc0,0x7c,0x00,0x00,// '@'
  61. 0x00,0x30,0x78,0xcc,0xcc,0xcc,0xfc,0xcc,0xcc,0xcc,0x00,0x00,// 'A'
  62. 0x00,0xfc,0x66,0x66,0x66,0x7c,0x66,0x66,0x66,0xfc,0x00,0x00,// 'B'
  63. 0x00,0x3c,0x66,0xc6,0xc0,0xc0,0xc0,0xc6,0x66,0x3c,0x00,0x00,// 'C'
  64. 0x00,0xf8,0x6c,0x66,0x66,0x66,0x66,0x66,0x6c,0xf8,0x00,0x00,// 'D'
  65. 0x00,0xfe,0x62,0x60,0x64,0x7c,0x64,0x60,0x62,0xfe,0x00,0x00,// 'E'
  66. 0x00,0xfe,0x66,0x62,0x64,0x7c,0x64,0x60,0x60,0xf0,0x00,0x00,// 'F'
  67. 0x00,0x3c,0x66,0xc6,0xc0,0xc0,0xce,0xc6,0x66,0x3e,0x00,0x00,// 'G'
  68. 0x00,0xcc,0xcc,0xcc,0xcc,0xfc,0xcc,0xcc,0xcc,0xcc,0x00,0x00,// 'H'
  69. 0x00,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00,// 'I'
  70. 0x00,0x1e,0x0c,0x0c,0x0c,0x0c,0xcc,0xcc,0xcc,0x78,0x00,0x00,// 'J'
  71. 0x00,0xe6,0x66,0x6c,0x6c,0x78,0x6c,0x6c,0x66,0xe6,0x00,0x00,// 'K'
  72. 0x00,0xf0,0x60,0x60,0x60,0x60,0x62,0x66,0x66,0xfe,0x00,0x00,// 'L'
  73. 0x00,0xc6,0xee,0xfe,0xfe,0xd6,0xc6,0xc6,0xc6,0xc6,0x00,0x00,// 'M'
  74. 0x00,0xc6,0xc6,0xe6,0xf6,0xfe,0xde,0xce,0xc6,0xc6,0x00,0x00,// 'N'
  75. 0x00,0x38,0x6c,0xc6,0xc6,0xc6,0xc6,0xc6,0x6c,0x38,0x00,0x00,// 'O'
  76. 0x00,0xfc,0x66,0x66,0x66,0x7c,0x60,0x60,0x60,0xf0,0x00,0x00,// 'P'
  77. 0x00,0x38,0x6c,0xc6,0xc6,0xc6,0xce,0xde,0x7c,0x0c,0x1e,0x00,// 'Q'
  78. 0x00,0xfc,0x66,0x66,0x66,0x7c,0x6c,0x66,0x66,0xe6,0x00,0x00,// 'R'
  79. 0x00,0x78,0xcc,0xcc,0xc0,0x70,0x18,0xcc,0xcc,0x78,0x00,0x00,// 'S'
  80. 0x00,0xfc,0xb4,0x30,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00,// 'T'
  81. 0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x78,0x00,0x00,// 'U'
  82. 0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x78,0x30,0x00,0x00,// 'V'
  83. 0x00,0xc6,0xc6,0xc6,0xc6,0xd6,0xd6,0x6c,0x6c,0x6c,0x00,0x00,// 'W'
  84. 0x00,0xcc,0xcc,0xcc,0x78,0x30,0x78,0xcc,0xcc,0xcc,0x00,0x00,// 'X'
  85. 0x00,0xcc,0xcc,0xcc,0xcc,0x78,0x30,0x30,0x30,0x78,0x00,0x00,// 'Y'
  86. 0x00,0xfe,0xce,0x98,0x18,0x30,0x60,0x62,0xc6,0xfe,0x00,0x00,// 'Z'
  87. 0x00,0x3c,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3c,0x00,0x00,// '['
  88. 0x00,0x00,0x80,0xc0,0x60,0x30,0x18,0x0c,0x06,0x02,0x00,0x00,// '\'
  89. 0x00,0x3c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x3c,0x00,0x00,// ']'
  90. 0x10,0x38,0x6c,0xc6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// '^'
  91. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,// '_'
  92. 0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// '`'
  93. 0x00,0x00,0x00,0x00,0x78,0x0c,0x7c,0xcc,0xcc,0x76,0x00,0x00,// 'a'
  94. 0x00,0xe0,0x60,0x60,0x7c,0x66,0x66,0x66,0x66,0xdc,0x00,0x00,// 'b'
  95. 0x00,0x00,0x00,0x00,0x78,0xcc,0xc0,0xc0,0xcc,0x78,0x00,0x00,// 'c'
  96. 0x00,0x1c,0x0c,0x0c,0x7c,0xcc,0xcc,0xcc,0xcc,0x76,0x00,0x00,// 'd'
  97. 0x00,0x00,0x00,0x00,0x78,0xcc,0xfc,0xc0,0xcc,0x78,0x00,0x00,// 'e'
  98. 0x00,0x38,0x6c,0x60,0x60,0xf8,0x60,0x60,0x60,0xf0,0x00,0x00,// 'f'
  99. 0x00,0x00,0x00,0x00,0x76,0xcc,0xcc,0xcc,0x7c,0x0c,0xcc,0x78,// 'g'
  100. 0x00,0xe0,0x60,0x60,0x6c,0x76,0x66,0x66,0x66,0xe6,0x00,0x00,// 'h'
  101. 0x00,0x18,0x18,0x00,0x78,0x18,0x18,0x18,0x18,0x7e,0x00,0x00,// 'i'
  102. 0x00,0x0c,0x0c,0x00,0x3c,0x0c,0x0c,0x0c,0x0c,0xcc,0xcc,0x78,// 'j'
  103. 0x00,0xe0,0x60,0x60,0x66,0x6c,0x78,0x6c,0x66,0xe6,0x00,0x00,// 'k'
  104. 0x00,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7e,0x00,0x00,// 'l'
  105. 0x00,0x00,0x00,0x00,0xfc,0xd6,0xd6,0xd6,0xd6,0xc6,0x00,0x00,// 'm'
  106. 0x00,0x00,0x00,0x00,0xf8,0xcc,0xcc,0xcc,0xcc,0xcc,0x00,0x00,// 'n'
  107. 0x00,0x00,0x00,0x00,0x78,0xcc,0xcc,0xcc,0xcc,0x78,0x00,0x00,// 'o'
  108. 0x00,0x00,0x00,0x00,0xdc,0x66,0x66,0x66,0x66,0x7c,0x60,0xf0,// 'p'
  109. 0x00,0x00,0x00,0x00,0x76,0xcc,0xcc,0xcc,0xcc,0x7c,0x0c,0x1e,// 'q'
  110. 0x00,0x00,0x00,0x00,0xec,0x6e,0x76,0x60,0x60,0xf0,0x00,0x00,// 'r'
  111. 0x00,0x00,0x00,0x00,0x78,0xcc,0x60,0x18,0xcc,0x78,0x00,0x00,// 's'
  112. 0x00,0x00,0x20,0x60,0xfc,0x60,0x60,0x60,0x6c,0x38,0x00,0x00,// 't'
  113. 0x00,0x00,0x00,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0x76,0x00,0x00,// 'u'
  114. 0x00,0x00,0x00,0x00,0xcc,0xcc,0xcc,0xcc,0x78,0x30,0x00,0x00,// 'v'
  115. 0x00,0x00,0x00,0x00,0xc6,0xc6,0xd6,0xd6,0x6c,0x6c,0x00,0x00,// 'w'
  116. 0x00,0x00,0x00,0x00,0xc6,0x6c,0x38,0x38,0x6c,0xc6,0x00,0x00,// 'x'
  117. 0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x3c,0x0c,0x18,0xf0,// 'y'
  118. 0x00,0x00,0x00,0x00,0xfc,0x8c,0x18,0x60,0xc4,0xfc,0x00,0x00,// 'z'
  119. 0x00,0x1c,0x30,0x30,0x60,0xc0,0x60,0x30,0x30,0x1c,0x00,0x00,// '{'
  120. 0x00,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x00,0x00,// '|'
  121. 0x00,0xe0,0x30,0x30,0x18,0x0c,0x18,0x30,0x30,0xe0,0x00,0x00,// '}'
  122. 0x00,0x73,0xda,0xce,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// '~'
  123. };

  124. typedef struct typFNT_GB16 // 漢字字模顯示數(shù)據(jù)結(jié)構(gòu)
  125. {
  126. char Index[2];
  127. char Msk[24];
  128. };
  129. struct typFNT_GB16 code GB_16[] = { // 顯示為12*12
  130. "中",0x04,0x00,0x04,0x00,0x7F,0xC0,0x44,0x40,0x44,0x40,0x44,0x40,0x7F,0xC0,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,
  131. "文",0x08,0x00,0x04,0x40,0xFF,0xE0,0x11,0x00,0x11,0x00,0x11,0x00,0x0A,0x00,0x0A,0x00,0x04,0x00,0x1B,0x00,0xE0,0xE0,0x00,0x00,
  132. "測",0x9E,0x20,0x52,0x20,0x12,0xA0,0x96,0xA0,0x56,0xA0,0x56,0xA0,0x56,0xA0,0xD6,0xA0,0x44,0xA0,0x4A,0x20,0x71,0x60,0x00,0x00,
  133. "試",0x80,0xC0,0x40,0xA0,0x5F,0xE0,0x00,0x80,0xC0,0x80,0x4F,0x80,0x44,0x80,0x44,0x80,0x57,0xA0,0x6C,0x60,0x40,0x20,0x00,0x00,
  134. "液",0x81,0x00,0x5F,0xE0,0x25,0x00,0x85,0xC0,0xAA,0x40,0x4E,0xC0,0x5A,0x40,0x49,0x80,0xC8,0x80,0x49,0x40,0x4E,0x20,0x00,0x00,
  135. "晶",0x1F,0x80,0x10,0x80,0x1F,0x80,0x10,0x80,0x1F,0x80,0x00,0x00,0x7B,0xE0,0x4A,0x20,0x7B,0xE0,0x4A,0x20,0x7B,0xE0,0x00,0x00,
  136. "顯",0x3F,0x80,0x20,0x80,0x3F,0x80,0x20,0x80,0x3F,0x80,0x00,0x00,0x4A,0x40,0x2A,0x40,0x2A,0x80,0x0B,0x00,0xFF,0xE0,0x00,0x00,
  137. "示",0x00,0x80,0x7F,0xC0,0x00,0x00,0x00,0x00,0xFF,0xE0,0x04,0x00,0x14,0x80,0x24,0x40,0x44,0x20,0x84,0x20,0x1C,0x00,0x00,0x00,
  138. //"及",0x7F,0x80,0x10,0x80,0x11,0x00,0x11,0x00,0x19,0xC0,0x14,0x40,0x14,0x80,0x23,0x00,0x23,0x00,0x4C,0x80,0xB0,0x60,0x00,0x00,
  139. //"的",0x11,0x00,0x21,0x00,0xFB,0xE0,0x8A,0x20,0x8C,0x20,0x8A,0x20,0xF9,0x20,0x89,0x20,0x88,0x20,0xF8,0x20,0x89,0xC0,0x00,0x00,
  140. //"試",0x80,0xC0,0x40,0xA0,0x5F,0xE0,0x00,0x80,0xC0,0x80,0x4F,0x80,0x44,0x80,0x44,0x80,0x57,0xA0,0x6C,0x60,0x40,0x20,0x00,0x00,
  141. //"驗(yàn)",0xF1,0x00,0x11,0x00,0x52,0x80,0x54,0x40,0x5B,0xA0,0xF0,0x00,0x15,0x40,0x35,0x40,0xD5,0x40,0x10,0x80,0x6F,0xE0,0x00,0x00,
  142. //"程",0x37,0xC0,0xE4,0x40,0x24,0x40,0xF7,0xC0,0x20,0x00,0x6F,0xE0,0x71,0x00,0xA7,0xC0,0xA1,0x00,0x21,0x00,0x2F,0xE0,0x00,0x00,
  143. //"序",0x04,0x00,0x7F,0xE0,0x40,0x00,0x5F,0x80,0x45,0x00,0x42,0x00,0x7F,0xE0,0x42,0x40,0x42,0x00,0x82,0x00,0x8E,0x00,0x00,0x00,
  144. "鍵",0x41,0x00,0x7F,0xC0,0x89,0x40,0xEB,0xE0,0x5D,0x40,0x47,0xC0,0xF5,0x00,0x57,0xE0,0x49,0x00,0x6D,0x00,0x53,0xE0,0x00,0x00,
  145. "盤",0x08,0x00,0x3F,0x80,0x24,0x80,0xFF,0xE0,0x28,0x80,0x25,0x80,0x40,0x00,0xBF,0xC0,0x2A,0x40,0x2A,0x40,0xFF,0xE0,0x00,0x00,
  146. //"字",0x04,0x00,0x7F,0xE0,0xC0,0x20,0x3F,0x80,0x02,0x00,0x04,0x00,0xFF,0xE0,0x04,0x00,0x04,0x00,0x04,0x00,0x1C,0x00,0x00,0x00,
  147. //"可",0x00,0x40,0xFF,0xE0,0x00,0x80,0x7C,0x80,0x44,0x80,0x44,0x80,0x44,0x80,0x7C,0x80,0x44,0x80,0x00,0x80,0x03,0x80,0x00,0x00,
  148. //"以",0x00,0x80,0x48,0x80,0x44,0x80,0x44,0x80,0x40,0x80,0x40,0x80,0x48,0x80,0x50,0x80,0x61,0x40,0x46,0x20,0x18,0x20,0x00,0x00,
  149. "按",0x21,0x00,0x2F,0xE0,0xF8,0x20,0x22,0x00,0x32,0x00,0x6F,0xE0,0xA4,0x40,0x24,0x80,0x23,0x80,0x21,0x40,0xEE,0x20,0x00,0x00,
  150. "點(diǎn)",0x04,0x00,0x07,0xC0,0x04,0x00,0x04,0x00,0x3F,0x80,0x20,0x80,0x20,0x80,0x3F,0x80,0x00,0x00,0x49,0x40,0xC9,0x20,0x00,0x00,
  151. "定",0x04,0x00,0x7F,0xE0,0xC0,0x20,0x00,0x00,0x7F,0xC0,0x04,0x00,0x24,0x00,0x27,0xC0,0x34,0x00,0x4C,0x00,0x83,0xE0,0x00,0x00,
  152. "位",0x24,0x00,0x22,0x00,0x5F,0xE0,0x40,0x00,0xC8,0x80,0x48,0x80,0x44,0x80,0x45,0x00,0x45,0x00,0x41,0x00,0x5F,0xE0,0x00,0x00,
  153. "直",0x04,0x00,0xFF,0xE0,0x04,0x00,0x3F,0x80,0x20,0x80,0x20,0x80,0x3F,0x80,0x20,0x80,0x3F,0x80,0x20,0x80,0xFF,0xE0,0x00,0x00,
  154. "線",0x22,0x80,0x22,0x40,0x52,0x60,0x97,0x80,0xE2,0x60,0x4F,0x80,0xB2,0x40,0xC2,0x80,0x31,0x20,0xC6,0xA0,0x18,0x60,0x00,0x00,
  155. "繪",0x21,0x00,0x21,0x00,0x52,0x80,0x94,0x40,0xEB,0xA0,0x20,0x00,0x5F,0xE0,0xE2,0x00,0x02,0x80,0xF4,0x40,0x8F,0xE0,0x00,0x00,
  156. "制",0x10,0x20,0x54,0x20,0x7E,0xA0,0x90,0xA0,0xFE,0xA0,0x10,0xA0,0x7E,0xA0,0x52,0xA0,0x52,0x20,0x56,0x20,0x10,0xE0,0x00,0x00,
  157. "圖",0x7F,0xE0,0x48,0x20,0x5F,0x20,0x6A,0x20,0x44,0x20,0x4A,0x20,0x75,0xA0,0x42,0x20,0x4C,0x20,0x42,0x20,0x7F,0xE0,0x00,0x00,
  158. "片",0x22,0x00,0x22,0x00,0x22,0x00,0x3F,0xE0,0x20,0x00,0x20,0x00,0x3F,0x00,0x21,0x00,0x21,0x00,0x41,0x00,0x81,0x00,0x00,0x00,
  159. "繪",0x21,0x00,0x21,0x00,0x52,0x80,0x94,0x40,0xEB,0xA0,0x20,0x00,0x5F,0xE0,0xE2,0x00,0x02,0x80,0xF4,0x40,0x8F,0xE0,0x00,0x00,
  160. "制",0x10,0x20,0x54,0x20,0x7E,0xA0,0x90,0xA0,0xFE,0xA0,0x10,0xA0,0x7E,0xA0,0x52,0xA0,0x52,0x20,0x56,0x20,0x10,0xE0,0x00,0x00,

  161. "流",0x82,0x00,0x5F,0xE0,0x42,0x00,0x04,0x80,0xAF,0xC0,0x60,0x40,0x2A,0x80,0x4A,0x80,0xCA,0xA0,0x52,0xA0,0x62,0xE0,0x00,0x00,
  162. "電",0x04,0x00,0x04,0x40,0x7F,0xE0,0x44,0x40,0x7F,0xC0,0x44,0x40,0x44,0x40,0x7F,0xC0,0x44,0x00,0x04,0x20,0x03,0xE0,0x00,0x00,
  163. "機(jī)",0x20,0x80,0x27,0xC0,0xFC,0x80,0x24,0x80,0x24,0x80,0x74,0x80,0x6C,0x80,0xA4,0x80,0xA4,0xA0,0x28,0xA0,0x30,0xE0,0x00,0x00,
  164. "加",0x20,0x00,0x20,0x00,0xFD,0xE0,0x25,0x20,0x25,0x20,0x25,0x20,0x25,0x20,0x25,0x20,0x45,0x20,0x45,0xE0,0x99,0x20,0x00,0x00,
  165. "減",0x81,0x40,0x41,0x40,0x5F,0xE0,0x11,0x00,0x5F,0x20,0x51,0x20,0x9F,0x40,0x9A,0x80,0xAE,0xA0,0xA9,0x60,0x42,0x20,0x00,0x00,
  166. "速",0x82,0x00,0x5F,0xE0,0x42,0x00,0x0F,0xC0,0xCA,0x40,0x4F,0xC0,0x43,0x00,0x46,0x80,0x5A,0x40,0xA2,0x00,0x9F,0xE0,0x00,0x00,
  167. "及",0x7F,0x80,0x10,0x80,0x11,0x00,0x11,0x00,0x19,0xC0,0x14,0x40,0x14,0x80,0x23,0x00,0x23,0x00,0x4C,0x80,0xB0,0x60,0x00,0x00,

  168. "系",0x03,0xC0,0x7C,0x00,0x08,0x80,0x3F,0x00,0x04,0x00,0x08,0x80,0x3F,0xC0,0x15,0x00,0x24,0x80,0x44,0x40,0x9C,0x20,0x00,0x00,
  169. "統(tǒng)",0x21,0x00,0x27,0xE0,0x51,0x00,0xF2,0x00,0x24,0x40,0x47,0xE0,0xF2,0x80,0x02,0x80,0x32,0xA0,0xC4,0xA0,0x18,0xE0,0x00,0x00,
  170. "步",0x04,0x00,0x27,0xC0,0x24,0x00,0x24,0x00,0xFF,0xE0,0x04,0x00,0x14,0x40,0x24,0x80,0x41,0x00,0x06,0x00,0x78,0x00,0x00,0x00,
  171. "長",0x20,0x80,0x21,0x00,0x22,0x00,0x24,0x00,0x28,0x00,0xFF,0xE0,0x24,0x00,0x22,0x00,0x21,0x00,0x2C,0x80,0x30,0x60,0x00,0x00,
  172. "順",0x57,0xE0,0x51,0x00,0x57,0xE0,0x54,0x20,0x55,0x20,0x55,0x20,0x55,0x20,0x55,0x20,0x51,0x80,0x92,0x40,0x8C,0x20,0x00,0x00,
  173. "時(shí)",0x00,0x80,0xF0,0x80,0x9F,0xE0,0x90,0x80,0x94,0x80,0xF2,0x80,0x92,0x80,0x90,0x80,0xF0,0x80,0x90,0x80,0x03,0x80,0x00,0x00,
  174. "針",0x41,0x00,0x41,0x00,0x79,0x00,0x81,0x00,0xF7,0xE0,0x21,0x00,0xF9,0x00,0x21,0x00,0x29,0x00,0x31,0x00,0x21,0x00,0x00,0x00,
  175. "旋",0x42,0x00,0x23,0xE0,0xF4,0x00,0x4F,0xE0,0x71,0x20,0x55,0x40,0x55,0x00,0x55,0xE0,0x55,0x00,0xB7,0x00,0x89,0xE0,0x00,0x00,
  176. "轉(zhuǎn)",0x21,0x00,0xF9,0x00,0x47,0xE0,0x61,0x00,0xA7,0xE0,0xFA,0x00,0x23,0xC0,0x38,0x40,0xE0,0x80,0x23,0x00,0x20,0x80,0x00,0x00,
  177. "逆",0x84,0x40,0x42,0x80,0x5F,0xE0,0x01,0x00,0xC9,0x40,0x49,0x40,0x4F,0xC0,0x42,0x00,0x44,0x00,0xA8,0x00,0x9F,0xE0,0x00,0x00,

  178. //"旋",0x42,0x00,0x23,0xE0,0xF4,0x00,0x4F,0xE0,0x71,0x20,0x55,0x40,0x55,0x00,0x55,0xE0,0x55,0x00,0xB7,0x00,0x89,0xE0,0x00,0x00,
  179. //"轉(zhuǎn)",0x21,0x00,0xF9,0x00,0x47,0xE0,0x61,0x00,0xA7,0xE0,0xFA,0x00,0x23,0xC0,0x38,0x40,0xE0,0x80,0x23,0x00,0x20,0x80,0x00,0x00,
  180. "方",0x04,0x00,0x02,0x40,0xFF,0xE0,0x08,0x00,0x0F,0x80,0x08,0x80,0x08,0x80,0x10,0x80,0x10,0x80,0x20,0x80,0xC7,0x00,0x00,0x00,
  181. "向",0x04,0x00,0x08,0x40,0x7F,0xE0,0x40,0x40,0x5F,0x40,0x51,0x40,0x51,0x40,0x5F,0x40,0x40,0x40,0x40,0x40,0x41,0xC0,0x00,0x00,

  182. //"時(shí)",
  183. //"針",
  184. };

  185. uchar gCurRow,gCurCol; // 圖形當(dāng)前行、列存儲(chǔ),行高16點(diǎn),列寬8點(diǎn)
  186. uchar tCurRow,tCurCol; // 文本當(dāng)前行、列存儲(chǔ),行高8點(diǎn) ,列寬8點(diǎn)
  187. uchar ShowModeSW; // 當(dāng)前顯示模式
  188. uint txthome,grhome;

  189. /******************************************************************************/
  190. uchar fnGetRow();
  191. uchar fnGetCol();
  192. uchar fnST01(); // 狀態(tài)位STA1,STA0判斷(讀寫指令和讀寫數(shù)據(jù))
  193. uchar fnST2(); // 狀態(tài)位ST2判斷(數(shù)據(jù)自動(dòng)讀狀態(tài))
  194. uchar fnST3(); // 狀態(tài)位ST3判斷(數(shù)據(jù)自動(dòng)寫狀態(tài))
  195. uchar fnST6(); // 狀態(tài)位ST6判斷(屏讀/屏拷貝狀態(tài))
  196. uchar fnPR1(uchar uCmd,uchar uPar1,uchar uPar2); // 寫雙參數(shù)的指令
  197. uchar fnPR11(uchar uCmd,uchar uPar1); // 寫單參數(shù)的指令
  198. uchar fnPR12(uchar uCmd); // 寫無參數(shù)的指令
  199. uchar fnPR13(uchar uData); // 寫數(shù)據(jù)
  200. uchar fnPR2(); // 讀數(shù)據(jù)
  201. void fnSetPos(uchar urow, uchar ucol);        // 設(shè)置當(dāng)前地址
  202. void cursor(uchar uRow, uchar uCol);         //設(shè)置當(dāng)前顯示行、列
  203. void at(unsigned char x,unsigned char y);/*設(shè)定文本x,y值*/
  204. void cls();         // 清屏
  205. char fnLCMInit(); // LCM 初始化
  206. void charout(uchar *str); //ASCII(8*8) 顯示函數(shù)
  207. uchar dprintf(uchar x,uchar y,char *fmt);// ASCII(8*16) 及 漢字(16*16) 顯示函數(shù)
  208. void OutToLCD(uchar Dat,uchar x,uchar y);//顯示輔助函數(shù)

  209. void SetShowMode(uchar newShowModeSW);        
  210. void Line( unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, bit Mode);
  211. void Pixel(unsigned char PointX,unsigned char PointY, bit Mode);

  212. uchar fnGetRow(void)
  213. {
  214.         return gCurRow;
  215. }

  216. uchar fnGetCol(void)
  217. {
  218.         return gCurCol;
  219. }

  220. uchar fnST01(void) // 狀態(tài)位STA1,STA0判斷(讀寫指令和讀寫數(shù)據(jù))
  221. {
  222.         uchar i;
  223.         
  224.         for(i=10;i>0;i--)
  225.         {
  226.                 if((LCMCW & 0x03) == 0x03)
  227.                 break;
  228.         }
  229.         return i; // 若返回零,說明錯(cuò)誤
  230. }

  231. uchar fnST2(void) // 狀態(tài)位ST2判斷(數(shù)據(jù)自動(dòng)讀狀態(tài))
  232. {
  233.         uchar i;
  234.         
  235.         for(i=10;i>0;i--)
  236.         {
  237.                 if((LCMCW & 0x04) == 0x04)
  238.                 break;
  239.         }
  240.         return i; // 若返回零,說明錯(cuò)誤
  241. }

  242. uchar fnST3(void) // 狀態(tài)位ST3判斷(數(shù)據(jù)自動(dòng)寫狀態(tài))
  243. {
  244.         uchar i;
  245.         
  246.         for(i=10;i>0;i--)
  247.         {
  248.                 if((LCMCW & 0x08) == 0x08)
  249.                 break;
  250.         }
  251.         return i; // 若返回零,說明錯(cuò)誤
  252. }

  253. uchar fnST6(void) // 狀態(tài)位ST6判斷(屏讀/屏拷貝狀態(tài))
  254. {
  255.         uchar i;
  256.         
  257.         for(i=10;i>0;i--)
  258.         {
  259.                 if((LCMCW & 0x40) == 0x40)
  260.                 break;
  261.         }
  262.         return i; // 若返回零,說明錯(cuò)誤
  263. }

  264. uchar fnPR1(uchar uCmd,uchar uPar1,uchar uPar2) // 寫雙參數(shù)的指令
  265. {
  266.         if(fnST01() == 0)
  267.         return 1;
  268.         LCMDW = uPar1;
  269.         if(fnST01() == 0)
  270.         return 2;
  271.         LCMDW = uPar2;
  272.         if(fnST01() == 0)
  273.         return 3;
  274.         LCMCW = uCmd;
  275.         return 0; // 返回0成功
  276. }

  277. uchar fnPR11(uchar uCmd,uchar uPar1) // 寫單參數(shù)的指令
  278. {
  279.         if(fnST01() == 0)
  280.         return 1;
  281.         LCMDW = uPar1;
  282.         if(fnST01() == 0)
  283.         return 2;
  284.         LCMCW = uCmd;
  285.         return 0; // 返回0成功
  286. }

  287. uchar fnPR12(uchar uCmd) // 寫無參數(shù)的指令
  288. {
  289.         if(fnST01() == 0)
  290.         return 1;
  291.         LCMCW = uCmd;
  292.         return 0; // 返回0成功
  293. }

  294. uchar fnPR13(uchar uData) // 寫數(shù)據(jù)
  295. {
  296.         if(fnST3() == 0)
  297.         return 1;
  298.         LCMDW = uData;
  299.         return 0; // 返回0成功
  300. }

  301. uchar fnPR2(void) // 讀數(shù)據(jù)
  302. {
  303.         if(fnST01() == 0)
  304.         return 1;
  305.         return LCMDW;
  306. }


  307. void fnSetPos(uchar urow, uchar ucol)        //設(shè)置當(dāng)前地址
  308. {
  309.         uint iPos;
  310.         
  311.         iPos = urow * 20 + ucol;
  312.         fnPR1(LC_ADD_POS,iPos & 0xFF,iPos / 256);
  313.         gCurRow = urow;
  314.         gCurCol = ucol;
  315. }

  316. void cursor(uchar uRow, uchar uCol)         //設(shè)置當(dāng)前顯示行、列
  317. {
  318.         fnSetPos(uRow * 16, uCol);
  319. }
  320. void at(unsigned char x,unsigned char y)/*設(shè)定文本x,y值*/
  321. {        
  322.         uint iPos; //地址
  323.         
  324.         iPos = x  + y* 20;
  325.         fnPR1(LC_ADD_POS,iPos&0xff,iPos/256);
  326.         tCurRow = x;
  327.         tCurCol = y;
  328. }

  329. // 清屏
  330. void cls(void)
  331. {
  332.         uint i;
  333.         
  334.         fnPR1(LC_ADD_POS,0x00,0x00); // 置地址指針
  335.         fnPR12(LC_AUT_WR); // 自動(dòng)寫
  336.         for(i=0;i<0x2000;i++)
  337.         {
  338.                 fnST3();
  339.                 fnPR13(0x00); // 寫數(shù)據(jù)
  340.         }
  341.         fnPR12(LC_AUT_OVR); // 自動(dòng)寫結(jié)束
  342.         fnPR1(LC_ADD_POS,0x00,0x00); // 重置地址指針
  343.         gCurRow = 0; // 置地址指針存儲(chǔ)變量
  344.         gCurCol = 0;
  345. }

  346. // LCM 初始化
  347. char fnLCMInit(void)
  348. {
  349.         reset=0;
  350.         reset=1;
  351.         fnPR1(LC_TXT_STP,0x00,0x00); // 文本顯示區(qū)首地址
  352.         fnPR1(LC_TXT_WID,0x14,0x00); // 文本顯示區(qū)寬度
  353.         fnPR1(LC_GRH_STP,0x00,0x00); // 圖形顯示區(qū)首地址
  354.         fnPR1(LC_GRH_WID,0x14,0x00); // 圖形顯示區(qū)寬度
  355.         fnPR11(LC_CGR_POS,CGRAMSTART >> 11);
  356.         fnPR12(LC_CUR_SHP | 0x01); // 光標(biāo)形狀
  357.         fnPR12(LC_MOD_OR); // 顯示方式設(shè)置
  358.         fnPR12(LC_DIS_SW |0x08);
  359.         grhome = GRSTART;
  360.     txthome = TXTSTART;

  361.         return 0;
  362. }
  363. void charout(uchar *str)
  364. {
  365.     uchar ch,len,i,uRow,uCol ;
  366.     len=strlen(str);
  367.     i=0;
  368.     uRow = tCurRow;
  369.     uCol = tCurRow;
  370.     at(uCol,uRow);
  371.     while(i<len)
  372.     {
  373.         ch=str[i]-0x20;
  374.         fnPR11(LC_INC_WR,ch);
  375.         i++;
  376.     }
  377. }
  378. // ASCII及漢字顯示函數(shù)

  379. uchar dprintf(uchar x,uchar y,char *fmt)
  380. {
  381.         char c1,c2,cData;
  382.         uchar i=0,j,uLen;
  383.         uchar k;
  384.         
  385.         uLen=strlen(fmt);

  386.         while(i<uLen)
  387.         {
  388.                 c1 = fmt[i];
  389.                 c2 = fmt[i+1];
  390.                
  391.                 fnSetPos(y,x/8);
  392.                 if(c1 >= 0)
  393.                 {
  394.                  // ASCII
  395.                     if(c1 < 0x20)
  396.                     {
  397.                         switch(c1)
  398.                         {
  399.                             case CR:
  400.                             case LF: // 回車或換行
  401.                                 i++;
  402.                                                 x=0;
  403.                                 if(y < 112)y+=HZ_CHR_HEIGHT;
  404.                                 continue;
  405.                             case BS: // 退格
  406.                                                 i++;
  407.                                 if(y>ASC_CHR_WIDTH)y-=ASC_CHR_WIDTH;
  408.                                 cData = 0x00;
  409.                                 break;
  410.                         }
  411.                     }
  412.                     for(j=0;j<ASC_CHR_HEIGHT;j++)
  413.                     {
  414.                         
  415.                         if(c1 >= 0x1f)
  416.                         {
  417.                                            cData= ASC_MSK[(c1-0x1f)*ASC_CHR_HEIGHT+j];
  418.                                         fnSetPos(y+j,x/8);
  419.                                         if((x%8)==0)
  420.                                         {
  421.                                                 fnPR12(LC_AUT_WR); // 寫數(shù)據(jù)
  422.                                            fnPR13(cData);        
  423.                                         fnPR12(LC_AUT_OVR);
  424.                                         }
  425.                                         else
  426.                                                 OutToLCD(cData,x,y+j);
  427.                         }
  428.                         fnSetPos(y+j,x/8);
  429.                     }
  430.                     if(c1 != BS) // 非退格
  431.                     x+=ASC_CHR_WIDTH;
  432.                 }
  433.                 else
  434.                 { // 中文
  435.                         
  436.                     for(j=0;j<sizeof(GB_16)/sizeof(GB_16[0]);j++)
  437.                     {
  438.                         if(c1 == GB_16[j].Index[0] && c2 == GB_16[j].Index[1])
  439.                         break;
  440.                     }
  441.                     for(k=0;k<HZ_CHR_HEIGHT;k++)
  442.                     {
  443.                                 
  444.                         fnSetPos(y+k,x/8);
  445.                         if(j < sizeof(GB_16)/sizeof(GB_16[0]))
  446.                         {
  447.                                         c1=GB_16[j].Msk[k*2];
  448.                                         c2=GB_16[j].Msk[k*2+1];
  449.                                 }
  450.                                 else           
  451.                                         c1=c2=0;
  452.                                 if((x%8)==0)
  453.                                 {
  454.                                         fnPR12(LC_AUT_WR);
  455.                                         fnPR13(c1);
  456.                                 fnPR12(LC_AUT_OVR);
  457.                         }
  458.                                 else
  459.                                         OutToLCD(c1,x,y+k);
  460.                                 
  461.                                 if(((x+2+HZ_CHR_WIDTH/2)%8)==0)
  462.                                 {
  463.                                         fnPR12(LC_AUT_WR);
  464.                                         fnPR13(c2);
  465.                                         fnPR12(LC_AUT_OVR);
  466.                         }
  467.                                 else
  468.                                         OutToLCD(c2,x+2+HZ_CHR_WIDTH/2,y+k);
  469.                     }
  470.                     x+=HZ_CHR_WIDTH;
  471.                     i++;
  472.                 }  
  473.                 i++;
  474.         }
  475.         return uLen;
  476. }
  477. void OutToLCD(uchar Dat,uchar x,uchar y)
  478. {
  479.         uchar uData1,uData2,ux,a,b;

  480.         a=8-(x%8);b=x%8;
  481.         fnSetPos(y,x/8);
  482.         fnPR12(LC_AUT_RD); // 讀數(shù)據(jù)
  483.         uData1=fnPR2();
  484.         uData2=fnPR2();
  485.         fnPR12(LC_AUT_OVR);
  486.         fnSetPos(y,x/8);
  487.         uData1&=~MSK1[a];
  488.         ux=Dat&MSK2[a];
  489.         ux>>=b;
  490.         uData1=uData1|ux;
  491.         ux=~MSK2[b];
  492.         uData2&=ux;
  493.         ux=MSK1[b];
  494.         ux=Dat&ux;
  495.         ux<<=a;
  496.         uData2=uData2|ux;
  497.         fnPR12(LC_AUT_WR); // 寫數(shù)據(jù)
  498.            fnPR13(uData1);        
  499.         fnPR13(uData2);
  500.         fnPR12(LC_AUT_OVR);

  501. }
  502. void SetShowMode(uchar newShowModeSW)         //設(shè)置為顯示模式
  503. {
  504.         ShowModeSW=newShowModeSW;
  505.         fnPR12(LC_DIS_SW | newShowModeSW);
  506. }

  507. /**********************************
  508. //= 函數(shù)原型: Pixel(unsigned char PointX,unsigned char PointY, bit Mode)
  509. //= 功    能: 在指定坐標(biāo)位置顯示一個(gè)點(diǎn)
  510. //= 參    數(shù): 坐標(biāo),顯示點(diǎn)或清除點(diǎn)
  511. //= 返 回 值:
  512. //= 函數(shù)性質(zhì):私有函數(shù)
  513. //= 如果顯示屏超過了256*256,請(qǐng)修改這個(gè)函數(shù) PointX,PointY的類型
  514. //= Mode 1:顯示 0:清除該點(diǎn)
  515. **********************************/
  516. void Pixel(unsigned char PointX,unsigned char PointY, bit Mode)
  517. {
  518.     unsigned char StartAddr;
  519.     unsigned char dat;
  520.     StartAddr=7-(PointX%8);
  521.     dat=LC_BIT_OP|StartAddr; //生產(chǎn)位操作命令畫點(diǎn)的數(shù)據(jù)
  522.     if(Mode) dat=dat|0x08;
  523.         fnSetPos(PointY,PointX/8);
  524.         fnPR12(LC_BIT_OP|dat); // 寫數(shù)據(jù)
  525. }


  526. /**********************************
  527. //= 函數(shù)原型: void line( unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, bit Mode)
  528. //= 功    能: 劃線函數(shù)
  529. //= 參    數(shù): 坐標(biāo)1,坐標(biāo)2,顯示點(diǎn)或清除點(diǎn)
  530. //= 返 回 值:
  531. //= 函數(shù)性質(zhì):私有函數(shù)
  532. //= 其它:顯示點(diǎn)陣不超過255*255
  533. /**********************************/

  534. void line( unsigned char x1,unsigned char y1, unsigned char x2,unsigned char y2,  bit Mode)
  535. {
  536.     unsigned char x,y;
  537.     float k,b;
  538.     if( abs(y1-y2) <= abs(x1-x2) ) // |k|<=1
  539.     {
  540.         k=((float)y2-y1) / ((float)x2-x1) ;
  541.         b=y1-k*x1;
  542.         if( x1 <= x2 )
  543.         {
  544.             for(x=x1;x<=x2;x++)
  545.             {
  546.                 y=(uchar)(k*x+b);
  547.                 Pixel(x, y, Mode);
  548.             }
  549.         }
  550.         else
  551.         {
  552.             for(x=x2;x<=x1;x++)
  553.             {
  554.                 y=(uchar)(k*x+b);
  555.                 Pixel(x, y, Mode);
  556.             }
  557.         }
  558.     }
  559.     else // abs(y1-y2) > abs(x1-x2) |K|>1
  560.     {
  561.         k=((float)x2-x1) / ((float)y2-y1) ;
  562.         b=x1-k*y1;
  563.         if( y1 <= y2 )
  564.         {
  565.             for(y=y1;y<=y2;y++)
  566.             {
  567.                 x=(uchar)(k*y+b);
  568.                 Pixel( x , y,Mode );
  569.             }
  570.         }
  571.         else
  572.         {
  573.             for(y=y2;y<=y1;y++)
  574.             {
  575.                 x=(uchar)(k*y+b);
  576.                 Pixel( x , y,Mode );
  577.             }
  578.         }
  579.     }
  580. }
復(fù)制代碼

評(píng)分

參與人數(shù) 1黑幣 +8 收起 理由
xmd1972 + 8 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

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

使用道具 舉報(bào)

沙發(fā)
ID:141935 發(fā)表于 2016-10-9 11:05 | 只看該作者
51黑有你更精彩!!!
回復(fù)

使用道具 舉報(bào)

板凳
ID:142153 發(fā)表于 2016-10-10 10:54 | 只看該作者
強(qiáng)大!學(xué)習(xí)了,棒棒噠
回復(fù)

使用道具 舉報(bào)

地板
ID:303781 發(fā)表于 2018-4-8 16:34 | 只看該作者
謝謝樓主!學(xué)習(xí)中
回復(fù)

使用道具 舉報(bào)

5#
ID:308395 發(fā)表于 2018-4-26 16:55 | 只看該作者
我的仿真只顯示一個(gè)速度
回復(fù)

使用道具 舉報(bào)

6#
ID:192893 發(fā)表于 2018-4-28 22:25 | 只看該作者
感謝樓主分享
回復(fù)

使用道具 舉報(bào)

7#
ID:552986 發(fā)表于 2019-6-2 14:21 | 只看該作者
太厲害了,給您個(gè)大贊!
回復(fù)

使用道具 舉報(bào)

8#
ID:453330 發(fā)表于 2019-12-18 11:37 | 只看該作者
51黑有你更精彩。!
回復(fù)

使用道具 舉報(bào)

9#
ID:496265 發(fā)表于 2019-12-18 15:37 | 只看該作者

學(xué)習(xí)一下
學(xué)習(xí)一下
回復(fù)

使用道具 舉報(bào)

10#
ID:478893 發(fā)表于 2019-12-18 15:39 | 只看該作者
謝謝分享,學(xué)習(xí)了
回復(fù)

使用道具 舉報(bào)

11#
ID:744356 發(fā)表于 2020-5-9 09:53 | 只看該作者
這個(gè)真的很好
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 日韩成人久久 | 成人3d动漫一区二区三区91 | 日韩一区在线观看视频 | 欧美日韩成人一区二区 | 免费v片 | av色站 | 99久久免费精品国产免费高清 | 国产日韩电影 | 九九免费 | 精品久久香蕉国产线看观看亚洲 | 天天操天天射综合 | 九九国产在线观看 | 在线视频亚洲 | 国产成人精品一区二 | 亚洲成av人片在线观看 | 国产精品视频免费观看 | 国产精品免费一区二区三区四区 | 日本精品一区二区 | 午夜免费av | 亚洲国产成人精品久久久国产成人一区 | av资源网站 | 午夜在线小视频 | 亚洲精品99久久久久久 | 国产精品二区三区在线观看 | 欧美一级久久 | 福利视频一区二区 | 亚洲图片视频一区 | 欧美一页| 国产精品一区二区三 | 亚洲欧美一区二区三区情侣bbw | 国产成人精品高清久久 | 成人av一区 | 国产不卡在线观看 | 欧美成人精品一区二区三区 | 伊人操| 综合另类 | 亚洲性人人天天夜夜摸 | 久久精品无码一区二区三区 | 最近中文字幕第一页 | 人人干人人艹 | 中文一级片 |