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

📄 my6963.lst

📁 基于proteus的液晶(t6969c)显示程序
💻 LST
📖 第 1 页 / 共 3 页
字号:
 258          0x00,0x00,0x00,0x30,0x18,0x18,0x18,0x0C, /*-- } --*/
 259          0x06,0x0C,0x18,0x18,0x18,0x30,0x00,0x00,
 260          0x00,0x00,0x00,0x00,0x00,0x00,0x71,0xDB, /*-- ~ --*/
 261          0x8E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 262          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*-- . --*/
 263          0x00,0x00,0x1C,0x1C,0x00,0x00,0x00,0x00
 264          };
 265          
 266          typedef struct typFNT_GB16        // 汉字字模数据结构
 267                  {
 268                  char Index[2];
 269                  char Msk[32];
 270                  };
 271          
 272          
 273          code struct typFNT_GB16  GB_16[] = 
 274          {  // 显示为16*16
 275          "中",   0x01,0x00,0x01,0x00,0x21,0x08,0x3F,0xFC,
 276                  0x21,0x08,0x21,0x08,0x21,0x08,0x21,0x08,
 277                  0x21,0x08,0x3F,0xF8,0x21,0x08,0x01,0x00,
 278                  0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
 279          "文",   0x02,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,
 280                  0x08,0x20,0x08,0x20,0x08,0x20,0x04,0x40,
 281                  0x04,0x40,0x02,0x80,0x01,0x00,0x02,0x80,
 282                  0x04,0x60,0x18,0x1E,0xE0,0x08,0x00,0x00,
 283          "测",   0x40,0x02,0x27,0xC2,0x24,0x42,0x84,0x52,
 284                  0x45,0x52,0x55,0x52,0x15,0x52,0x25,0x52,
 285                  0x25,0x52,0x25,0x52,0xC5,0x52,0x41,0x02,
 286                  0x42,0x82,0x42,0x42,0x44,0x4A,0x48,0x04,
 287          "试",   0x00,0x20,0x40,0x28,0x20,0x24,0x30,0x24,
 288                  0x27,0xFE,0x00,0x20,0xE0,0x20,0x27,0xE0,
 289                  0x21,0x20,0x21,0x10,0x21,0x10,0x21,0x0A,
 290                  0x29,0xCA,0x36,0x06,0x20,0x02,0x00,0x00,
 291          "周",   0x00,0x00,0x1F,0xFC,0x10,0x84,0x13,0xE4,
 292                          0x10,0x84,0x10,0x84,0x17,0xF4,0x10,0x04,
 293                          0x13,0xE4,0x12,0x24,0x12,0x24,0x13,0xE4,
 294                          0x22,0x24,0x20,0x04,0x40,0x14,0x80,0x08,
 295          "四",   0x00,0x00,0x7F,0xFC,0x44,0x84,0x44,0x84,
 296                  0x44,0x84,0x44,0x84,0x44,0x84,0x44,0x84,
 297                          0x48,0x84,0x48,0x7C,0x50,0x04,0x60,0x04,
 298                          0x40,0x04,0x7F,0xFC,0x40,0x04,0x00,0x00
 299          };
 300          // 一个单色图标的数据,宽度x高度=40x40
 301          
 302          char code img1[] = 
 303          {40,40,
C51 COMPILER V8.09   MY6963                                                                03/03/2008 15:21:50 PAGE 6   

 304          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 305          0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x07,0x00,0xE0,0x00,0x00,0x18,
 306          0x00,0x18,0x00,0x00,0x30,0x00,0x0C,0x00,0x00,0x40,0x00,0x02,0x00,0x00,0x80,0x00,
 307          0x01,0x00,0x01,0x00,0x00,0x00,0x80,0x03,0x00,0x00,0x00,0xC0,0x02,0x01,0x81,0x80,
 308          0x40,0x04,0x03,0xC3,0xC0,0x20,0x04,0x03,0xC3,0xC0,0x20,0x04,0x03,0xC3,0xC0,0x20,
 309          0x08,0x03,0xC3,0xC0,0x10,0x08,0x03,0xC3,0xC0,0x10,0x08,0x01,0x81,0x80,0x10,0x08,
 310          0x08,0x00,0x10,0x10,0x08,0x08,0x00,0x10,0x10,0x08,0x10,0x00,0x08,0x10,0x08,0xF0,
 311          0x00,0x0F,0x10,0x08,0x08,0x00,0x10,0x10,0x04,0x04,0x00,0x20,0x20,0x04,0x06,0x00,
 312          0x60,0x20,0x04,0x03,0x81,0xC0,0x20,0x02,0x01,0x7E,0x80,0x40,0x03,0x00,0x81,0x00,
 313          0xC0,0x01,0x00,0x42,0x00,0x80,0x00,0x80,0x3C,0x01,0x00,0x00,0x40,0x00,0x02,0x00,
 314          0x00,0x30,0x00,0x0C,0x00,0x00,0x18,0x00,0x18,0x00,0x00,0x07,0x00,0xE0,0x00,0x00,
 315          0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 316          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
 317          };
 318          
 319          uchar gCurRow,gCurCol; // 当前行列存储行高16 点列宽8点
 320          /************************************************/
 321          /* 取当前行数据*/   // 当前行列存储行高16 点列宽8点
 322          /************************************************/
 323          uchar fnGetRow(void)
 324          {
 325   1          return(gCurRow);
 326   1      }
 327          /************************************************/
 328          /* 取当前列数据*/
 329          /************************************************/
 330          unsigned char fnGetCol(void)
 331          {
 332   1          return(gCurCol);
 333   1      }
 334           
 335          
 336          /************************************************/
 337          /* 状态位STA1,STA0判断读写指令和读写数据*/
 338          /* 在读写数据或者写入命令前必须保证均为1 */
 339          /************************************************/
 340          unsigned char fnSTA01(void)
 341          {
 342   1          uchar i;
 343   1          for(i=10;i>0;i--)
 344   1          {
 345   2              if((LCMCW & 0x03) == 0x03) // 读取状态
 346   2              {
 347   3                  break;
 348   3              }
 349   2          }
 350   1          return(i); // 若返回零说明错误
 351   1      }
 352          /********************************************/
 353          /* 检查STA2,如果STA2=1 为自动读状态*/
 354          /*****************************************/
 355          uchar fnSTA2(void)
 356          {
 357   1          unsigned char i;
 358   1          for(i=10;i>0;i--)
 359   1          {
 360   2              if((LCMCW & 0x04) == 0x04)
 361   2              {
 362   3                  break;
 363   3              }
 364   2          }
 365   1          return(i); // 若返回零说明错误
C51 COMPILER V8.09   MY6963                                                                03/03/2008 15:21:50 PAGE 7   

 366   1      }
 367          /***********************************************/
 368          /* 状态位STA3 判断STA3 = 1 数据自动写状态*/
 369          /***********************************************/
 370          unsigned char fnSTA3(void)
 371          {
 372   1          unsigned char i;
 373   1          for(i=10;i>0;i--)
 374   1          {
 375   2              if((LCMCW & 0x08) == 0x08)
 376   2              {
 377   3                  break;
 378   3              }
 379   2          }
 380   1          return(i); // 若返回零说明错误
 381   1      }
 382          /************************************************/
 383          /* 状态位STA6 判断STA6 =1 屏读/屏拷贝状态*/
 384          /************************************************/
 385          uchar fnSTA6(void)
 386          {
 387   1          unsigned char i;
 388   1          for(i=10;i>0;i--)
 389   1          {
 390   2              if((LCMCW & 0x40) == 0x40)
 391   2              {
 392   3                  break;
 393   3              }
 394   2          }
 395   1          return(i); // 若返回零说明错误
 396   1      }
 397          /************************/
 398          /* 写双参数的指令*/
 399          /************************/
 400          unsigned char fnPR1(unsigned char uCmd,unsigned char uPar1,unsigned char uPar2)
 401          {
 402   1          if(fnSTA01() == 0)
 403   1          {
 404   2              return 1;
 405   2          }
 406   1          LCMDW=uPar1;
 407   1          if(fnSTA01() == 0)
 408   1          {
 409   2              return 2;
 410   2          }
 411   1          LCMDW=uPar2;
 412   1          if(fnSTA01() == 0)
 413   1          {
 414   2              return 3;
 415   2          }
 416   1          LCMCW=uCmd;
 417   1          return(0); // 返回0 成功
 418   1      }
 419          /************************/
 420          /* 写单参数的指令*/
 421          /************************/
 422          unsigned char fnPR11(unsigned char uCmd,unsigned char uPar1)
 423          {
 424   1          if(fnSTA01() == 0)
 425   1          {
 426   2              return 1;
 427   2          }
C51 COMPILER V8.09   MY6963                                                                03/03/2008 15:21:50 PAGE 8   

 428   1          LCMDW=uPar1;
 429   1          if(fnSTA01() == 0)
 430   1          {
 431   2              return 2;
 432   2          }
 433   1          LCMCW=uCmd;
 434   1          return(0); // 返回0 成功 
 435   1      }
 436          /************************/
 437          /* 写无参数的指令*/
 438          /************************/
 439          unsigned char fnPR12(unsigned char uCmd)
 440          {   
 441   1          if(fnSTA01() == 0)
 442   1          {
 443   2              return 1;
 444   2          }
 445   1         LCMCW=uCmd;
 446   1          return(0); // 返回0 成功
 447   1      }
 448          /************************/
 449          /* 写数据*/
 450          /************************/
 451          unsigned char fnPR13(unsigned char uData)
 452          {
 453   1          if(fnSTA3() == 0)
 454   1          {
 455   2              return 1;
 456   2          }
 457   1          LCMDW=uData;
 458   1          return(0); // 返回0 成功
 459   1      }
 460          /************************/
 461          /* 读数据*/
 462          /************************/
 463          unsigned char fnPR2(void)
 464          {
 465   1         // unsigned char temp;
 466   1          if(fnSTA01() == 0)
 467   1          {
 468   2               return 1; // 获取状态如果状态错
 469   2          }
 470   1          return(LCMDW); // 返回数据
 471   1      }
 472          
 473          
 474          
 475          /************************/
 476          /* 设置当前地址*/   //RAM里
 477          /************************/
 478          void fnSetPos(unsigned char urow, unsigned char ucol)
 479          {
 480   1          unsigned int iPos;
 481   1          iPos = (unsigned int)urow * 30 + ucol;   
 482   1          fnPR1(LC_ADD_POS,iPos&0xff,iPos/256); 
 483   1          gCurRow = urow;
 484   1          gCurCol = ucol;
 485   1      }
 486          /**********************/
 487          /* 设置当前显示行列*/
 488          /**********************/
 489          void cursor(unsigned char uRow, unsigned char uCol)
C51 COMPILER V8.09   MY6963                                                                03/03/2008 15:21:50 PAGE 9   

 490          {
 491   1          fnSetPos(uRow * 16, uCol);
 492   1      }
 493          /*********************/
 494          /* 清屏*/
 495          /*********************/
 496          void cls(void)
 497          {
 498   1          unsigned int i;
 499   1          fnPR1(LC_ADD_POS,0x00,0x00); // 置地址指针为从零开始
 500   1          fnPR12(LC_AUT_WR); // 自动写
 501   1          for(i=0;i<240*128/8;i++) // 清一屏
 502   1          {
 503   2              fnSTA3();
 504   2              fnPR13(0x0); // 写数据实际使用时请将0x55 改成0x0
 505   2          }
 506   1          fnPR12(LC_AUT_OVR); // 自动写结束
 507   1          fnPR1(LC_ADD_POS,0x00,0x00); // 重置地址指针
 508   1          gCurRow = 0; // 置地址指针存储变量
 509   1          gCurCol = 0;
 510   1      }
 511          /************************/
 512          /* LCM 初始化*/
 513          /************************/
 514          char fnLCMInit(void)
 515          {
 516   1          if(fnPR1(LC_TXT_STP,0x00,0x00) != 0) // 文本显示区首地址
 517   1          {
 518   2              return (0xff);
 519   2          }
 520   1          fnPR1(LC_TXT_WID,0x1E,0x00); // 文本显示区宽度
 521   1          fnPR1(LC_GRH_STP,0x00,0x00); // 图形显示区首地址
 522   1          fnPR1(LC_GRH_WID,0x1E,0x00); // 图形显示区宽度
 523   1          fnPR12(LC_CUR_SHP | 0x01); // 光标形状

⌨️ 快捷键说明

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