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

📄 checktime.lst

📁 本人开发的测量水的浊度的仪器
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.06   CHECKTIME                                                             04/09/2005 13:15:55 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE CHECKTIME
OBJECT MODULE PLACED IN checktime.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE checktime.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #include "checktime.h"
   2          #include "lcd.h"
   3          #include "common.h"
   4          #include "ds1302.h"
   5          #include "system.h"
   6          
   7          #define DISPLAYTIMEX 1
   8          #define DISPLAYTIMEY 12
   9          
  10          #define hex2digit(ch) (ch+'0')
  11          
  12          idata volatile uchar time[12];
  13          void setcursorpos(uchar pos)
  14          {
  15   1              static uchar cursorpos=0;
  16   1              ushort addr;
  17   1              
  18   1              setcursordirection(CURSORRIGHT);
  19   1              addr = DISPLAYTIMEY*320+640+cursorpos*2+DISPLAYTIMEX;
  20   1              setcursoraddr(addr);
  21   1              writecmd(0x42);
  22   1              writedat(0x00);
  23   1              writedat(0x00);
  24   1              
  25   1              cursorpos = pos;
  26   1              addr = DISPLAYTIMEY*320+640+cursorpos*2+DISPLAYTIMEX;
  27   1              setcursoraddr(addr);
  28   1              writecmd(0x42);
  29   1              writedat(0x3f);
  30   1              writedat(0xfc);
  31   1      }
  32          
  33          uchar isbigmonth(uchar month)
  34          {
  35   1              if(month < 8)
  36   1                      return month&0x01;
  37   1              else
  38   1                      return !(month&0x01);
  39   1      }
  40          
  41          #if 0
              void increasetime(uchar pos)
              {
                      uchar tmp,idx,leapyear,month;
                      uchar buf[2];
              
                      if(pos == 0 || pos == 1)
                              return;
              
                      if((time[0]*10+time[1])/4) 
                              leapyear = 0;
                      else
                              leapyear = 1;
                      month = time[2]*10+time[3];
              
C51 COMPILER V7.06   CHECKTIME                                                             04/09/2005 13:15:55 PAGE 2   

                      tmp = (pos-2)/3;
                      idx = tmp*2;
                      if(!(pos%3)) idx++;
              
                      switch(idx)
                      {
                      case 0://year10
                      case 1://year0
                              time[idx]++;
                              if(time[idx] > 9)
                                      time[idx] = 0;
                      break;
                      case 2://month10
                              if(time[2])
                              {
                                      if(time[3])
                                              time[2] = 0;
                              }
                              else
                              {
                                      if(time[3] < 3)
                                              time[2] = 1;
                              }
                      break;
                      case 3://month0
                              if(time[2] == 1)
                              {
                                      if(time[3] < 2)
                                              time[3]++;
                                      else
                                              time[3] = 0;
                              } 
                              else
                              {
                                      time[3]++;
                                      if(time[3] > 9)
                                              time[3] = 1;
                              }
                      break;
                      case 4://date10
                              if(month == 2)
                              {
                                      if(time[4] < 1)
                                              time[4]++;
                                      else
                                      {
                                              if(leapyear)
                                              {
                                                      time[4]++; 
                                              }
                                              else
                                              {
                                                      if(time[5] < 9)
                                                      time[4]++;
                                              }
                                      }
                              }
                              else
                              {
                                      if(time[4] < 2)
                                              time[4]++;
                                      else
C51 COMPILER V7.06   CHECKTIME                                                             04/09/2005 13:15:55 PAGE 3   

                                      {
                                              if(isbigmonth(month))
                                              {
                                                      if(time[5] < 2)
                                                              time[4]++;
                                              }
                                              else
                                              {
                                                      if(time[5] < 1)
                                                              time[4]++;
                                              }
                                      }
                              }
                      break;
                      case 5://date0
                              if(month == 2)
                              {
                                      if(time[4] < 2)
                                      {
                                              if(time[5] < 9)
                                                      time[5]++;
                                      }
                                      else
                                      {
                                              if(leapyear)
                                              {
                                                      if(time[5] < 9)
                                                              time[5]++;
                                              }
                                              else
                                              {
                                                      if(time[5] < 8)
                                                              time[5]++;
                                              }
                                      }
                              }
                              else
                              {
                                      if(time[4] < 3)
                                      {
                                              if(time[5] < 9)
                                                      time[5]++;
                                      }
                                      else
                                      {
                                              if(isbigmonth(month))
                                              {
                                                      if(time[5] < 1)
                                                              time[5]++;
                                              }
                                      }
                              }
                      break;
                      case 6://hour10
                              if(time[6] < 2) 
                                      time[6]++;
                              else
                                      time[6] = 0;
                      break;
                      case 7://hour0
                              if(time[6] < 2)
                              {
C51 COMPILER V7.06   CHECKTIME                                                             04/09/2005 13:15:55 PAGE 4   

                                      if(time[7] < 9)
                                              time[7]++;
                              }
                              else
                              {
                                      if(time[7] < 3)
                                              time[7]++;
                              }
                      break;
                      case 8://minute10
                      case 10://second10
                              if(time[idx] < 5)
                                      time[idx]++;
                              else
                                      time[idx] = 0;
                      break;
                      case 9://minute0
                      case 11://second0
                              if(time[idx] < 9)
                                      time[idx]++;
                              else
                                      time[idx] = 0;
                      break;
                      }
              
                      buf[0] = hex2digit(time[idx]);
                      buf[1] = 0;
                      printstring16(0,DISPLAYTIMEX+pos*2,DISPLAYTIMEY,buf);
                      setcursorpos(pos);
              }
              
              void decreasetime(uchar pos)
              {
                      uchar tmp,idx;
                      uchar buf[2];
              
                      if(pos == 0 || pos == 1)
                              return;
              
              
                      tmp = (pos-2)/3;
                      idx = tmp*2;
                      if(!(pos%3)) idx++;
              
                      switch(idx)
                      {
                      case 0://year10
                      case 1://year0
                              time[idx]++;
                              if(time[idx] > 9)
                                      time[idx] = 0;
                      break;
                      case 2://month10

⌨️ 快捷键说明

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