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

📄 main.lst

📁 LCD12864液晶C语言程序用于带字库的液晶
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.50   MAIN                                                                  09/02/2007 20:03:07 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include <reg52.H>
   2          #include <absacc.h>
   3          
   4          #define uint unsigned  int
   5          #define uchar unsigned char
   6          
   7          /***********LCD读写控制字************************/  
   8          #define LCD_WR_CMD    XBYTE[0xfcea]        //写命令
   9          #define LCD_RD_CMD    XBYTE[0xfeea]        //读状态字
  10          #define LCD_WR_DATA   XBYTE[0xfdea]        //写显示数据
  11          #define LCD_RD_DATA   XBYTE[0xffea]        //读显示数据
  12          
  13          
  14          
  15          unsigned char lcdPosX, lcdPosY; //X,Y坐标
  16          unsigned char halfScr, halfLineCnt, basicBlock; //半屏,半屏行数,N*8块
  17          
  18          //-----------------------------------------------
  19          unsigned char code powerOnPhoto [] = { //开机画面
  20                0xFF,0xFF,0xFF,0xFE,0x00,0x3E,0x18,0x00,
  21                0x00,0x00,0x00,0x00,0x1F,0x3F,0xFF,0xFF,
  22                0xFF,0xFF,0xFF,0xF2,0x00,0x1E,0x1C,0x00,
  23                0x00,0x00,0x00,0x00,0x07,0xBF,0xFF,0xFF,
  24                0xFF,0xFF,0xFF,0xF3,0x00,0x0E,0x0C,0x00,
  25                0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xFF,
  26                0xFF,0xFF,0xFF,0xF5,0x80,0x04,0x06,0x00,
  27                0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,
  28                0xFF,0xFF,0xFF,0xFC,0x80,0x00,0x06,0x00,
  29                0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,
  30                0xFF,0xFF,0xFF,0xFE,0xC0,0x00,0x02,0x00,
  31                0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,
  32                0xFF,0xFF,0xFF,0xFF,0x7C,0x00,0x03,0x00,
  33                0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,
  34                0xFF,0xFF,0xFF,0xFF,0xFD,0x00,0x03,0x00,
  35                0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,
  36                0xFF,0xFF,0xFF,0xFF,0xFD,0x1C,0x03,0x00,
  37                0x00,0x00,0x04,0x20,0x00,0x1F,0xFF,0xFF,
  38                0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,
  39                0x00,0x00,0x3E,0x2C,0x00,0x0F,0xFF,0xFF,
  40                0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,
  41                0x00,0x00,0x7E,0xE9,0x00,0x0F,0xFF,0xFF,
  42                0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,
  43                0x00,0x00,0xFF,0xFF,0x00,0x07,0xFF,0xFF,
  44                0xFF,0xFF,0xFF,0xFF,0xFF,0xF9,0xE0,0x00,
  45                0x00,0x01,0xFF,0xFF,0xC0,0x07,0xFF,0xFF,
  46                0xFF,0xFF,0xFF,0xFF,0xCF,0xF8,0xE0,0x00,
  47                0x00,0x03,0xFF,0xFF,0xF0,0x03,0xFF,0xFF,
  48                0xFF,0xFF,0xFF,0xFF,0xEF,0xFC,0xE0,0x60,
  49                0x00,0x03,0xDF,0xFF,0xF8,0x03,0xFF,0xFF,
  50                0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x60,
  51                0x00,0x03,0xFF,0xF9,0xFC,0x00,0xFF,0xFF,
  52                0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x60,
  53                0x00,0x00,0x7F,0xF3,0xFE,0x01,0xFF,0xFF,
  54                0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x60,
  55                0x00,0x00,0x1F,0x7F,0xFE,0x01,0xFF,0xFF,
C51 COMPILER V7.50   MAIN                                                                  09/02/2007 20:03:07 PAGE 2   

  56                0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x60,
  57                0x00,0x00,0x08,0x1F,0xFA,0x01,0x7F,0xFF,
  58                0xFF,0xFF,0xFF,0xB0,0x60,0x00,0x00,0xE0,
  59                0x00,0x00,0x00,0x00,0x78,0x00,0x7F,0xFF,
  60                0xFF,0xFF,0xFF,0xD0,0x00,0x00,0x00,0xE0,
  61                0x00,0x00,0x00,0x00,0x39,0x00,0x7F,0xFF,
  62                0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,0xE0,
  63                0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,
  64                0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x01,0xE0,
  65                0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,
  66                0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x01,0xE0,
  67                0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,
  68                0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x01,0xC0,
  69                0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,
  70                0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x03,0xC0,
  71                0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,
  72                0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x07,0xC0,
  73                0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,
  74                0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x07,0xC0,
  75                0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,
  76                0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x0F,0x80,
  77                0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,
  78                0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x0F,0x80,
  79                0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,
  80                0xFF,0xFF,0xFF,0x88,0x00,0x00,0x0E,0x00,
  81                0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,
  82                0xFF,0xFF,0xFF,0x80,0x00,0x00,0x1C,0x30,
  83                0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,
  84                0xFF,0xFF,0xFF,0xA0,0x00,0x00,0x1C,0x38,
  85                0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,
  86                0xFF,0xFF,0xFF,0x90,0x00,0x00,0x18,0x38,
  87                0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,
  88                0xFF,0xFF,0xFF,0x98,0x00,0x00,0x18,0xFC,
  89                0x0E,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,
  90                0xFF,0xFF,0xFF,0x80,0x00,0x00,0x19,0xFD,
  91                0x1F,0x80,0x00,0x00,0x00,0x00,0x7F,0xFF,
  92                0xFF,0xFF,0xFF,0xC4,0x00,0x00,0x39,0xFE,
  93                0xBF,0x80,0x00,0x00,0x00,0x00,0xFF,0xFF,
  94                0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x31,0xFE,
  95                0xFF,0x80,0x00,0x00,0x00,0x00,0xFF,0xFF,
  96                0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x38,0xFF,
  97                0xC7,0x80,0x00,0x00,0x00,0x00,0xBF,0xFF,
  98                0xFF,0xFF,0xFF,0xD0,0x00,0x00,0x38,0x75,
  99                0x87,0x80,0x00,0x00,0x00,0x01,0xBF,0xFF,
 100                0xFF,0xFF,0xFF,0xD0,0x00,0x00,0x38,0x70,
 101                0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,
 102                0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x3C,0xC0,
 103                0x00,0x30,0x00,0x00,0x00,0x01,0xFF,0xFF,
 104                0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x1F,0xE0,
 105                0x00,0x20,0x00,0x00,0x00,0x02,0xFF,0xFF,
 106                0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,
 107                0x00,0x00,0x00,0x00,0x00,0x02,0xFF,0xFF,
 108                0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,
 109                0x00,0x00,0x00,0x00,0x00,0x06,0xFF,0xFF,
 110                0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,
 111                0x00,0x00,0x00,0x00,0x00,0x04,0xFF,0xFF,
 112                0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,
 113                0x00,0x00,0x00,0x00,0x00,0x05,0xFF,0xFF,
 114                0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,
 115                0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,
 116                0xFF,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,
 117                0x00,0x00,0x00,0x00,0x00,0x0B,0xF7,0xFE,
C51 COMPILER V7.50   MAIN                                                                  09/02/2007 20:03:07 PAGE 3   

 118                0xFF,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,
 119                0x00,0x00,0x00,0x00,0x00,0x13,0xF7,0xFF,
 120                0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,
 121                0x00,0x00,0x00,0x00,0x00,0x13,0xFF,0xFF,
 122                0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,
 123                0x00,0x00,0x00,0x00,0x00,0x11,0xFF,0xFF,
 124                0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,
 125                0x00,0x00,0x00,0x00,0x00,0x11,0xFD,0xFF,
 126                0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x01,0x18,
 127                0x00,0x00,0x00,0x00,0x00,0x01,0xBC,0xF7,
 128                0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x07,0x7F,
 129                0xFE,0x00,0x00,0x00,0x00,0x03,0xBC,0xFF,
 130                0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x0F,0xFF,
 131                0xFE,0xC0,0x00,0x00,0x00,0x03,0xFE,0xEF,
 132                0xFF,0xFF,0xFF,0xF9,0x00,0x00,0x7F,0xFF,
 133                0xFF,0xC0,0x00,0x00,0x00,0x03,0xFE,0x6F,
 134                0xFF,0xFF,0xFF,0xF9,0x00,0x00,0x7F,0xE3,
 135                0x9F,0xC0,0x00,0x00,0x00,0x03,0xFE,0xFF,
 136                0xFF,0xFF,0xFF,0xFC,0x00,0x01,0xFF,0xC0,
 137                0x0F,0xF0,0x00,0x00,0x00,0x07,0xFE,0xFF,
 138                0xFF,0xFF,0xFF,0xFC,0x00,0x01,0xFE,0xC0,
 139                0x05,0xFC,0x00,0x00,0x00,0x07,0xCE,0xFF,
 140                0xFF,0xFF,0xFF,0xFC,0x00,0x03,0xFF,0xCB,
 141                0x4D,0xFF,0x80,0x00,0x00,0x07,0xFE,0xFF,
 142                0xFF,0xFF,0xFF,0xFE,0x00,0x03,0xFC,0x00,
 143                0x00,0xFF,0xC0,0x00,0x00,0x0E,0x00,0xF7,
 144                0xFF,0xFF,0xFF,0xFE,0x00,0x01,0xC0,0x00,
 145                0x00,0x0F,0xC0,0x00,0x00,0x06,0x01,0xFF,
 146                0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x1D,0x00,
 147                0x00,0x01,0xC0,0x00,0x00,0x0E,0x03,0xFF
 148          };
 149          
 150          
 151          unsigned char code filejia[] =                  // 数据表
 152          {
 153                0x00,0x00,0x00,0x00,0x0F,0xF0,0x10,0x08,
 154                0x7F,0xFE,0x40,0x02,0x40,0x02,0x4F,0xF2,
 155                0x48,0x12,0x48,0x12,0x48,0x12,0x48,0x12,
 156                0x4F,0xF2,0x40,0x02,0x7F,0xFE,0x00,0x00
 157          };
 158          
 159          
 160          
 161          //子程序声明和用法
 162          
 163          
 164          //初始化LCD子程序
 165          void lcdClear (void);
 166          //清除LCD文本屏幕子程序
 167          void alldisplayPhoto (unsigned char *bmp, unsigned char bmpCls); 
 168          void displayPhoto (unsigned char *bmp, unsigned char bmpCls); 
 169          //全屏显示图形子程序
 170          //输入参数:*bmp=图形数据 
 171          //bmpCls=清除图形屏幕选项(OFF为不清屏,即显示图形,ON为清屏)
 172          void convertChar (unsigned char CX, CY, width); 
 173          //字符反白显示
 174          //输入参数:CX=要反白字符的行(0-3)
 175          //CY=要反白字符的列(0-7)
 176          //width=要反白字符的长度(1-16)
 177          void wrPosition (void); 
 178          //坐标写入子程序
 179          void dispString (unsigned char X, Y, speed, unsigned char *msg); 
C51 COMPILER V7.50   MAIN                                                                  09/02/2007 20:03:07 PAGE 4   

 180          //显示字符串子程序
 181          //输入参数:X=行(0-3), Y=列(0-7), speed=显示速度(毫秒), msg=字符数据
 182          void beepBl (void);
 183          //蜂鸣器响一声子程序
 184          void delayMs (unsigned char ms); 
 185          //延时(毫秒)子程序
 186          //输入参数:毫秒数
 187          void delaySec (unsigned char sec); 
 188          //延时(秒)子程序
 189          //输入参数:秒数
 190          void lcdInit (void);
 191          //-------------
 192          void lcd_delay(void);
 193          void lcd_wbyte(unsigned char sendbyte);
 194          void lcd_wri(unsigned char indata);
 195          void lcd_wrd(unsigned char indata);
 196          void lcd_nop(void);
 197          void delay_ms(unsigned char k);
 198          //void lcd_show_str(unsigned char * strdata, unsigned char len, unsigned char x_tab);
 199          //-------------------
 200          void showPhoto (unsigned char cx,cy,high,width ,unsigned char *bmp);
 201          
 202          void clearChar (unsigned char CX, CY, width);
 203          //===============================================
 204          
 205          
 206          void main (void)
 207          {
 208   1      unsigned char InitLine;
 209   1      // unsigned char number;
 210   1      // unsigned char totlenumber;
 211   1      lcdInit ();
 212   1      
 213   1      while(1)
 214   1      {
 215   2      lcdClear();
 216   2      
 217   2      dispString(0, 1, 200, "佛山领航电教");
 218   2      dispString(1, 1, 200, "点播演示系统");
 219   2      
 220   2      
 221   2      delaySec(10);
 222   2      
 223   2      
 224   2      //displayPhoto(0,1);
 225   2          lcdClear();
 226   2      // delaySec(10);
 227   2          displayPhoto(powerOnPhoto, 0);
 228   2      
 229   2      
 230   2        //displayPhoto(0,1);
 231   2         
 232   2      delaySec(4);
 233   2        alldisplayPhoto(0,1);
 234   2        
 235   2        
 236   2          showPhoto(0x80,1,1,1,filejia);
 237   2         dispString(1, 1, 1, "  陈百强");
 238   2          convertChar(1, 1, 14); 
 239   2      delaySec(10); 
 240   2           showPhoto(0x88,2,1,1,filejia);
 241   2      dispString(2, 1, 1, "  黄家驹");
C51 COMPILER V7.50   MAIN                                                                  09/02/2007 20:03:07 PAGE 5   

 242   2          
 243   2      showPhoto(0x88,3,1,1,filejia);
 244   2      dispString(3, 1, 1, "  郑智化"); 
 245   2         delaySec(10); 
 246   2          clearChar(1, 1, 14);
 247   2            
 248   2      convertChar(2, 1, 14); 
 249   2      delaySec(10); 
 250   2      clearChar(2, 1, 14); 
 251   2      convertChar(3, 1, 14); 
 252   2      delaySec(10); 
 253   2      clearChar(3, 1, 14); 
 254   2      
 255   2      delaySec(10);
 256   2      alldisplayPhoto(0,1);
 257   2      lcdClear();
 258   2      
 259   2      dispString(0, 0, 1, "┏━━━━━━┓");
 260   2      dispString(1, 0, 1, "┃12864LCD测试┃");
 261   2      dispString(2, 0, 1, "┃画面人物宝儿┃");
 262   2      dispString(3, 0, 1, "┗━━━━━━┛");
 263   2      delaySec(6);
 264   2      lcdClear();
 265   2      dispString(0, 1, 100, "请稍等片刻");
 266   2      dispString(2, 0, 100, "系统初始化。。。");
 267   2      for (InitLine = 0; InitLine < 17; InitLine++)
 268   2      {
 269   3      convertChar(2, 0, InitLine);
 270   3      delaySec(2);
 271   3      }
 272   2      lcdClear();
 273   2      
 274   2      
 275   2      
 276   2      
 277   2      }
 278   1      }
 279          
 280          
 281          //===============================================
 282          void lcdInit (void)
 283          {
 284   1         
 285   1        
 286   1      lcd_delay();
 287   1      lcd_wri(0x34);
 288   1      lcd_delay();
 289   1          lcd_wri(0x30);
 290   1      lcd_delay();
 291   1      lcd_wri(0x0c);
 292   1      lcd_delay();
 293   1      lcd_wri(0x01);
 294   1      lcd_delay();
 295   1      lcd_wri(0x06);
 296   1      lcd_delay();
 297   1        
 298   1      }
 299          //===============================================
 300          void lcdClear (void) 
 301          {
 302   1      lcd_wri(0x30);
 303   1      lcd_delay();
C51 COMPILER V7.50   MAIN                                                                  09/02/2007 20:03:07 PAGE 6   

 304   1        lcd_wri(0x01);
 305   1        delayMs(4);
 306   1      }
 307          //===============================================
 308          
 309          //===============================================
 310          
 311          
 312          //===============================================
 313          void displayPhoto (unsigned char *bmp, unsigned char bmpCls) 
 314          {
 315   1      
 316   1         lcdPosX = 0x80;
 317   1      halfScr = 2;
 318   1      
 319   1      for (;halfScr != 0; halfScr--)
 320   1      {
 321   2      lcdPosY = 0x80;
 322   2      halfLineCnt = 32;
 323   2      
 324   2      for (;halfLineCnt != 0; halfLineCnt--)
 325   2      {
 326   3      basicBlock = 16;
 327   3      wrPosition ();
 328   3      
 329   3      for (; basicBlock != 0; basicBlock--)
 330   3      {
 331   4      if (bmpCls == 0)
 332   4      {
 333   5      lcd_wrd (*bmp++);
 334   5      }
 335   4      else if (bmpCls == 1)
 336   4      {
 337   5      lcd_wrd (0x00);
 338   5      }
 339   4      }
 340   3      lcdPosY++;

⌨️ 快捷键说明

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