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

📄 12232.lst

📁 12232 LCD中实现16*16汉字任意行显示的源代码 UV2开发环境
💻 LST
📖 第 1 页 / 共 3 页
字号:
 229   1      
 230   1          send_mi(col_addr_set);
 231   1          send_mi(disp_start_line); /* 归回零列,设定显示起始行首 */
 232   1      
 233   1          send_si(col_addr_set);
 234   1          send_si(disp_start_line);
 235   1      
 236   1          send_mi(disp_on);         /* 开显示 */
 237   1          send_si(disp_on);
 238   1      
 239   1          lcd_clr();
 240   1      }
 241          
C51 COMPILER V7.09   12232                                                                 03/14/2007 23:21:25 PAGE 5   

 242          
 243          /****************************************************************************/
 244          /* 函数名:set_page                                                         */
 245          /* 功  能:同时设置主(左)从(右)显示页为0-1页                                */
 246          /* 作  者:spot                                                             */
 247          /* 输  入:page                                                             */
 248          /* 输  出:无                                                               */
 249          /*                                                                          */
 250          /* 历史记录:                                                               */
 251          /*  spot          2005-06-28     Creat Inital version. (Version 1.0)        */
 252          /****************************************************************************/
 253          void set_page(u_char page)
 254          {
 255   1          send_mi(page_addr_set|page);
 256   1          send_si(page_addr_set|page);
 257   1      }
 258          
 259          /****************************************************************************/
 260          /* 函数名:set_address                                                      */
 261          /* 功  能:同时设置主从列地址为0-61列                                       */
 262          /* 作  者:spot                                                             */
 263          /* 输  入:address                                                          */
 264          /* 输  出:无                                                               */
 265          /*                                                                          */
 266          /* 历史记录:                                                               */
 267          /*  spot          2005-06-28     Creat Inital version. (Version 1.0)        */
 268          /****************************************************************************/
 269          void set_address(u_char address)
 270          {
 271   1          send_mi(address&0x7F);  /* &0x7F,考虑到防止越限 */
 272   1          send_si(address&0x7F);
 273   1      }
 274          
 275          /****************************************************************************/
 276          /* 函数名:putchar_l                                                        */
 277          /* 功  能:在左页(主窗口)当前地址画一个字节(8点)                            */
 278          /* 作  者:spot                                                             */
 279          /* 输  入:c                                                                */
 280          /* 输  出:无                                                               */
 281          /*                                                                          */
 282          /* 历史记录:                                                               */
 283          /*  spot          2005-06-28     Creat Inital version. (Version 1.0)        */
 284          /****************************************************************************/
 285          void putchar_l(u_char c)
 286          {
 287   1          send_md(c);
 288   1      }
 289          
 290          /****************************************************************************/
 291          /* 函数名:putchar_r                                                        */
 292          /* 功  能:在右页(从窗口)当前地址画一个字节(8点)                            */
 293          /* 作  者:spot                                                             */
 294          /* 输  入:c                                                                */
 295          /* 输  出:无                                                               */
 296          /*                                                                          */
 297          /* 历史记录:                                                               */
 298          /*  spot          2005-06-28     Creat Inital version. (Version 1.0)        */
 299          /****************************************************************************/
 300          void putchar_r(u_char c)
 301          {
 302   1          send_sd(c);
 303   1      }
C51 COMPILER V7.09   12232                                                                 03/14/2007 23:21:25 PAGE 6   

 304          
 305          //----------------------------------------------------------
 306          //--------设置读写改--------
 307          //----------------------------------------------------------
 308          u_char read_data()
 309          {
 310   1      u_char d=0;     
 311   1      RS = 0;
 312   1      _nop_();
 313   1      _nop_();
 314   1      RS = 1;
 315   1      _nop_();
 316   1      
 317   1      RW=1;
 318   1      _nop_();
 319   1      
 320   1      d=lcd_data;
 321   1      
 322   1      
 323   1      
 324   1      return d;
 325   1      
 326   1      
 327   1      
 328   1      }
 329          
 330          
 331          //----------------------------------------------------------
 332          //--------设置读写改--------
 333          //----------------------------------------------------------
 334          void read_write_l(u_char ubyte)
 335          {
 336   1      
 337   1      
 338   1          send_mi(0xe0);
 339   1          send_si(0xe0);
 340   1          ubyte=ubyte|read_data();
 341   1      
 342   1      
 343   1      
 344   1              putchar_l(ubyte);
 345   1      
 346   1      
 347   1              RS = 0;
 348   1              RW=0;
 349   1          send_mi(0xee);
 350   1          send_si(0xee);
 351   1      
 352   1      
 353   1      }
 354          
 355          //----------------------------------------------------------
 356          //--------设置读写改--------
 357          //----------------------------------------------------------
 358          void read_write_r(u_char ubyte)
 359          {
 360   1      
 361   1      
 362   1          send_mi(0xe0);
 363   1          send_si(0xe0);
 364   1          ubyte=ubyte|read_data();
 365   1      
C51 COMPILER V7.09   12232                                                                 03/14/2007 23:21:25 PAGE 7   

 366   1      
 367   1      
 368   1              putchar_r(ubyte);
 369   1      
 370   1      
 371   1              RS = 0;
 372   1              RW=0;
 373   1          send_mi(0xee);
 374   1          send_si(0xee);
 375   1      
 376   1      
 377   1      }
 378          
 379          
 380          
 381          /****************************************************************************/
 382          /* 函数名:draw_bmp                                                         */
 383          /* 功  能:画一个图,横坐标是col,layer表示上下层,width是图形的宽,高固定16    */
 384          /* 作  者:spot                                                             */
 385          /* 输  入:                                                                 */
 386          /*         col     图型的起始位置0~121                                      */
 387          /*         layer   图形的位置(Y坐标)0-下半部分 非0-上半部分                 */
 388          /*         width                                      */
 389          /*         bmp     图形数据指针                                             */
 390          /*                                                                          */
 391          /* 输  出:无                                                               */
 392          /*                                                                          */
 393          /* 历史记录:                                                               */
 394          /*  spot          2005-06-28     Creat Inital version. (Version 1.0)        */
 395          /****************************************************************************/
 396          void draw_bmp(u_char col,u_char y,u_char width,u_char *bmp)
 397          {
 398   1      //y:0~7
 399   1          u_char x;
 400   1          u_char address;           /* address表示显存的物理地址 */
 401   1          u_char p=0;
 402   1          u_char y0=0;
 403   1              u_char buf=0;
 404   1              u_char buf0=0;  
 405   1              u_char buf1=0;
 406   1              u_char buf3=0;
 407   1              u_char buf2=0;
 408   1      
 409   1      
 410   1      //u_char page;            /* page表示上下两页,window表示左右窗口(0左,1右) */
 411   1      u_char window;
 412   1      
 413   1      //    if (layer)
 414   1      //    {
 415   1      //        page=2;               /* 左-主窗口,右-从窗口 */
 416   1      //    }
 417   1      //
 418   1          for (x=col; x<col+width; x++)
 419   1          {
 420   2              if (x>121)
 421   2                  return;           /* 防止显示乱码 */
 422   2      
 423   2              if (x>60)             /* 左右窗口定位 */
 424   2              {
 425   3                  window=1;         /* 右-从窗口    */
 426   3                  address=x%61;
 427   3              }
C51 COMPILER V7.09   12232                                                                 03/14/2007 23:21:25 PAGE 8   

 428   2              else
 429   2              {
 430   3                      window=0;
 431   3                  address=x;        /* 主窗口输出   */
 432   3              }
 433   2      
 434   2      
 435   2      
 436   2      if(y==0)
 437   2      {
 438   3              buf2=bmp[p];
 439   3              buf3=bmp[p+width];
 440   3                      set_page(2);
 441   3                      set_address(address);
 442   3      
 443   3              if (window)
 444   3                 putchar_r(buf2);
 445   3      //         read_write_r(buf2);
 446   3                              
 447   3              else
 448   3                 putchar_l(buf2);
 449   3      //                      read_write_l(buf2);
 450   3      
 451   3                      set_page(3);
 452   3                      set_address(address);
 453   3      
 454   3              if (window)
 455   3      //            putchar_r(buf3);
 456   3              read_write_r(buf3);
 457   3              else
 458   3      //           putchar_l(buf3);
 459   3                      read_write_l(buf3);
 460   3      }
 461   2      
 462   2      
 463   2      if(y>0&&y<8)

⌨️ 快捷键说明

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