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

📄 1602.lst

📁 多功能太阳能定时器程序(液晶)
💻 LST
📖 第 1 页 / 共 5 页
字号:
1159   1      }
1160          
1161          /****************************************************************************
1162          写入汉字
1163          ****************************************************************************/
1164          void write_character(unsigned char x,unsigned char y,unsigned char *ptr,bit fanhei)
1165          {
1166   1       unsigned char i,j;
1167   1       unsigned char number,k=0;
1168   1       unsigned char cl,ch;
1169   1       unsigned char fanheizi=0;
1170   1       unsigned char Page,Row;
C51 COMPILER V8.02   1602                                                                  04/21/2008 20:44:58 PAGE 20  

1171   1      
1172   1       cl=ptr[0];
1173   1       ch=ptr[1];
1174   1       for(number=0;;number++)
1175   1       {
1176   2        if((cl==GB_16[number].Index[0])&&(ch==GB_16[number].Index[1]))
1177   2        {
1178   3         Page=x|0xb8;
1179   3         if((y>=0)&&(y<8))
1180   3         {
1181   4          Row=(y*8)|0x40;
1182   4      
1183   4          write_cmdl(Page);
1184   4          write_cmdl(Row);
1185   4      
1186   4          for(j=0;j<2;j++)
1187   4          {
1188   5           for(i=0;i<16;i++)
1189   5           {
1190   6                if(fanhei==1)
1191   6                {
1192   7             fanheizi=255-GB_16[number].Msk[k];
1193   7                }
1194   6                else
1195   6                {
1196   7                 fanheizi=GB_16[number].Msk[k];
1197   7                }
1198   6            write_datal(fanheizi);
1199   6                k++;
1200   6           }
1201   5           write_cmdl(Row);
1202   5           write_cmdl(Page+1);
1203   5          }
1204   4         }
1205   3      
1206   3         if((y>=8)&&(y<16))
1207   3         {
1208   4          y=y-8;
1209   4          Row=(y*8)|0x40;
1210   4      
1211   4          write_cmdr(Page);
1212   4          write_cmdr(Row);
1213   4      
1214   4          for(j=0;j<2;j++)
1215   4          {
1216   5           for(i=0;i<16;i++)
1217   5           {
1218   6                if(fanhei==1)
1219   6                {
1220   7             fanheizi=255-GB_16[number].Msk[k];
1221   7                }
1222   6                else
1223   6                {
1224   7                 fanheizi=GB_16[number].Msk[k];
1225   7                }
1226   6            write_datar(fanheizi);
1227   6                k++;
1228   6           }
1229   5           write_cmdr(Row);
1230   5           write_cmdr(Page+1);
1231   5          }
1232   4         }
C51 COMPILER V8.02   1602                                                                  04/21/2008 20:44:58 PAGE 21  

1233   3         break;
1234   3        }
1235   2       }
1236   1      }
1237          
1238          /****************************************************************************
1239          写入天干地支
1240          ****************************************************************************/
1241          void write_yearlunar(unsigned char x,unsigned char y,unsigned char lunar,bit tiandi)
1242          {
1243   1       unsigned char i,j;
1244   1       unsigned char k=0;
1245   1       unsigned char yearlunar;
1246   1       unsigned char Page,Row;
1247   1      
1248   1       Page=x|0xb8;
1249   1       if((y>=0)&&(y<8))
1250   1       {
1251   2        Row=(y*8)|0x40;
1252   2      
1253   2        write_cmdl(Page);
1254   2        write_cmdl(Row);
1255   2      
1256   2        for(j=0;j<2;j++)
1257   2        {
1258   3         for(i=0;i<16;i++)
1259   3         {
1260   4              if(tiandi==1)
1261   4              {
1262   5           yearlunar=tiangan[lunar*32+k];
1263   5              }
1264   4          else
1265   4          {
1266   5               yearlunar=dizhi[lunar*32+k];
1267   5          }
1268   4          write_datal(yearlunar);
1269   4          k++;
1270   4         }
1271   3         write_cmdl(Row);
1272   3         write_cmdl(Page+1);
1273   3        }
1274   2       }
1275   1      
1276   1       if((y>=8)&&(y<16))
1277   1       {
1278   2        y=y-8;
1279   2        Row=(y*8)|0x40;
1280   2      
1281   2        write_cmdr(Page);
1282   2        write_cmdr(Row);
1283   2      
1284   2        for(j=0;j<2;j++)
1285   2        {
1286   3         for(i=0;i<16;i++)
1287   3         {
1288   4              if(tiandi==1)
1289   4              {
1290   5           yearlunar=255-tiangan[lunar*32+k];
1291   5              }
1292   4          else
1293   4          {
1294   5               yearlunar=dizhi[lunar*32+k];
C51 COMPILER V8.02   1602                                                                  04/21/2008 20:44:58 PAGE 22  

1295   5          }
1296   4          write_datar(yearlunar);
1297   4          k++;
1298   4         }
1299   3         write_cmdr(Row);
1300   3         write_cmdr(Page+1);
1301   3        }
1302   2       }
1303   1      }
1304          /****************************************************************************
1305          DS18B20初始化
1306          ****************************************************************************/
1307          bit reset_ds18b20(void)
1308          {
1309   1       bit presence;
1310   1      
1311   1       DQ=0;       
1312   1       delayus(70);    
1313   1       DQ=1;    
1314   1       delayus(3); 
1315   1       presence=DQ;
1316   1       delayus(25);    
1317   1       return presence; 
1318   1      }   
1319          
1320          /****************************************************************************
1321          读一字节温度值
1322          ****************************************************************************/
1323          unsigned char read_ds18b20(void)
1324          {
1325   1       unsigned char i;
1326   1       unsigned char value = 0;
1327   1      
1328   1       for(i=8;i>0;i--)
1329   1       {
1330   2        value=value>>1;
1331   2        DQ=0; 
1332   2        DQ=1;
1333   2        delayus(1);  
1334   2        if(DQ)
1335   2        {
1336   3         value=value|0x80;
1337   3        }
1338   2        delayus(6); 
1339   2       }
1340   1        return(value);
1341   1      }
1342          
1343          /****************************************************************************
1344          写一字节命令
1345          ****************************************************************************/
1346          void write_ds18b20(unsigned char value)
1347          {
1348   1       unsigned char i;
1349   1       for(i=8;i>0;i--)
1350   1       {
1351   2        DQ=0; 
1352   2        DQ=value&0x01;
1353   2        delayus(5); 
1354   2        DQ=1;
1355   2        value=value>>1;
1356   2       }
C51 COMPILER V8.02   1602                                                                  04/21/2008 20:44:58 PAGE 23  

1357   1       delayus(5);
1358   1      }
1359          
1360          /****************************************************************************
1361          读出温度值
1362          ****************************************************************************/
1363          unsigned char read_temp(void)
1364          {
1365   1       unsigned char i,count;
1366   1       unsigned int temp_v;
1367   1       unsigned int x;
1368   1       unsigned char temp[2];
1369   1      
1370   1       reset_ds18b20();
1371   1       write_ds18b20(0xcc);
1372   1       write_ds18b20(0x44); 
1373   1       reset_ds18b20();
1374   1       write_ds18b20(0xcc);
1375   1       write_ds18b20(0xbe); 
1376   1       temp[1]=read_ds18b20();
1377   1       temp[0]=read_ds18b20();
1378   1       tempflag=0; 
1379   1       if((temp[0]&0xf8)!=0x00)
1380   1       {
1381   2        tempflag=1; 
1382   2        temp[1]=~temp[1];
1383   2        temp[0]=~temp[0]; 
1384   2        temp_v=temp[1]+1;  
1385   2        temp[1]=temp_v;   
1386   2        if(temp_v>255)
1387   2        {
1388   3         temp[0]++; 
1389   3        } 
1390   2       }
1391   1      
1392   1       x=((temp[0]&0x07)*256+temp[1])>>4;
1393   1       temp[1]=temp[1]&0x0f;
1394   1       temp[1]=divdisplay[temp[1]];
1395   1      
1396   1       for(i=0;i<8;i++)
1397   1       {
1398   2        bcddis[i]=0;
1399   2       }
1400   1      
1401   1       i=0;
1402   1       bcddis[0]=temp[1];
1403   1       i++;
1404   1      
1405   1       bcddis[1]=10;
1406   1       i++;
1407   1      
1408   1       while(x/10)
1409   1       {
1410   2        bcddis[i]=x%10;
1411   2        x=x/10;
1412   2        i++;
1413   2       }
1414   1       bcddis[i]=x;
1415   1       i++;
1416   1       count=i;
1417   1       if(tempflag==1)
1418   1       {
C51 COMPILER V8.02   1602                                                                  04/21/2008 20:44:58 PAGE 24  

1419   2        bcddis[i]=13;//-
1420   2       }
1421   1       else
1422   1       {
1423   2        bcddis[i]=12;//+
1424   2       }
1425   1       
1426   1       return count;
1427   1      }
1428          
1429          /****************************************************************************
1430          显示三路温度值
1431          ****************************************************************************/
1432          void tempdisplay(void)
1433          {
1434   1       unsigned char i;
1435   1       unsigned char count;
1436   1       clear();
1437   1       write_character(0,2,"温",0);
1438   1       write_character(0,4,"度",0);
1439   1       write_character(2,2,"热",0);
1440   1       write_character(2,4,"水",0);
1441   1       write_character(2,6,"箱",0);
1442   1       write_character(4,2,"水",0);
1443   1       write_character(4,4,"管",0);
1444   1       write_character(6,2,"集",0);
1445   1       write_character(6,4,"热",0);
1446   1       write_character(6,6,"器",0);
1447   1       write_character(0,10,"℃",0);  
1448   

⌨️ 快捷键说明

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