找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1838|回复: 0
打印 上一主题 下一主题
收起左侧

cog12864室内检测系统STM32源程序

[复制链接]
跳转到指定楼层
楼主
ID:559345 发表于 2019-6-29 13:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
利用绘晶cog12864屏幕。显示万年历,温度,湿度,空气质量

单片机源程序如下:
  1. #include "stm32f10x.h"
  2. #include "delay.h"
  3. #include "lcd.h"
  4. #include "ds1302.h"
  5. #include "dht11.h"
  6. #include "key.h"

  7. unsigned char shi[]={
  8.         /*--  文字:  室  --*/
  9. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  10. 0x10,0x0C,0x24,0x24,0xA4,0x64,0x25,0x26,0x24,0x24,0xA4,0x24,0x24,0x14,0x0C,0x00,
  11. 0x40,0x40,0x48,0x49,0x49,0x49,0x49,0x7F,0x49,0x49,0x49,0x4B,0x48,0x40,0x40,0x00,};
  12. unsigned char nei[]={
  13.         /*--  文字:  内  --*/
  14. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  15. 0x00,0xF8,0x08,0x08,0x08,0x08,0x88,0x7F,0x88,0x08,0x08,0x08,0x08,0xF8,0x00,0x00,
  16. 0x00,0xFF,0x00,0x08,0x04,0x02,0x01,0x00,0x00,0x01,0x02,0x4C,0x80,0x7F,0x00,0x00,};
  17. unsigned char jian[]={
  18. /*--  文字:  检  --*/
  19. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  20. 0x10,0x10,0xD0,0xFF,0x90,0x50,0x20,0x50,0x4C,0x43,0x4C,0x50,0x20,0x40,0x40,0x00,
  21. 0x04,0x03,0x00,0xFF,0x00,0x41,0x44,0x58,0x41,0x4E,0x60,0x58,0x47,0x40,0x40,0x00,};
  22. unsigned char ce[]={
  23.         /*--  文字:  测  --*/
  24. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  25. 0x10,0x60,0x02,0x8C,0x00,0xFE,0x02,0xF2,0x02,0xFE,0x00,0xF8,0x00,0xFF,0x00,0x00,
  26. 0x04,0x04,0x7E,0x01,0x80,0x47,0x30,0x0F,0x10,0x27,0x00,0x47,0x80,0x7F,0x00,0x00,};
  27. unsigned char xi[]={
  28.         /*--  文字:  系  --*/
  29. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  30. 0x00,0x00,0x22,0x32,0x2A,0xA6,0xA2,0x62,0x21,0x11,0x09,0x81,0x01,0x00,0x00,0x00,
  31. 0x00,0x42,0x22,0x13,0x0B,0x42,0x82,0x7E,0x02,0x02,0x0A,0x12,0x23,0x46,0x00,0x00,};
  32. unsigned char tong[]={
  33.         /*--  文字:  统  --*/
  34. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  35. 0x20,0x30,0xAC,0x63,0x30,0x00,0x88,0xC8,0xA8,0x99,0x8E,0x88,0xA8,0xC8,0x88,0x00,
  36. 0x22,0x67,0x22,0x12,0x12,0x80,0x40,0x30,0x0F,0x00,0x00,0x3F,0x40,0x40,0x71,0x00,};

  37. unsigned char kong[]={
  38. /*--  文字:  空  --*/
  39. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  40. 0x10,0x0C,0x44,0x24,0x14,0x04,0x05,0x06,0x04,0x04,0x14,0x24,0x44,0x14,0x0C,0x00,
  41. 0x00,0x40,0x40,0x41,0x41,0x41,0x41,0x7F,0x41,0x41,0x41,0x41,0x40,0x40,0x00,0x00,};
  42. unsigned char qi[]={
  43. /*--  文字:  气  --*/
  44. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  45. 0x20,0x10,0x4C,0x47,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0xD4,0x04,0x04,0x00,0x00,
  46. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x30,0x40,0xF0,0x00,};
  47. unsigned char zhi[]={
  48. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  49. 0x00,0x00,0xFE,0x12,0x12,0x92,0x92,0x92,0x92,0xFF,0x91,0x91,0x91,0x91,0x10,0x00,
  50. 0x80,0x60,0x1F,0x80,0x80,0x5F,0x40,0x20,0x10,0x0E,0x10,0x10,0x20,0x5F,0x80,0x00,};
  51. unsigned char liang[]={
  52. /*--  文字:  量  --*/
  53. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  54. 0x20,0x20,0x20,0xBE,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xBE,0x20,0x20,0x20,0x00,
  55. 0x00,0x80,0x80,0xAF,0xAA,0xAA,0xAA,0xFF,0xAA,0xAA,0xAA,0xAF,0x80,0x80,0x00,0x00,
  56. };

  57. unsigned char y[]={
  58. /*--  文字:  优  --*/
  59. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  60. 0x00,0x80,0x60,0xF8,0x07,0x10,0x10,0x10,0xFF,0x10,0xF0,0x11,0x16,0x10,0x10,0x00,
  61. 0x01,0x00,0x00,0xFF,0x00,0x80,0x60,0x1C,0x03,0x00,0x3F,0x40,0x40,0x40,0x78,0x00,};
  62. unsigned char l[]={
  63. /*--  文字:  良  --*/
  64. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  65. 0x00,0x00,0xFC,0x24,0x24,0x24,0x25,0x26,0x24,0x24,0x24,0xFC,0x00,0x00,0x00,0x00,
  66. 0x00,0x00,0xFF,0x81,0x41,0x21,0x03,0x05,0x09,0x11,0x29,0x45,0x42,0x80,0x80,0x00,};
  67. unsigned char z[]={
  68. /*--  文字:  中  --*/
  69. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  70. 0x00,0x00,0xF0,0x10,0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0x10,0xF0,0x00,0x00,0x00,
  71. 0x00,0x00,0x0F,0x04,0x04,0x04,0x04,0xFF,0x04,0x04,0x04,0x04,0x0F,0x00,0x00,0x00,};
  72. unsigned char c[]={
  73. /*--  文字:  差  --*/
  74. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  75. 0x00,0x04,0x24,0x24,0x25,0x26,0xE4,0x3C,0x24,0x26,0x25,0x24,0x24,0x04,0x00,0x00,
  76. 0x41,0x21,0x11,0x89,0x85,0x8B,0x89,0x89,0xF9,0x89,0x89,0x89,0x89,0x81,0x01,0x00,};       


  77. unsigned char zhou[]={
  78. /*--  文字:  周  --*/
  79. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  80. 0x00,0x00,0xFE,0x82,0x92,0x92,0x92,0xFE,0x92,0x92,0x92,0x82,0xFE,0x00,0x00,0x00,
  81. 0x80,0x60,0x1F,0x00,0x00,0x1E,0x12,0x12,0x12,0x1E,0x40,0x80,0x7F,0x00,0x00,0x00,
  82. };
  83. unsigned char yi[]={
  84. /*--  文字:  一  --*/
  85. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  86. 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
  87. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  88. };
  89. unsigned char er[]={
  90. /*--  文字:  二  --*/
  91. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  92. 0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x00,
  93. 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,
  94. };
  95. unsigned char san[]={
  96. /*--  文字:  三  --*/
  97. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  98. 0x00,0x04,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x04,0x00,0x00,
  99. 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
  100. };
  101. unsigned char si[]={
  102. /*--  文字:  四  --*/
  103. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  104. 0x00,0xFC,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0xFC,0x00,0x00,
  105. 0x00,0x7F,0x28,0x24,0x23,0x20,0x20,0x20,0x20,0x21,0x22,0x22,0x22,0x7F,0x00,0x00,
  106. };
  107. unsigned char wu[]={
  108. /*--  文字:  五  --*/
  109. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  110. 0x00,0x02,0x42,0x42,0x42,0xC2,0x7E,0x42,0x42,0x42,0x42,0xC2,0x02,0x02,0x00,0x00,
  111. 0x40,0x40,0x40,0x40,0x78,0x47,0x40,0x40,0x40,0x40,0x40,0x7F,0x40,0x40,0x40,0x00,
  112. };
  113. unsigned char lu[]={
  114. /*--  文字:  六  --*/
  115. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  116. 0x20,0x20,0x20,0x20,0x20,0x20,0x21,0x22,0x2C,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
  117. 0x00,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x01,0x02,0x04,0x18,0x60,0x00,0x00,
  118. };
  119. unsigned char muo[]={
  120. /*--  文字:  末  --*/
  121. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  122. 0x08,0x88,0x88,0x88,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x88,0x88,0x88,0x08,0x00,
  123. 0x20,0x20,0x10,0x08,0x04,0x02,0x01,0xFF,0x01,0x02,0x04,0x08,0x10,0x20,0x20,0x00,
  124. };
  125. unsigned char zi[]={
  126. /*--  文字:  制  --*/
  127. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  128. 0x40,0x50,0x4E,0x48,0x48,0xFF,0x48,0x48,0x48,0x40,0xF8,0x00,0x00,0xFF,0x00,0x00,
  129. 0x00,0x00,0x3E,0x02,0x02,0xFF,0x12,0x22,0x1E,0x00,0x0F,0x40,0x80,0x7F,0x00,0x00,
  130. };
  131. unsigned char zhuo[]={
  132. /*--  文字:  作  --*/
  133. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  134. 0x00,0x80,0x60,0xF8,0x07,0x40,0x30,0x0F,0xF8,0x88,0x88,0x88,0x88,0x08,0x08,0x00,
  135. 0x01,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0xFF,0x08,0x08,0x08,0x08,0x08,0x00,0x00,
  136. };
  137. unsigned char ren[]={
  138. /*--  文字:  人  --*/
  139. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  140. 0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x3F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  141. 0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x03,0x0C,0x10,0x20,0x40,0x80,0x00,
  142. };
  143. unsigned char zhang[]={
  144. /*--  文字:  张  --*/
  145. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  146. 0x02,0xE2,0x22,0x22,0x3E,0x80,0x80,0xFF,0x80,0xA0,0x90,0x88,0x86,0x80,0x80,0x00,
  147. 0x00,0x43,0x82,0x42,0x3E,0x00,0x00,0xFF,0x40,0x21,0x06,0x08,0x10,0x20,0x40,0x00,
  148. };
  149. unsigned char yu[]={
  150. /*--  文字:  宇  --*/
  151. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  152. 0x10,0x0C,0x24,0x24,0x24,0x24,0x25,0xE6,0x24,0x24,0x24,0x24,0x24,0x14,0x0C,0x00,
  153. 0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,
  154. };
  155. unsigned char lon[]={
  156. /*--  文字:  龙  --*/
  157. /*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
  158. 0x10,0x10,0x10,0x10,0x10,0xFF,0x10,0x10,0xF0,0x10,0x11,0x16,0xD0,0x10,0x10,0x00,
  159. 0x80,0x40,0x20,0x18,0x06,0x41,0x20,0x10,0x3F,0x44,0x42,0x41,0x40,0x40,0x78,0x00,
  160. };




  161. int main(void)
  162. {
  163.   int i;       
  164.         u8 time[15];
  165.         u8 temperature;              
  166.         u8 humidity;
  167.        
  168.          delay_init();                  //初始化延时函数
  169.          lcd_gpio_init();
  170.          lcd_init();
  171.        
  172.          DS1302_Init();
  173.         // delay_ms(10);
  174.   // DS1302_Write_Time();

  175.         DHT11_Init();
  176.          
  177.          key_init();
  178.          
  179.          clear_screen();
  180.    delay_ms(150);       
  181.          display_bk();
  182.          delay_ms(150);
  183.          dispaly_16x16(1,3,16,shi);
  184.          delay_ms(50);
  185.          dispaly_16x16(1,3,32,nei);
  186.          delay_ms(50);
  187.          dispaly_16x16(1,3,48,jian);
  188.          delay_ms(50);
  189.          dispaly_16x16(1,3,64,ce);
  190.          delay_ms(50);
  191.          dispaly_16x16(1,3,80,xi);
  192.          delay_ms(50);
  193.          dispaly_16x16(1,3,96,tong);
  194.          delay_ms(50);
  195.          dispaly_16x16(1,5,10,zi);
  196.          delay_ms(50);
  197.          dispaly_16x16(1,5,26,zhuo);
  198.          delay_ms(50);
  199.          dispaly_16x16(1,5,42,ren);
  200.          delay_ms(50);
  201.          dispaly_8x16(1,5,58,":");
  202.          delay_ms(50);
  203.          dispaly_16x16(1,5,66,zhang);
  204.          delay_ms(50);
  205.          dispaly_16x16(1,5,82,yu);
  206.          delay_ms(50);
  207.          dispaly_16x16(1,5,98,lon);
  208.          delay_ms(500);

  209.          clear_screen();



  210.                 dispaly_8x16(1,4,30,"WHITE");
  211.                 delay_ms(50);
  212.                 for(i=0;i<5;i++)
  213.                 {
  214.                   white(170);
  215.                 }
  216.                                                                   
  217.     clear_screen();

  218.         while(1)
  219.         {
  220.                 int m,r;
  221.                 DS1302_Get_Time(time);
  222.          DHT11_Read_Data(&temperature,&humidity);        //读取温湿度值       

  223.         m=temperature;       
  224.         r=humidity;       
  225.                
  226.          dispaly_8x16_t(1,1,0,time[0]);
  227.          dispaly_8x16_t(1,1,8,time[1]);
  228.    dispaly_8x16_t(1,1,16,time[2]);
  229.    dispaly_8x16_t(1,1,24,time[3]);               
  230.    dispaly_8x16(1,1,32,"-");
  231.          dispaly_8x16_t(1,1,40,time[4]);
  232.          dispaly_8x16_t(1,1,48,time[5]);       
  233.    dispaly_8x16(1,1,56,"-");
  234.          dispaly_8x16_t(1,1,64,time[6]);
  235.          dispaly_8x16_t(1,1,72,time[7]);       
  236.          
  237.          dispaly_8x16_t(0,3,0,time[9]);
  238.          dispaly_8x16_t(0,3,8,time[10]);
  239.          dispaly_8x16(0,3,16,":");
  240.          dispaly_8x16_t(0,3,24,time[11]);
  241.          dispaly_8x16_t(0,3,32,time[12]);       
  242.          dispaly_8x16(0,3,40,":");
  243.          dispaly_8x16_t(0,3,48,time[13]);
  244.          dispaly_8x16_t(0,3,56,time[14]);               


  245.    dispaly_8x16(1,5,5,"T");
  246.          dispaly_8x16(1,5,13,":");
  247.    dispaly_8x16_t(1,5,21,m/10%10);       
  248.    dispaly_8x16_t(1,5,29,m/1%10);
  249.          dispaly_8x16(1,5,37,"C.");
  250.    
  251.          dispaly_8x16(1,5,60,"H");
  252.    dispaly_8x16(1,5,68,":");         
  253.    dispaly_8x16_t(1,5,76,r/10%10);
  254.          dispaly_8x16_t(1,5,84,r/1%10);
  255.    dispaly_8x16(1,5,92,"%RH");

  256.    dispaly_16x16(1,7,0,kong);
  257.    dispaly_16x16(1,7,16,qi);
  258.    dispaly_16x16(1,7,32,zhi);
  259.    dispaly_16x16(1,7,48,liang);
  260.          dispaly_8x16(1,7,64,":");






  261.    if(A==0&&B==0)
  262.          {
  263.          dispaly_16x16(1,7,80,y);
  264.         dispaly_8x16(1,7,96," ");         
  265.          }
  266.   
  267.    if(A==0&&B==1)
  268.          {
  269.          dispaly_16x16(1,7,80,l);
  270.         dispaly_8x16(1,7,96," ");         
  271.          }

  272.    if(A==1&&B==0)
  273.          {
  274.          dispaly_16x16(1,7,80,z);
  275.          dispaly_8x16(1,7,96," ");         
  276.          }               

  277.    if(A==1&&B==1)
  278.          {
  279.          dispaly_16x16(1,7,80,c);
  280.          dispaly_8x16(1,7,96,"!");
  281.          }


  282.          
  283.          
  284.        switch(time[8])
  285.                          {
  286.                                   case 1: dispaly_16x16(1,3,90,zhou);
  287.                                             dispaly_16x16(1,3,106,yi);
  288.                                             break;
  289.                                   case 2: dispaly_16x16(1,3,90,zhou);
  290.                                             dispaly_16x16(1,3,106,er);
  291.                                             break;
  292.                                   case 3: dispaly_16x16(1,3,90,zhou);
  293.                                             dispaly_16x16(1,3,106,san);
  294.                                             break;
  295.                                   case 4: dispaly_16x16(1,3,90,zhou);
  296.                                             dispaly_16x16(1,3,106,si);
  297.                                             break;
  298.                                   case 5: dispaly_16x16(1,3,90,zhou);
  299.                                             dispaly_16x16(1,3,106,wu);
  300.                                             break;
  301.                                   case 6: dispaly_16x16(1,3,90,zhou);
  302.                                             dispaly_16x16(1,3,106,lu);
  303.                                             break;
  304.                                   case 7: dispaly_16x16(1,3,90,zhou);
  305.                                             dispaly_16x16(1,3,106,muo);
  306.                                             break;                                 
  307.                                  
  308.                                  
  309.                                  
  310.                          }
  311.        

  312.        
  313.        
  314.         }
  315. }
  316. //  dispaly_8x16(1,5,38,"C.");
  317. //
  318. //  dispaly_8x16(1,5,91,"%RH");

  319. //        if( Read_DHT11(&DHT11_Data)==SUCCESS)
  320. //        {

  321. //
  322. ////DHT11_Data.humi_int,DHT11_Data.humi_deci,DHT11_Data.temp_int,DHT11_Data.temp_deci;
  323. //               
  324. //        dispaly_8x16_t(1,5,10,temp_int);
  325.        
  326. //        dispaly_8x16(1,5,38,"C.");
  327. //        dispaly_8x16_t(1,5,50,humi_int);
  328. //  dispaly_8x16_t(1,5,60,humi_deci);         
  329. //  dispaly_8x16(1,5,91,"%RH");               
  330. //               
  331. //               
  332. //               
  333. //        }
复制代码

所有程序51hei提供下载:
室内检测系统.7z (189.54 KB, 下载次数: 32)


评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表