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

📄 带农历带生肖.lst

📁 12864液晶显示控制器为ST7920 12864液晶显示控制器为ST7920
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.08   確农繽確蒧肖                                                          01/25/2009 10:21:59 PAGE 1   


C51 COMPILER V8.08, COMPILATION OF MODULE 確农繽確蒧肖
OBJECT MODULE PLACED IN 带农历带生肖.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE 带农历带生肖.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          //头文件
   2          #include <REG52.h>
   3          #include <string.h>
   4          #include <intrins.h>
   5          
   6          #define uint  unsigned int
   7          #define uchar unsigned char
   8          /*****************************************************************************/
   9          
  10          
  11          
  12          sbit LCM_cs   = P2^5;
  13          sbit LCM_std  = P2^6;
  14          sbit LCM_sclk = P2^7;
  15          sbit LCM_psb  = P2^3;   //H=并口; L=串口;
  16          sbit LCM_rst  = P2^4;   //Reset Signal 低电平有效
  17          
  18          
  19          sbit    beep   = P1^2;
  20          /*****************************************************************************/
  21          //温度传感器定义
  22          sbit DQ = P1^ 0;//ds18B20
  23          /*****************************************************************************/
  24          //键盘引脚定义
  25          sbit KEY_1 = P3^4;       //左上
  26          sbit KEY_2 = P3^5;       //左下
  27          sbit KEY_3 = P3^6;       //右上
  28          sbit KEY_4 = P3^7;       //右下  
  29          
  30          //定义DS1302时钟接口
  31          sbit  DS1302_CLK = P1^3;              //实时时钟时钟线引脚 
  32          sbit  DS1302_IO  = P1^4;              //实时时钟数据线引脚 
  33          sbit  DS1302_RST = P1^7;              //实时时钟复位线引脚/***********************************************
             -******************************/
  34          //定义累加器A中的各位
  35          sbit  ACC0 = ACC^0;
  36          sbit  ACC7 = ACC^7;
  37          /*****************************************************************************/
  38          //定义全局变量
  39          unsigned char yy,mo,dd,xq,hh,mm,ss,e;//定义时间映射全局变量(专用寄存器)
  40          
  41          bit c_moon;
  42          data uchar year_moon,month_moon,day_moon,week;
  43          
  44          bit w = 0; //调时标志位
  45          static unsigned char menu = 0;//定义静态小时更新用数据变量
  46          static unsigned char keys = 0;//定义静态小时更新用数据变量
  47          static unsigned char timecount = 0;//定义静态软件计数器变量
  48          uchar code tab1[]={
  49          "  电子万年历    "
  50          "  版本: V1.0   "
  51          "2008年11月22日夜"
  52          "      张强      "
  53          };
  54          /****************************************************************************/
C51 COMPILER V8.08   確农繽確蒧肖                                                          01/25/2009 10:21:59 PAGE 2   

  55          void DelayM(unsigned int a)       //延时函数 1MS/次     
  56          {
  57   1                      unsigned char i;
  58   1                      while( --a != 0)
  59   1             {                
  60   2                              for(i = 0; i < 125; i++);  //一个 ; 表示空语句,CPU空转。
  61   2                      }                                  //i 从0加到125,CPU大概就耗时1毫秒
  62   1      }
  63          /****************************************************************************/
  64          //函数声明
  65          void LCM_WriteString(unsigned char *str) ;  //写字符  例:LCM_WriteString("您好!");
  66          void LCM_WriteDatOrCom(bit ,unsigned char );  //(0,指令) (1,数据)
  67          void LCM_w_byte(unsigned char bbyte);  //写一个字节给LCM
  68          void delaynms(unsigned int di);  //延时
  69          void LCM_init(void); //LCM初始化
  70          void LCM_clr(void);  //清屏
  71          void Delay(int num);
  72          bit get_moon_day(uchar month_p,uint table_addr);
  73          void Conversion(bit c,uchar year,uchar month,uchar day);
  74          void nl();
  75          void days (viod)  //公历节日数据库
  76          {        
  77   1                      
  78   1                      LCM_WriteDatOrCom(0,0x80);
  79   1      //              LCM_WriteString("[Dis]      [Set]");
  80   1      
  81   1                      LCM_WriteDatOrCom(0,0x98);
  82   1      //                                                                                              ----|----------------|
  83   1      
  84   1                      if ( mo == 0x01 && dd == 0x01 ){ LCM_WriteString("Happy New Year!!"); }//1月
  85   1                      if ( mo == 0x01 && dd == 0x28 ){ LCM_WriteString("  世界麻风日    "); }
  86   1                      if (month_moon== 0x01 && day_moon == 0x01 ){  LCM_WriteString("    今日春节    ");  }                   
             -                               
  87   1                      if (month_moon== 0x01 && day_moon == 0x15 ){ LCM_WriteString("  元宵节快乐    "); }   
  88   1                                                                                                    
  89   1                
  90   1              if (month_moon== 0x02 && day_moon == 0x02 ){ LCM_WriteString("    青龙节      "); }  
  91   1                      if ( mo == 0x02 && dd == 0x02 ){ LCM_WriteString("  世界湿地日    "); }//2月
  92   1                      if ( mo == 0x02 && dd == 0x13 ){ LCM_WriteString("  明天情人节了  "); }         
  93   1                      if ( mo == 0x02 && dd == 0x14 ){ LCM_WriteString("  今天是情人节  "); }
  94   1                                      
  95   1                      if ( mo == 0x03 && dd == 0x01 ){ LCM_WriteString("  国际海豹日    "); }//3月            
  96   1                      if ( mo == 0x03 && dd == 0x03 ){ LCM_WriteString("  全国爱耳日    "); }         
  97   1                      if ( mo == 0x03 && dd == 0x08 ){ LCM_WriteString("   3.8妇女节    "); }         
  98   1                      if ( mo == 0x03 && dd == 0x12 ){ LCM_WriteString("    植树节      "); }         
  99   1                      if ( mo == 0x03 && dd == 0x14 ){ LCM_WriteString("  国际警察日    "); }         
 100   1                      if ( mo == 0x03 && dd == 0x15 ){ LCM_WriteString("  消费者权益日  "); }         
 101   1                      if ( mo == 0x03 && dd == 0x17 ){ LCM_WriteString("  国际航海日    "); }         
 102   1                      if ( mo == 0x03 && dd == 0x21 ){ LCM_WriteString("  世界森林日    "); }         
 103   1                      if ( mo == 0x03 && dd == 0x22 ){ LCM_WriteString("    世界水日    "); }         
 104   1                      if ( mo == 0x03 && dd == 0x23 ){ LCM_WriteString("  世界气象日    "); }         
 105   1                      if ( mo == 0x03 && dd == 0x24 ){ LCM_WriteString("世界防治结核病日"); }
 106   1                                      
 107   1                      if ( mo == 0x04 && dd == 0x01 ){ LCM_WriteString("愚人节  小心上当"); }//4              
 108   1                      if ( mo == 0x04 && dd == 0x07 ){ LCM_WriteString("  世界卫生日    "); }         
 109   1                      if ( mo == 0x04 && dd == 0x08 ){ LCM_WriteString("    复活节      "); }         
 110   1                      if ( mo == 0x04 && dd == 0x13 ){ LCM_WriteString("  黑色星期五    "); }
 111   1                      
 112   1                  if (month_moon== 0x05 && day_moon == 0x05 ){ LCM_WriteString("    端午节      "); }                 
 113   1                      if ( mo == 0x05 && dd == 0x01 ){ LCM_WriteString("  劳动节  放假  "); }//5              
 114   1                      if ( mo == 0x05 && dd == 0x04 ){ LCM_WriteString("    青年节      "); }         
 115   1                      if ( mo == 0x05 && dd == 0x08 ){ LCM_WriteString("  世界红十字日  "); }         
C51 COMPILER V8.08   確农繽確蒧肖                                                          01/25/2009 10:21:59 PAGE 3   

 116   1                      if ( mo == 0x05 && dd == 0x12 ){ LCM_WriteString("  国际护士节    "); }         
 117   1                      if ( mo == 0x05 && dd == 0x05 ){ LCM_WriteString("近日注意母亲节  "); }         
 118   1                      if ( mo == 0x05 && dd == 0x15 ){ LCM_WriteString("  国际家庭日    "); }
 119   1                      if ( mo == 0x05 && dd == 0x31 ){ LCM_WriteString("  世界无烟日    "); }         
 120   1                                      
 121   1                      if ( mo == 0x06 && dd == 0x01 ){ LCM_WriteString("  国际儿童节    "); }//6
 122   1                      if ( mo == 0x06 && dd == 0x05 ){ LCM_WriteString("  世界环境日    "); }         
 123   1                      if ( mo == 0x06 && dd == 0x26 ){ LCM_WriteString("  国际禁毒日    "); }         
 124   1                      if ( mo == 0x06 && dd == 0x06 ){ LCM_WriteString("  全国爱眼日    "); }         
 125   1                      if ( mo == 0x06 && dd == 0x13 ){ LCM_WriteString("近日注意父亲节  "); }
 126   1                      if ( mo == 0x06 && dd == 0x15 ){ LCM_WriteString("近日注意父亲节  "); }
 127   1                      
 128   1              if (month_moon== 0x07 && day_moon == 0x07 ){ LCM_WriteString("乞巧节中国情人节"); }  
 129   1              if (month_moon== 0x07 && day_moon == 0x15 ){ LCM_WriteString("    中元节      "); }             
 130   1                      if ( mo == 0x07 && dd == 0x01 ){ LCM_WriteString("香港回归记念日  "); }//7
 131   1                      if ( mo == 0x07 && dd == 0x07 ){ LCM_WriteString("抗日战争记念日  "); }
 132   1                      if ( mo == 0x07 && dd == 0x11 ){ LCM_WriteString("  世界人口日    "); }
 133   1      
 134   1                  if (month_moon== 0x08 && day_moon == 0x15 ){ LCM_WriteString("  中秋节快乐    "); }  
 135   1                      if ( mo == 0x08 && dd == 0x01 ){ LCM_WriteString("  八一建军节    "); }//8
 136   1                      if ( mo == 0x08 && dd == 0x08 ){ LCM_WriteString("  中国男子节    "); }
 137   1                      if ( mo == 0x08 && dd == 0x15 ){ LCM_WriteString("抗战胜利记念日  "); }
 138   1      
 139   1              if (month_moon== 0x09 && day_moon == 0x09 ){ LCM_WriteString("  今日重阳节    "); }  
 140   1                      if ( mo == 0x09 && dd == 0x10 ){ LCM_WriteString("  中国教师节    "); }//9
 141   1                      if ( mo == 0x09 && dd == 0x18 ){ LCM_WriteString("九·一八事变记念"); }
 142   1                      if ( mo == 0x09 && dd == 0x20 ){ LCM_WriteString("  国际爱牙日    "); }
 143   1                      if ( mo == 0x09 && dd == 0x27 ){ LCM_WriteString("  世界旅游日    "); }
 144   1      
 145   1                      if ( mo == 0x10 && dd == 0x01 ){ LCM_WriteString("  中国国庆节    "); }//10
 146   1                      if ( mo == 0x10 && dd == 0x04 ){ LCM_WriteString("  世界动物日    "); }
 147   1                      if ( mo == 0x10 && dd == 0x24 ){ LCM_WriteString("    联合国日    "); }
 148   1                      if ( mo == 0x10 && dd == 0x12 ){ LCM_WriteString("明天国际教师节  "); }
 149   1                      if ( mo == 0x10 && dd == 0x13 ){ LCM_WriteString("  国际教师节    "); }
 150   1      
 151   1                      if ( mo == 0x11 && dd == 0x10 ){ LCM_WriteString("  世界青年节    "); }//11
 152   1                      if ( mo == 0x11 && dd == 0x17 ){ LCM_WriteString("  世界学生节    "); }
 153   1      
 154   1                  if (month_moon== 0x12 && day_moon == 0x08 ){ LCM_WriteString("  今日腊八节    "); }  
 155   1              if (month_moon== 0x12 && day_moon == 0x15 ){ LCM_WriteString("  过小年        "); }  
 156   1              if (month_moon== 0x12 && day_moon == 0x29 ){ LCM_WriteString("  腊月二十九    "); }  
 157   1              if (month_moon== 0x12 && day_moon == 0x30 ){ LCM_WriteString("  大年三十(^o^) "); }
 158   1                      if ( mo == 0x12 && dd == 0x01 ){ LCM_WriteString("  世界艾滋病日  "); }//12
 159   1                      if ( mo == 0x12 && dd == 0x23 ){ LCM_WriteString("  明晚平安夜    "); }
 160   1                      if ( mo == 0x12 && dd == 0x24 ){ LCM_WriteString("  今晚平安夜    "); }
 161   1                      if ( mo == 0x12 && dd == 0x25 ){ LCM_WriteString("    圣诞快乐    "); }
 162   1                      if ( mo == 0x12 && dd == 0x31 ){ LCM_WriteString("    明日新年    "); }
 163   1      
 164   1                      else{ 
 165   2                              if ( hh >= 0x04 && hh <  0x06 ){ LCM_WriteString("★★__▲▲__凌晨"); }
 166   2                              if ( hh >= 0x06 && hh <  0x08 ){ LCM_WriteString("☆○__▲△__早晨"); }
 167   2                              if ( hh >= 0x08 && hh <  0x12 ){ LCM_WriteString("__●__▲▲__上午"); }
 168   2                              if ( hh == 0x12)               { LCM_WriteString("____▲●▲__中午"); }
 169   2                              if ( hh >= 0x13 && hh <  0x18 ){ LCM_WriteString("__▲▲__●__下午"); }
 170   2                              if ( hh >= 0x18 && hh <  0x22 ){ LCM_WriteString("△▲__●☆__晚上"); }
 171   2                              if ( hh >= 0x22 && hh <= 0x23 ){ LCM_WriteString("△▲__★☆__夜里"); }
 172   2                              if ( hh >= 0x00 && hh <  0x04 ){ LCM_WriteString("__★▲▲★__深夜"); }
 173   2                              }
 174   1      
 175   1      
 176   1      
 177   1      }
C51 COMPILER V8.08   確农繽確蒧肖                                                          01/25/2009 10:21:59 PAGE 4   

 178          /****************************************************************************/
 179          //初始化LCM
 180          void LCM_init(void)      
 181          {
 182   1        LCM_rst=1;
 183   1        LCM_psb=0;
 184   1        LCM_WriteDatOrCom (0,0x30);  /*30---基本指令动作*/   
 185   1         LCM_WriteDatOrCom (0,0x01);  /*清屏,地址指针指向00H*/
 186   1        Delay (100);
 187   1         LCM_WriteDatOrCom (0,0x06);  /*光标的移动方向*/
 188   1         LCM_WriteDatOrCom(0,0x0c);  /*开显示,关游标*/
 189   1       
 190   1      }
 191          /******************************************************************************/
 192          //写指令或数据  (0,指令) (1,数据)
 193          void LCM_WriteDatOrCom(bit dat_comm,uchar content)
 194           {
 195   1        uchar a,i,j;
 196   1        Delay(50);
 197   1        a=content;
 198   1        LCM_cs=1;
 199   1        LCM_sclk=0;
 200   1        LCM_std=1;
 201   1        for(i=0;i<5;i++)
 202   1        {
 203   2          LCM_sclk=1;
 204   2          LCM_sclk=0;
 205   2        }
 206   1        LCM_std=0;
 207   1        LCM_sclk=1;
 208   1        LCM_sclk=0;
 209   1        if(dat_comm)
 210   1          LCM_std=1;   //data
 211   1        else
 212   1         LCM_std=0;   //command
 213   1        LCM_sclk=1;
 214   1        LCM_sclk=0;
 215   1        LCM_std=0;
 216   1        LCM_sclk=1;
 217   1        LCM_sclk=0;
 218   1        for(j=0;j<2;j++)
 219   1        {
 220   2          for(i=0;i<4;i++)
 221   2          {
 222   3            a=a<<1;
 223   3            LCM_std=CY;
 224   3            LCM_sclk=1;
 225   3            LCM_sclk=0;
 226   3          }
 227   2          LCM_std=0;
 228   2          for(i=0;i<4;i++)
 229   2          {
 230   3            LCM_sclk=1;
 231   3            LCM_sclk=0;
 232   3          }
 233   2        }
 234   1      }
 235          /*********************************************************************************/
 236          void chn_disp (uchar code *chn)
 237          {
 238   1        uchar i,j;
 239   1        LCM_WriteDatOrCom  (0,0x30);
C51 COMPILER V8.08   確农繽確蒧肖                                                          01/25/2009 10:21:59 PAGE 5   

 240   1        LCM_WriteDatOrCom  (0,0x80);
 241   1        for (j=0;j<4;j++)
 242   1        {
 243   2          for (i=0;i<16;i++)
 244   2          LCM_WriteDatOrCom  (1,chn[j*16+i]);
 245   2        }
 246   1      }

⌨️ 快捷键说明

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