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

📄 lcd12864_1.lst

📁 51开发环境
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V6.23a  LCD12864_1                                                            04/11/2008 15:27:31 PAGE 1   


C51 COMPILER V6.23a, COMPILATION OF MODULE LCD12864_1
OBJECT MODULE PLACED IN LCD12864_1.OBJ
COMPILER INVOKED BY: F:\Keil\C51\BIN\c51.exe LCD12864_1.c OPTIMIZE(9,SPEED) BROWSE DEBUG OBJECTEXTEND CODE

stmt level    source

   1          //=====================================================================
   2          //               LCD12864  液晶显示技术I
   3          //               Make Time: 2008-4-8
   4          //=======================================================================
   5          
   6          #include <reg52.h>
   7          #include  <string.h>
   8          
   9          #define uchar unsigned char
  10          #define uint  unsigned int
  11          #define ulong unsigned long
  12          
  13          //=======引脚定义==================
  14          
  15          sbit lck = P3^5;//锁存信号
  16          
  17          //======常用命令及参数定义==========
  18          #define DISPON     0x3f
  19          #define DISPOFF    0x3e
  20          #define DISPFIRST  0xc0
  21          #define SETX       0x40
  22          #define SETY       0xb8
  23          #define LCDBUZY    0x80
  24          #define L          0x00
  25          #define R          0x40
  26          #define LIMIT      0x80
  27          #define LINE       16 // 设置最多一行可以显示多少字符(1~~16)
  28          
  29          
  30          //========全局变量===============
  31          code uchar pixel[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
  32          uchar  cbyte;
  33          uchar data statu;
  34          bit xy; // the position variable
  35          uchar charNum=1; 
  36          //this named charNum  variable recorded the char position,the whole screen can write 56 characters
  37          //one line can be written 14 characters 
  38          
  39          //=========汉字序列定义
  40          #define HZ_TIAN '~'+1
  41          #define HZ_DAO  '~'+3
  42          #define HZ_CHOU '~'+5
  43          #define HZ_QIN  '~'+7
  44          
  45          
  46          //=========函数声明============
  47          void WrL(uchar x);
  48          void WrR(uchar x);
  49          void Lcmcls(void);
  50          void delay1s(void);
  51          void Lcminit (void);
  52          void Putpicture(uchar flag);
  53          void delay(unsigned int time);
  54          void VtoH8x16change(uchar *hzbuf);
  55          void Puthalf(uchar *strch,uchar row,uchar col);
C51 COMPILER V6.23a  LCD12864_1                                                            04/11/2008 15:27:31 PAGE 2   

  56          void Wrdata(uchar x,uchar row,uchar col);
  57          void Locatexy(uchar row,uchar col);
  58          void vWrite8x16Character(uchar *ch,uchar row,uchar col,bit flag);
  59          void vWrite8x16String(uchar  *str,uchar col, uchar row, bit flag);
  60          
  61          
  62          extern uchar  code picture1[];
  63          extern uchar  code picture2[];
  64          extern uchar  code  char_Table[95][16];
  65          
  66          
  67          
  68          struct    //时间结构体
  69          {
  70            unsigned char hour; //0~23
  71            unsigned char min;  //0~59
  72            unsigned char sec;  //0~59
  73            unsigned int  msec; //0~999
  74            unsigned int  speeder; // define the speed yourself in interrupt program
  75            unsigned long allsec; //3600*hour+60*min+sec
  76             
  77          }time;
  78          //;***************************************************************
  79          //;     Name :  InitialMain()
  80          //;     Usage:  to do some initial work before enter the game 
  81          //;***************************************************************
  82          void InitialMain(void)
  83          {
  84   1        /* set initail time */
  85   1        time.hour=0;
  86   1        time.min=0;
  87   1        time.sec=0;
  88   1        time.msec=0;
  89   1        time.allsec=0;  
  90   1        TMOD=0x11;
  91   1        EA=1;
  92   1        ET0=1;
  93   1        TR0=1;
  94   1        ET1=1;
  95   1        TR1=1;
  96   1        PT1=0;PT0=1;
  97   1      
  98   1      }
  99          
 100          
 101          //============================================
 102          //  Usage: print the character in format
 103          //=============================================
 104          void Printc(uint chr)
 105          {
 106   1        uchar  lie,hang;
 107   1        hang=(charNum-1)/LINE;
 108   1        hang=hang*2;
 109   1        lie=(charNum-1)%LINE;
 110   1        lie=8*lie;   
 111   1        vWrite8x16Character(char_Table[chr-' ' ],hang,lie,0);  
 112   1        charNum++; //add one every time you write a character
 113   1      
 114   1      }
 115          
 116          //=============================================
 117          //      name :  Prints(uchar *str)
C51 COMPILER V6.23a  LCD12864_1                                                            04/11/2008 15:27:31 PAGE 3   

 118          //      usage:  print a stream in format 
 119          //=============================================
 120          void  Prints(uchar *str)
 121          {
 122   1        while(*(str)!='\0' )
 123   1         {     // 一些格式的处理
 124   2                 if(*(str)=='\n' )   //回车处理
 125   2            {
 126   3             charNum=(charNum+15)/16;
 127   3             charNum=charNum*16+1;
 128   3             str++;
 129   3             if(*(str)=='\0' ) return;
 130   3            }
 131   2            
 132   2               if(*(str)=='\r' )   //跳到所在行的行头
 133   2            {
 134   3             charNum=(charNum+15)/16;
 135   3             charNum=(charNum)*16-15;  
 136   3             str++;   
 137   3             if(*(str)=='\0' ) return;
 138   3            }        
 139   2            
 140   2            
 141   2             Printc(*(str));
 142   2            str++;
 143   2      
 144   2          
 145   2         }
 146   1      
 147   1      
 148   1      }
 149          
 150          //================================================
 151          //  Name : Format(uchar *str)
 152          //  usage: this function is printing some format
 153          //         格式化显示字符串           
 154          //=================================================
 155          void Format(uchar *str )
 156          { 
 157   1        
 158   1           if(*(str)=='\n' )   //回车处理
 159   1            {
 160   2             charNum=(charNum+15)/16;
 161   2             charNum=charNum*16+1;  
 162   2             return;
 163   2            }
 164   1            
 165   1           if(*(str)=='\r' )   //回到本行头
 166   1            {
 167   2             charNum=(charNum+15)/16;
 168   2             charNum=charNum*16-15;  
 169   2             return;
 170   2            }
 171   1            
 172   1           if(*(str)=='\p' )   //回到上一行头
 173   1            {                         
 174   2             charNum=(charNum+15)/16;
 175   2             charNum=charNum*16-31;  
 176   2             return;
 177   2            } 
 178   1            
 179   1           if(*(str)=='\b' )   //退格,并删除 
C51 COMPILER V6.23a  LCD12864_1                                                            04/11/2008 15:27:31 PAGE 4   

 180   1            {                         
 181   2             charNum--;
 182   2             Prints(" " );
 183   2             charNum--; 
 184   2             return;
 185   2            }   
 186   1      }
 187          
 188          //================================================
 189          //   名称: Printd(int integer)
 190          //   功能: just can display -32768~~~32768
 191          //================================================
 192          void Printd(int integer)
 193          {
 194   1        if(integer==0) 
 195   1        {Printc('0' );return;}
 196   1        
 197   1        {char i,j;
 198   2         char lenth[6];
 199   2         if(integer<0)
 200   2            {lenth[5]=1;integer=-integer;} //负数
 201   2         else
 202   2            lenth[5]=0; //正数
 203   2                   
 204   2            lenth[4]=integer%10;  
 205   2            integer/=10;
 206   2            lenth[3]=integer%10;  
 207   2            integer/=10;
 208   2            lenth[2]=integer%10;  
 209   2            integer/=10;
 210   2            lenth[1]=integer%10;        
 211   2            lenth[0]=integer/10;
 212   2           
 213   2            i=0;
 214   2            while(i<5)
 215   2            {
 216   3              if( lenth[i]!=0)
 217   3              { j=i;
 218   4                break;
 219   4              }
 220   3              i++;
 221   3            }
 222   2            
 223   2          //display in lcd12864     
 224   2          if(lenth[5]==1) Printc('-' );       
 225   2          for(i=j;i<5;i++)
 226   2          { Printc(lenth[i]+'0' ); }                                   
 227   2             
 228   2        
 229   2        } 
 230   1        
 231   1       
 232   1      }
 233          
 234          
 235          //=================================================================
 236          //     名称: DisplayInLine(*str)
 237          //     功能: 在某一行,流动显示一个句子
 238          //     参数: str是要显示的句子,thisLine为显示行的行首位置
 239          //=================================================================
 240          void  DisplayInLine(uchar* str,uchar thisLine)
 241          {
C51 COMPILER V6.23a  LCD12864_1                                                            04/11/2008 15:27:31 PAGE 5   

 242   1            static uint i,j;     
 243   1              if(j<i+15)  //+15
 244   1                {
 245   2                 
 246   2                  Printc(  *(str+j) ); 
 247   2                   j++;              
 248   2                }
 249   1              else
 250   1               { 
 251   2                   j=i; charNum=thisLine; 
 252   2               
 253   2                    if(i<strlen(str)-16)  //-15
 254   2                    {
 255   3                     i++;
 256   3                    }
 257   2                  
 258   2                    else
 259   2                    i=0;          
 260   2                }  
 261   1               

⌨️ 快捷键说明

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