网站导航: 首页 > 设计参考 > 正文 文章搜索
T6963C 液晶驱动源代码
 
文章编号:
090106170055
文章分类: 单片机 51系列
点 击:
...
关 键 词: T6963C,液晶,LCD
文章来源:
网络
摘 要:

 
  1. /*T6963C 液晶驱动Keil C源代码  
  2. 线路图  
  3. 89C51              T6963C  
  4. --------  
  5. |     8  
  6. P1.0-1.7|=========== D0-7  
  7. |  
  8. P3.0|----------- /RD  
  9. P3.1|----------- /WR  
  10. P3.2|----------- C/D  
  11. |         -- /CE  
  12. |         |  
  13. |        ---  
  14. P3.3|----------- /RESET    
  15. |     VCC--- /HALT  
  16. --------       
  17. */  
  18.   
  19. #include <reg8751.h>   
  20. #include <math.h>   
  21. #include  <intrins.h>   
  22.   
  23. sbit cd=P3^2;   
  24. sbit wr=P3^1;   
  25. sbit rd=P3^0;   
  26. sbit reset=P3^3;   
  27. sbit vee=P3^7;   
  28.   
  29. sbit scl=P3^2;   
  30. sbit sda=P3^3;   
  31.   
  32. unsigned int time;   
  33. unsigned char x,y;   
  34.   
  35. /* 忙标志 */  
  36. #pragma disable   
  37. unsigned char busy(void) {   
  38.     unsigned char dat;   
  39.     cd=1;rd=1;wr=1;   
  40.     P0=0xff;   
  41.     rd=0;   
  42.     dat=P0;   
  43.     rd=1;   
  44.     return(dat);   
  45. }   
  46. /* 数据,指令读写判别 */  
  47. #pragma disable   
  48. void p1(void) {       
  49.     while ((busy()&3)!=3) {}   
  50. }   
  51. /* 数据自动读判别 */  
  52. #pragma disable   
  53. void p2(void) {       
  54.     while ((busy()&4)!=4) {}   
  55. }   
  56. /* 数据自动写判别 */  
  57. #pragma disable   
  58. void p3(void) {       
  59.     while ((busy()&8)!=8) {}   
  60. }   
  61. /* 控制指令 */  
  62. #pragma disable   
  63. void ctrl(unsigned char dat) {   
  64.     p1();   
  65.     cd=1;   
  66.     wr=0;   
  67.     P0=dat;   
  68.     wr=1;   
  69. }   
  70. /* 写数据 */  
  71. #pragma disable   
  72. void write(unsigned char dat) {   
  73.     p1();   
  74.     cd=0;   
  75.     wr=0;   
  76.     P0=dat;   
  77.     wr=1;   
  78.     cd=1;   
  79. }   
  80. /* 自动写 */  
  81. #pragma disable   
  82. void autowrite(unsigned char dat) {   
  83.     p3();   
  84.     cd=0;   
  85.     wr=0;   
  86.     P0=dat;   
  87.     wr=1;   
  88.     cd=1;   
  89. }   
  90. /* 读数据 */  
  91. #pragma disable   
  92. unsigned char read(void) {   
  93.     unsigned char dat;   
  94.     p1();   
  95.     cd=0;   
  96.     P0=0xff;   
  97.     rd=0;   
  98.     dat=P0;   
  99.     rd=1;   
  100.     cd=1;   
  101.     return(dat);   
  102. }   
  103. /* 自动读数据 */  
  104. #pragma disable   
  105. unsigned char autoread(void) {   
  106.     unsigned char dat;   
  107.     p2();   
  108.     cd=0;   
  109.     P0=0xff;   
  110.     rd=0;   
  111.     dat=P0;   
  112.     rd=1;   
  113.     cd=1;   
  114.     return(dat);   
  115. }   
  116. /* 显示图形和文本 */  
  117. #pragma disable   
  118. void disp(unsigned char d) { /*显示*/  
  119.     write(d);ctrl(0xc0);   
  120. }   
  121. /* 设定图形x,y值*/  
  122. #pragma disable   
  123. void ag(unsigned char x,unsigned char y) { /*地址*/  
  124.     unsigned int xy;   
  125.     xy=y;   
  126.     xy=xy*16+x+256;   
  127.     write(xy&0xff);write(xy/256);ctrl(0x24);   
  128. }   
  129. /* 设定文本x,y值 */  
  130. #pragma disable   
  131. void at(unsigned char x,unsigned char y) { /*地址*/  
  132.     write(y*16+x);write(0);ctrl(0x24);   
  133. }   
  134. /* 点亮一点 */  
  135. #pragma disable   
  136. void setb(unsigned char d) {   
  137.     ctrl(0xf8|d);   
  138. }   
  139. /* 清除一点*/  
  140. #pragma disable   
  141. void clrb(unsigned char d) {   
  142.     ctrl(0xf0|d);   
  143. }   
  144. /* x,y处显示光标 */  
  145. #pragma disable   
  146. void ab(unsigned char x,unsigned char y) {  /*光标*/  
  147.     ctrl(0x97); /*光标开*/  
  148.     write(x);write(y);ctrl(0x21);   
  149. }   
  150. /* 取消光标 */  
  151. #pragma disable   
  152. void noab(void) {    
  153.     ctrl(0x9c);    
  154. }   
  155.   
  156. /* lcd初始化 */  
  157. void init(void) {   
  158.     unsigned int i;   
  159.     reset=0;   
  160.     reset=1;   
  161.     write(0x0);write(0);ctrl(0x40);  /*文本首址*/  
  162.     write(0x10);write(0x0);ctrl(0x41); /*文本区域*/  
  163.     write(0x0);write(0x1);ctrl(0x42); /*图形首址*/  
  164.     write(0x10);write(0x0);ctrl(0x43); /*图形区域*/  
  165.     ctrl(0x81); /*显示方式*/  
  166.     ctrl(0x90); /*显示开关*/  
  167.     ctrl(0xa0); /*光标形状*/  
  168.     at(0,0);   
  169.     ctrl(0xb0); /*自动写方式*/  
  170.     for (i=0;i<1280;i++) {   
  171.         autowrite(0x0);   
  172.     }   
  173.     ctrl(0xb2);/*结束自动写方式 */  
  174.     ctrl(0x9c);   
  175. }   
  176.   
  177. void wait10(void) {   
  178.     time=0;   
  179.     while (time<10) {}   
  180. }   
  181.   
  182. unsigned char temp;   
  183.   
  184. unsigned char code asc16[]={   
  185.         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,   
  186.         0,0,126,129,165,129,129,189,153,129,129,126,0,0,0,0,   
  187.         0,0,126,255,219,255,255,195,231,255,255,126,0,0,0,0,   
  188.         0,0,0,0,108,254,254,254,254,124,56,16,0,0,0,0,   
  189.         0,0,0,0,16,56,124,254,124,56,16,0,0,0,0,0,   
  190.         0,0,0,24,60,60,231,231,231,24,24,60,0,0,0,0,   
  191.         0,0,0,24,60,126,255,255,126,24,24,60,0,0,0,0,   
  192.         0,0,0,0,0,0,24,60,60,24,0,0,0,0,0,0,   
  193.         255,255,255,255,255,255,231,195,195,231,255,255,255,255,255,255,   
  194.         0,0,0,0,0,60,102,66,66,102,60,0,0,0,0,0,   
  195.         255,255,255,255,255,195,153,189,189,153,195,255,255,255,255,255,   
  196.         0,0,30,14,26,50,120,204,204,204,204,120,0,0,0,0,   
  197.         0,0,60,102,102,102,102,60,24,126,24,24,0,0,0,0,   
  198.         0,0,63,51,63,48,48,48,48,112,240,224,0,0,0,0,   
  199.         0,0,127,99,127,99,99,99,99,103,231,230,192,0,0,0,   
  200.         0,0,0,24,24,219,60,231,60,219,24,24,0,0,0,0,   
  201.         0,128,192,224,240,248,254,248,240,224,192,128,0,0,0,0,   
  202.         0,2,6,14,30,62,254,62,30,14,6,2,0,0,0,0,   
  203.         0,0,24,60,126,24,24,24,126,60,24,0,0,0,0,0,   
  204.         0,0,102,102,102,102,102,102,102,0,102,102,0,0,0,0,   
  205.         0,0,127,219,219,219,123,27,27,27,27,27,0,0,0,0,   
  206.         0,124,198,96,56,108,198,198,108,56,12,198,124,0,0,0,   
  207.         0,0,0,0,0,0,0,0,254,254,254,254,0,0,0,0,   
  208.         0,0,24,60,126,24,24,24,126,60,24,126,0,0,0,0,   
  209.         0,0,24,60,126,24,24,24,24,24,24,24,0,0,0,0,   
  210.         0,0,24,24,24,24,24,24,24,126,60,24,0,0,0,0,   
  211.         0,0,0,0,0,24,12,254,12,24,0,0,0,0,0,0,   
  212.         0,0,0,0,0,48,96,254,96,48,0,0,0,0,0,0,   
  213.         0,0,0,0,0,0,192,192,192,254,0,0,0,0,0,0,   
  214.         0,0,0,0,0,40,108,254,108,40,0,0,0,0,0,0,   
  215.         0,0,0,0,16,56,56,124,124,254,254,0,0,0,0,0,   
  216.         0,0,0,0,254,254,124,124,56,56,16,0,0,0,0,0,   
  217.         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,   
  218.         0,0,24,60,60,60,24,24,24,0,24,24,0,0,0,0,   
  219.         0,102,102,102,36,0,0,0,0,0,0,0,0,0,0,0,   
  220.         0,0,0,108,108,254,108,108,108,254,108,108,0,0,0,0,   
  221.         24,24,124,198,194,192,124,6,6,134,198,124,24,24,0,0,   
  222.         0,0,0,0,194,198,12,24,48,96,198,134,0,0,0,0,   
  223.         0,0,56,108,108,56,118,220,204,204,204,118,0,0,0,0,   
  224.         0,48,48,48,96,0,0,0,0,0,0,0,0,0,0,0,   
  225.         0,0,12,24,48,48,48,48,48,48,24,12,0,0,0,0,   
  226.         0,0,48,24,12,12,12,12,12,12,24,48,0,0,0,0,   
  227.         0,0,0,0,0,102,60,255,60,102,0,0,0,0,0,0,   
  228.         0,0,0,0,0,24,24,126,24,24,0,0,0,0,0,0,   
  229.         0,0,0,0,0,0,0,0,0,24,24,24,48,0,0,0,   
  230.         0,0,0,0,0,0,0,254,0,0,0,0,0,0,0,0,   
  231.         0,0,0,0,0,0,0,0,0,0,24,24,0,0,0,0,   
  232.         0,0,0,0,2,6,12,24,48,96,192,128,0,0,0,0,   
  233.         0,0,56,108,198,198,214,214,198,198,108,56,0,0,0,0,   
  234.         0,0,24,56,120,24,24,24,24,24,24,126,0,0,0,0,   
  235.         0,0,124,198,6,12,24,48,96,192,198,254,0,0,0,0,   
  236.         0,0,124,198,6,6,60,6,6,6,198,124,0,0,0,0,   
  237.         0,0,12,28,60,108,204,254,12,12,12,30,0,0,0,0,   
  238.         0,0,254,192,192,192,252,6,6,6,198,124,0,0,0,0,   
  239.         0,0,56,96,192,192,252,198,198,198,198,124,0,0,0,0,   
  240.         0,0,254,198,6,6,12,24,48,48,48,48,0,0,0,0,   
  241.         0,0,124,198,198,198,124,198,198,198,198,124,0,0,0,0,   
  242.         0,0,124,198,198,198,126,6,6,6,12,120,0,0,0,0,   
  243.         0,0,0,0,24,24,0,0,0,24,24,0,0,0,0,0,   
  244.         0,0,0,0,24,24,0,0,0,24,24,48,0,0,0,0,   
  245.         0,0,0,6,12,24,48,96,48,24,12,6,0,0,0,0,   
  246.         0,0,0,0,0,126,0,0,126,0,0,0,0,0,0,0,   
  247.         0,0,0,96,48,24,12,6,12,24,48,96,0,0,0,0,   
  248.         0,0,124,198,198,12,24,24,24,0,24,24,0,0,0,0,   
  249.         0,0,0,124,198,198,222,222,222,220,192,124,0,0,0,0,   
  250.         0,0,16,56,108,198,198,254,198,198,198,198,0,0,0,0,   
  251.         0,0,252,102,102,102,124,102,102,102,102,252,0,0,0,0,   
  252.         0,0,60,102,194,192,192,192,192,194,102,60,0,0,0,0,   
  253.         0,0,248,108,102,102,102,102,102,102,108,248,0,0,0,0,   
  254.         0,0,254,102,98,104,120,104,96,98,102,254,0,0,0,0,   
  255.         0,0,254,102,98,104,120,104,96,96,96,240,0,0,0,0,   
  256.         0,0,60,102,194,192,192,222,198,198,102,58,0,0,0,0,   
  257.         0,0,198,198,198,198,254,198,198,198,198,198,0,0,0,0,   
  258.         0,0,60,24,24,24,24,24,24,24,24,60,0,0,0,0,   
  259.         0,0,30,12,12,12,12,12,204,204,204,120,0,0,0,0,   
  260.         0,0,230,102,102,108,120,120,108,102,102,230,0,0,0,0,   
  261.         0,0,240,96,96,96,96,96,96,98,102,254,0,0,0,0,   
  262.         0,0,198,238,254,254,214,198,198,198,198,198,0,0,0,0,   
  263.         0,0,198,230,246,254,222,206,198,198,198,198,0,0,0,0,   
  264.         0,0,124,198,198,198,198,198,198,198,198,124,0,0,0,0,   
  265.         0,0,252,102,102,102,124,96,96,96,96,240,0,0,0,0,   
  266.         0,0,124,198,198,198,198,198,198,214,222,124,12,14,0,0,   
  267.         0,0,252,102,102,102,124,108,102,102,102,230,0,0,0,0,   
  268.         0,0,124,198,198,96,56,12,6,198,198,124,0,0,0,0,   
  269.         0,0,126,126,90,24,24,24,24,24,24,60,0,0,0,0,   
  270.         0,0,198,198,198,198,198,198,198,198,198,124,0,0,0,0,   
  271.         0,0,198,198,198,198,198,198,198,108,56,16,0,0,0,0,   
  272.         0,0,198,198,198,198,214,214,214,254,238,108,0,0,0,0,   
  273.         0,0,198,198,108,124,56,56,124,108,198,198,0,0,0,0,   
  274.         0,0,102,102,102,102,60,24,24,24,24,60,0,0,0,0,   
  275.         0,0,254,198,134,12,24,48,96,194,198,254,0,0,0,0,   
  276.         0,0,60,48,48,48,48,48,48,48,48,60,0,0,0,0,   
  277.         0,0,0,128,192,224,112,56,28,14,6,2,0,0,0,0,   
  278.         0,0,60,12,12,12,12,12,12,12,12,60,0,0,0,0,   
  279.         16,56,108,198,0,0,0,0,0,0,0,0,0,0,0,0,   
  280.         0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,   
  281.         48,48,24,0,0,0,0,0,0,0,0,0,0,0,0,0,   
  282.         0,0,0,0,0,120,12,124,204,204,204,118,0,0,0,0,   
  283.         0,0,224,96,96,120,108,102,102,102,102,124,0,0,0,0,   
  284.         0,0,0,0,0,124,198,192,192,192,198,124,0,0,0,0,   
  285.         0,0,28,12,12,60,108,204,204,204,204,118,0,0,0,0,   
  286.         0,0,0,0,0,124,198,254,192,192,198,124,0,0,0,0,   
  287.         0,0,56,108,100,96,240,96,96,96,96,240,0,0,0,0,   
  288.         0,0,0,0,0,118,204,204,204,204,204,124,12,204,120,0,   
  289.         0,0,224,96,96,108,118,102,102,102,102,230,0,0,0,0,   
  290.         0,0,24,24,0,56,24,24,24,24,24,60,0,0,0,0,   
  291.         0,0,6,6,0,14,6,6,6,6,6,6,102,102,60,0,   
  292.         0,0,224,96,96,102,108,120,120,108,102,230,0,0,0,0,   
  293.         0,0,56,24,24,24,24,24,24,24,24,60,0,0,0,0,   
  294.         0,0,0,0,0,236,254,214,214,214,214,198,0,0,0,0,   
  295.         0,0,0,0,0,220,102,102,102,102,102,102,0,0,0,0,   
  296.         0,0,0,0,0,124,198,198,198,198,198,124,0,0,0,0,   
  297.         0,0,0,0,0,220,102,102,102,102,102,124,96,96,240,0,   
  298.         0,0,0,0,0,118,204,204,204,204,204,124,12,12,30,0,   
  299.         0,0,0,0,0,220,118,102,96,96,96,240,0,0,0,0,   
  300.         0,0,0,0,0,124,198,96,56,12,198,124,0,0,0,0,   
  301.         0,0,16,48,48,252,48,48,48,48,54,28,0,0,0,0,   
  302.         0,0,0,0,0,204,204,204,204,204,204,118,0,0,0,0,   
  303.         0,0,0,0,0,102,102,102,102,102,60,24,0,0,0,0,   
  304.         0,0,0,0,0,198,198,214,214,214,254,108,0,0,0,0,   
  305.         0,0,0,0,0,198,108,56,56,56,108,198,0,0,0,0,   
  306.         0,0,0,0,0,198,198,198,198,198,198,126,6,12,248,0,   
  307.         0,0,0,0,0,254,204,24,48,96,198,254,0,0,0,0,   
  308.         0,0,14,24,24,24,112,24,24,24,24,14,0,0,0,0,   
  309.         0,0,24,24,24,24,0,24,24,24,24,24,0,0,0,0,   
  310.         0,0,112,24,24,24,14,24,24,24,24,112,0,0,0,0,   
  311.         0,0,118,220,0,0,0,0,0,0,0,0,0,0,0,0,   
  312.         0,0,0,0,16,56,108,198,198,198,254,0,0,0,0,0   
  313. };   
  314.   
  315. /* 显示8*16点阵英文字母,反白 */  
  316. void da(unsigned char n,bit un) {   
  317.     unsigned char i;   
  318.     unsigned int k=n;   
  319.     for (i=0;i<16;i++) {   
  320.         ag(x,y*8+i);   
  321.         if (un==0) disp(asc16[k*16+i]); else disp(255-asc16[k*16+i]);   
  322.     }   
  323.     if ((++x)>=16) {   
  324.         x=0;   
  325.         y+=2;   
  326.         if (y>=8) y=0;   
  327.     }   
  328. }   
  329. /* 反白文本/取消 */  
  330. void da8(unsigned char n,bit un) {   
  331.     unsigned char i,j;   
  332.     for (j=0;j<n;j++) {   
  333.         for (i=0;i<8;i++) {   
  334.             ag(x,y*8+i);   
  335.             if (un==0) disp(0xff); else disp(0x0);   
  336.         }   
  337.         if ((++x)>=16) {   
  338.             x=0;   
  339.             y+=1;   
  340.             if (y>=8) y=0;   
  341.         }   
  342.     }   
  343. }   
  344.   
  345. unsigned char code fot[]={   
  346.         /*0时*/0x0,0x8,0x4,0x8,0x7e,0x8,0x44,0x8,0x47,0xfe,0x44,0x8,0x44,0x8,0x7c,0x88,0x44,0x48,   
  347.         0x44,0x48,0x44,0x8,0x44,0x8,0x7c,0x8,0x44,0x48,0x0,0x28,0x0,0x10,   
  348.         /*1间*/0x20,0x4,0x1b,0xfe,0x8,0x4,0x40,0x24,0x4f,0xf4,0x48,0x24,0x48,0x24,0x48,0x24,   
  349.         0x4f,0xe4,0x48,0x24,0x48,0x24,0x48,0x24,0x4f,0xe4,0x48,0x24,0x40,0x14,0x40,0x8,   
  350.         /*2日*/0x0,0x10,0x1f,0xf8,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1f,0xf0,   
  351.         0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1f,0xf0,0x10,0x10,0x0,0x0,   
  352.         /*3期*/0x22,0x4,0x22,0x7e,0x22,0x44,0x7f,0x44,0x22,0x44,0x3e,0x7c,0x22,0x44,0x3e,0x44,   
  353.         0x22,0x44,0x22,0x7c,0xff,0xc4,0x0,0x44,0x24,0x44,0x22,0x84,0x41,0x14,0x82,0x8,   
  354.         /*4闹*/0x40,0x4,0x37,0xfe,0x10,0x4,0x42,0x4,0x41,0x24,0x5f,0xf4,0x41,0x4,0x41,0x24,   
  355.         0x4f,0xf4,0x49,0x24,0x49,0x24,0x49,0x24,0x49,0x64,0x41,0x4,0x41,0x14,0x40,0x8,   
  356.         /*5钟*/0x10,0x20,0x10,0x20,0x10,0x20,0x1c,0x24,0x21,0xfe,0x21,0x24,0x7d,0x24,0x91,0x24,   
  357.         0x11,0x24,0xfd,0xfc,0x11,0x24,0x10,0x20,0x14,0x20,0x18,0x20,0x10,0x20,0x0,0x20,   
  358.         /*6设*/0x1,0xf0,0x21,0x10,0x11,0x10,0x11,0x10,0x1,0x10,0x2,0xe,0xf4,0x0,0x13,0xf8,   
  359.         0x11,0x8,0x11,0x10,0x10,0x90,0x10,0xa0,0x14,0x40,0x18,0xb0,0x13,0xe,0xc,0x4,   
  360.         /*7定*/0x2,0x0,0x1,0x0,0x7f,0xfe,0x40,0x2,0x80,0x24,0x1f,0xf0,0x1,0x0,0x1,0x0,   
  361.         0x11,0x20,0x11,0xf0,0x11,0x0,0x11,0x0,0x11,0x0,0x29,0x6,0x47,0xfc,0x80,0x0,   
  362.         /*8开*/0x0,0x8,0x7f,0xfc,0x8,0x20,0x8,0x20,0x8,0x20,0x8,0x20,0x8,0x24,0xff,0xfe,   
  363.         0x8,0x20,0x8,0x20,0x8,0x20,0x8,0x20,0x10,0x20,0x10,0x20,0x20,0x20,0x40,0x20,   
  364.         /*9关*/0x10,0x10,0x8,0x18,0x4,0x20,0x4,0x48,0x7f,0xfc,0x1,0x0,0x1,0x0,0x1,0x4,   
  365.         0xff,0xfe,0x1,0x0,0x2,0x80,0x2,0x80,0x4,0x40,0x8,0x30,0x30,0xe,0xc0,0x4,   
  366.         /*10星*/0x0,0x8,0x3f,0xfc,0x20,0x8,0x3f,0xf8,0x20,0x8,0x3f,0xf8,0x1,0x0,0x21,0x8,   
  367.         0x3f,0xfc,0x21,0x0,0x41,0x10,0xbf,0xf8,0x1,0x0,0x1,0x4,0xff,0xfe,0x0,0x0,   
  368.         /*11温*/0x0,0x8,0x43,0xfc,0x32,0x8,0x12,0x8,0x83,0xf8,0x62,0x8,0x22,0x8,0xb,0xf8,   
  369.         0x10,0x0,0x27,0xfc,0xe4,0xa4,0x24,0xa4,0x24,0xa4,0x24,0xa4,0x2f,0xfe,0x20,0x0,   
  370.         /*12度*/0x1,0x0,0x0,0x84,0x3f,0xfe,0x22,0x20,0x22,0x28,0x3f,0xfc,0x22,0x20,0x23,0xe0,   
  371.         0x20,0x0,0x2f,0xf0,0x22,0x20,0x21,0x40,0x20,0x80,0x43,0x60,0x8c,0x1e,0x30,0x4,   
  372.         /*13亮*/0x1,0x8,0x7f,0xfc,0x0,0x10,0x1f,0xf8,0x10,0x10,0x10,0x10,0x1f,0xf0,0x0,0x0,   
  373.         0x7f,0xfe,0x40,0x22,0x8f,0xf4,0x8,0x20,0x8,0x20,0x8,0x22,0x10,0x22,0x60,0x1e,   
  374.         /*14湿*/0x0,0x8,0x47,0xfc,0x34,0x8,0x14,0x8,0x87,0xf8,0x64,0x8,0x24,0x8,0xf,0xf8,   
  375.         0x11,0x20,0x21,0x20,0xe9,0x24,0x25,0x28,0x23,0x30,0x21,0x24,0x3f,0xfe,0x20,0x0,   
  376.         /*15报*/0x10,0x8,0x11,0xfc,0x11,0x8,0x11,0x8,0xfd,0x28,0x11,0x10,0x15,0x0,0x19,0xf8,   
  377.         0x31,0x8,0xd1,0x90,0x11,0x50,0x11,0x20,0x11,0x50,0x11,0x8e,0x51,0x4,0x21,0x0,   
  378.         /*16警*/0x14,0x40,0x7f,0x7c,0x10,0xc8,0x3f,0x28,0x55,0x10,0x1d,0x6e,0x3,0x4,0xff,0xfe,   
  379.         0x0,0x0,0x1f,0xf0,0x0,0x0,0x1f,0xf0,0x0,0x0,0x1f,0xf0,0x10,0x10,0x1f,0xf0,   
  380.         /*17火*/0x1,0x0,0x1,0x0,0x1,0x0,0x1,0x0,0x11,0x8,0x11,0x18,0x11,0x20,0x21,0x40,   
  381.         0x42,0x80,0x2,0x80,0x4,0x40,0x4,0x40,0x8,0x20,0x10,0x10,0x20,0xe,0x40,0x4,   
  382.         /*18盗*/0x1,0x0,0x41,0x8,0x33,0xfc,0x12,0x48,0x4,0x40,0x10,0xa0,0x21,0x10,0xc6,0xe,   
  383.         0x40,0x4,0x1f,0xf0,0x12,0x90,0x12,0x90,0x12,0x90,0x12,0x94,0xff,0xfe,0x0,0x0,   
  384.         /*19煤*/0x21,0x10,0x21,0x10,0x21,0x10,0x27,0xfc,0xf9,0x10,0x49,0xf0,0x49,0x10,0x49,0xf0,   
  385.         0x48,0x44,0x8f,0xfe,0x50,0x40,0x20,0xe0,0x51,0x50,0x4a,0x4e,0x84,0x44,0x0,0x40,   
  386.         /*20气*/0x10,0x0,0x10,0x8,0x1f,0xfc,0x20,0x0,0x2f,0xf0,0x40,0x0,0xbf,0xe0,0x0,0x20,   
  387.         0x0,0x20,0x0,0x20,0x0,0x20,0x0,0x20,0x0,0x22,0x0,0x12,0x0,0xa,0x0,0x53,   
  388.         /*21紧*/0x4,0x0,0x25,0xf8,0x25,0x10,0x24,0xa0,0x24,0x40,0x24,0xb0,0x7,0xe,0x4,0x24,   
  389.         0x1f,0xc0,0x1,0x0,0x2,0x10,0x7f,0xf8,0x1,0x8,0x9,0x20,0x11,0x18,0x63,0x8,   
  390.         /*22急*/0x4,0x0,0x4,0x0,0xf,0xe0,0x8,0x40,0x10,0x88,0x3f,0xfc,0x40,0x8,0x1f,0xf8,   
  391.         0x0,0x8,0x3f,0xf8,0x2,0x0,0x51,0x84,0x50,0x92,0x90,0x12,0xf,0xf0,0x0,0x0,   
  392.         /*23电*/0x2,0x0,0x2,0x0,0x2,0x10,0x7f,0xf8,0x42,0x10,0x42,0x10,0x7f,0xf0,0x42,0x10,   
  393.         0x42,0x10,0x7f,0xf0,0x42,0x10,0x2,0x0,0x2,0x4,0x2,0x4,0x1,0xfc,0x0,0x0,   
  394.         /*24话*/0x0,0x10,0x40,0x38,0x33,0xc0,0x10,0x40,0x0,0x40,0x0,0x44,0xf7,0xfe,0x10,0x40,   
  395.         0x10,0x48,0x13,0xfc,0x12,0x8,0x12,0x8,0x16,0x8,0x1a,0x8,0x13,0xf8,0x2,0x8   
  396. };   
  397.        
  398. /* 显示16*16点阵汉字,反白 */  
  399. void dh(unsigned char n,bit un) {   
  400.     unsigned char i,j;   
  401.     unsigned int k=n;   
  402.     for (i=0;i<16;i++) {   
  403.         for (j=0;j<2;j++) {   
  404.             ag(j+x,y*8+i);   
  405.             if (un==0) disp(fot[k*32+i*2+j]); else disp(255-fot[k*32+i*2+j]);   
  406.         }   
  407.     }   
  408.     x+=2;   
  409.     if (x>=16) {   
  410.         x=0;   
  411.         y+=2;   
  412.         if (y>=8) y=0;   
  413.     }   
  414. }   
  415.   
  416. /* 划线 */  
  417. void line(unsigned char x0,unsigned char y0,unsigned char x1,unsigned char y1) {   
  418.     unsigned char x=x1-x0,y=y1-y0,xx,temp;   
  419.     float yy;   
  420.     if (x>y) {   
  421.         yy=y0;   
  422.         for (xx=x0;xx<x1;xx++) {   
  423.             yy+=(float)y/x;   
  424.             ag((xx/8),yy);   
  425.             setb((7-xx&7));   
  426.         }   
  427.     } else {   
  428.         yy=x0;   
  429.         for (xx=y0;xx<y1;xx++) {   
  430.             yy+=(float)x/y;   
  431.             ag(yy/8,xx);   
  432.             setb((7-(char)yy&7));   
  433.         }   
  434.     }   
  435. }   
  436.   
  437. //==============================================   
  438. unsigned char kpush;   
  439. unsigned char code key[]={0,237,221,189,125,231,215,183,119,   
  440. 238,222,190,126,235,219,187,123};   
  441.   
  442. void scankey(void) {   
  443.     unsigned char lie,knew=0;   
  444.     P1=0xf;   
  445.     if ((P1&0xf)!=0xf) {   
  446.         wait10();   
  447.         if ((lie=P1&0xf)!=0xf) {   
  448.             P1=0xf0;   
  449.             knew=P1&0xf0|lie;   
  450.         }   
  451.     }    
  452.     for (lie=0;lie<17;lie++) {   
  453.         if (knew==key[lie]) break;   
  454.     }   
  455.     kpush=lie;   
  456. }   
  457.   
  458.   
  459. /* 定时器0中断 */  
  460. unsigned char s,m,h;   
  461. unsigned int s001;   
  462. void int_t0(void) interrupt 1 {   
  463.     TL0+=48;TH0=0xf8;   
  464.     time++;   
  465.     if ((++s001)>=1000) {   
  466.         s001=0;   
  467.         if ((++s)>59) {   
  468.             s=0;   
  469.             if ((++m)>59) {   
  470.                 m=0;   
  471.                 if ((++h)>23) h=0;   
  472.             }   
  473.         }   
  474.     }   
  475. }   
  476.   
  477. /* 定时器1中断,现用于lcd负压 */  
  478. /* 该部分线路图整理中*/  
  479. void int_t1(void) interrupt 3 {   
  480.     P3=P3^0xc0;   
  481. }   
  482.   
  483. void main(void) {   
  484.     unsigned char i,j;   
  485.     TMOD=0x21;   
  486.     TH1=0;PT0=1;   
  487.     P3=0x7f;   
  488.     EA=1;   
  489.     ET0=1;TR0=1;   
  490.     ET1=1;TR1=1;    
  491.     init();   
  492.        
  493.     dh(10,0);   
  494.     dh(3,0);   
  495.     da(' ',0);   
  496.     da('1',0);   
  497.        
  498.     at(7,0);   
  499.     disp('1'-0x20);   
  500.     disp('2'-0x20);   
  501.     disp(':'-0x20);   
  502.     disp('5'-0x20);   
  503.     disp('9'-0x20);   
  504.     disp(' '-0x20);   
  505.     disp('o'-0x20);   
  506.     disp('n'-0x20);   
  507.        
  508.     at(7,1);   
  509.     disp('1'-0x20);   
  510.     disp('2'-0x20);   
  511.     disp(':'-0x20);   
  512.     disp('5'-0x20);   
  513.     disp('9'-0x20);   
  514.     disp(' '-0x20);   
  515.     disp('o'-0x20);   
  516.     disp('f'-0x20);   
  517.     disp('f'-0x20);   
  518.        
  519.     line(53,0,53,18);   
  520.     line(0,18,128,18);   
  521.        
  522.        
  523.     x=0;y=3;   
  524.     dh(0,0);   
  525.     dh(1,0);   
  526.        
  527.     x=0;y=6;   
  528.     dh(2,0);   
  529.     dh(3,0);   
  530.     da(' ',0);   
  531.     da('1',0);   
  532.     da('9',0);   
  533.     da('9',0);   
  534.     da('8',0);   
  535.     da('-',0);   
  536.     da('1',0);   
  537.     da('2',0);   
  538.     da('-',0);   
  539.     da('2',0);   
  540.     da('9',0);   
  541.        
  542.     // for (i=0;i<128;i++) {   
  543.     //  da(i,i%16,i/16*2);   
  544.     // }   
  545.        
  546.     // while (1) {}   
  547.        
  548.     // at(0,2);   
  549.     // for (i=0;i<16;i++) disp('='-0x20);   
  550.        
  551.        
  552.     // for (i=0;i<8;i++) {   
  553.     //  dh(i,i*2,0);   
  554.     //  dh(i+8,i*2,2);   
  555.     //  dh(i+16,i*2,4);   
  556.     //  dh(i+24,i*2,6);   
  557.     // }   
  558.        
  559.     // while (1) {}   
  560.        
  561.     x=13;   
  562.     y=1;   
  563.     da8(3,0);   
  564.        
  565.     while (1) {   
  566.         scankey();   
  567.         if (kpush==1) {   
  568.             x=0;y=0;   
  569.             dh(10,1);   
  570.             dh(3,1);   
  571.         } else if (kpush==2) {   
  572.             x=0;y=3;   
  573.             dh(0,1);   
  574.             dh(1,1);   
  575.         }   
  576.         x=6;y=3;   
  577.         da(h/10+0x30,0);   
  578.         da(h%10+0x30,0);   
  579.         da(':',0);   
  580.         da(m/10+0x30,0);   
  581.         da(m%10+0x30,0);   
  582.         da(':',0);   
  583.         da(s/10+0x30,0);   
  584.         da(s%10+0x30,0);   
  585.     }   
  586.        
  587. }    
  588.   

 

 
相关文章:

 
最新开源项目
 
 
  查看更多...  
 
本站相关产品   淘宝网店
 




 
  查看更多...  

 

本站程序由百合电子工作室开发和维护
Copyright @ baihe electric studio
渝ICP备09006681号-4