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

📄 lcd.lst

📁 使用C语言编写的单片机控制LCD显示程序
💻 LST
字号:
C51 COMPILER V7.06   LCD                                                                   09/02/2005 08:49:54 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE LCD
OBJECT MODULE PLACED IN lcd.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE lcd.c BROWSE DEBUG OBJECTEXTEND TABS(2)

stmt level    source

   1          #include "reg52.h"
   2          
   3          #define  uchar  unsigned char
   4          #define  uint   unsigned int
   5          #define  ulong   unsigned long
   6          
   7          extern char getbyte(void);        //从接收缓冲区取一个byte,如不想等待则在调用前检测inbufsign是否为1。
   8          extern putbyte(char c);         //放入一个字节到发送缓冲区
   9          extern putstring(uchar  *puts);     //发送一个定义在程序存储区的字符串到串口
  10          extern putbytes(uchar *outplace,uint j);//放一串数据到发送缓冲区,需要定义发送的字节数
  11          extern puthex(uchar c);         //发送一个字节的hex码,分成两个字节发。
  12          extern  bit   inbufsign;        //串口接收到数据标志
  13          #define CR putstring("\r\n")      //发送一个回车换行
  14          extern void serial_init (void);       //串口初始化
  15          
  16          void delay(uint dtime)
  17          {
  18   1        uint n;
  19   1        uint i;
  20   1        for(i=0;i<dtime;i++)
  21   1        for(n=0;n<2100;n++);
  22   1      }
  23          
  24          //清屏
  25          void lcd_cls(void)
  26          {
  27   1        delay(4);
  28   1        putbyte(0x1b);
  29   1        putbyte(0x32);
  30   1      }
  31          //打开/关闭模块背光 0开背光,1关背光
  32          void Set_module_light(uchar module)
  33          {
  34   1        while(inbufsign)getbyte();
  35   1        putbyte(0x1b);
  36   1        putbyte(0x25);
  37   1        putbyte(module);
  38   1        getbyte();getbyte();
  39   1      }
  40          // 设置光标位置(横向位置(0-19) 行位置(0-4))
  41          void lcd_cursor(uchar x, uchar y)      
  42          {
  43   1        while(inbufsign)getbyte();
  44   1        putbyte(0x1b);
  45   1        putbyte(0x33);
  46   1        putbyte(x);
  47   1        putbyte(y);
  48   1        getbyte();getbyte();
  49   1      
  50   1      }
  51          
  52          //显示字符串
  53          void lcd_string(uchar attr,uchar *string) 
  54          {
  55   1        delay(5);
C51 COMPILER V7.06   LCD                                                                   09/02/2005 08:49:54 PAGE 2   

  56   1        putbyte(0x1b);
  57   1        putbyte(0x37);
  58   1        putbyte(attr);  
  59   1        putstring(string);
  60   1        putbyte(0x00);
  61   1      }
  62          //画线
  63          void lcd_line(uchar attr,uchar x0,uchar y0,uchar x1,uchar y1)
  64          {
  65   1        delay(10);
  66   1        putbyte(0x1b);
  67   1        putbyte(0x39);
  68   1        putbyte(attr);
  69   1        putbyte(x0);
  70   1        putbyte(y0);
  71   1        putbyte(x1);
  72   1        putbyte(y1);  
  73   1      }
  74          //画矩形
  75          void lcd_rect(uchar x1,uchar y1,uchar x2,uchar y2)
  76          { 
  77   1        lcd_line(1,x1,y1,x2,y1);
  78   1        lcd_line(1,x1,y1,x1,y2);
  79   1        lcd_line(1,x2,y1,x2,y2);
  80   1        lcd_line(1,x1,y2,x2,y2);
  81   1      }
  82          
  83          
  84          //在光标处显示数0正显,1反显
  85          void lcd_char(uchar attr,uchar num)
  86          {
  87   1        uchar str[3];
  88   1        uchar tem;
  89   1        str[2]='\0';
  90   1        
  91   1        tem=num%10;
  92   1        num/=10;
  93   1        str[1] = tem+0x30;
  94   1        str[0] = num+0x30;
  95   1      
  96   1        lcd_string(attr,str); 
  97   1      }
  98          //在光标处显示1个数0正显,1反显
  99          void lcd_char1(uchar attr ,uchar num)
 100            {
 101   1          uchar str[2];
 102   1          str[1]='\0';
 103   1          str[0] = num%10+0x30;
 104   1          //str[0] = num+0x30;//这一句和上一句对于本程序效果一样  
 105   1          lcd_string(attr,str); 
 106   1        }
 107          // 画图片,*picture_data指向图片数据,图片数据的第一二个字节是图片宽度和图片高度
 108          void lcd_picture(uchar attr,uchar x0,uchar y0,uchar *picture_data)
 109          {
 110   1        putbyte(0x1b);
 111   1        putbyte(0x42);
 112   1        putbyte(attr);
 113   1        putbyte(x0);
 114   1        putbyte(y0);
 115   1        putbytes(picture_data,(((*picture_data)+7)/8)*(*(picture_data+1))+2);
 116   1        getbyte();getbyte();
 117   1          
C51 COMPILER V7.06   LCD                                                                   09/02/2005 08:49:54 PAGE 3   

 118   1      }
 119          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    398    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----      27
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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