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

📄 ili9163.lst

📁 2.4tft彩屏教程
💻 LST
📖 第 1 页 / 共 2 页
字号:
 277   3                      }
 278   2                      else
 279   2                      {
 280   3                              PointX = X1;
 281   3                      }
 282   2                      for(i = 0;i <= ((X0<X1) ? (X1-X0) : (X0-X1));i++)
 283   2                      {
 284   3      
 285   3                                      Put_pixel(PointX,PointY,color);
 286   3                              PointX++;
 287   3                      }
 288   2                      return;
 289   2              }
 290   1      
 291   1              if(dx > 0)
 292   1                      incx = 1;
 293   1              else if(dx == 0)
 294   1                      incx = 0;
 295   1              else
 296   1                      incx = -1;
 297   1      
 298   1              if(dy > 0)
 299   1                      incy = 1;
 300   1              else if(dy == 0)
 301   1                      incy = 0;
 302   1              else
 303   1                      incy = -1;
C51 COMPILER V7.06   ILI9163                                                               06/30/2010 14:30:33 PAGE 6   

 304   1      
 305   1          dx = ((X0>X1) ? (X0-X1) : (X1-X0));
 306   1          dy = ((Y0>Y1) ? (Y0-Y1) : (Y1-Y0));
 307   1      
 308   1          if(dx>dy) distance=dx;
 309   1          else distance=dy;
 310   1      
 311   1          PointX = X0;
 312   1          PointY = Y0;
 313   1          for(i=0;i<=distance+1;i++)
 314   1          {
 315   2      
 316   2                      Put_pixel(PointX,PointY,color);
 317   2              xerr+=dx;
 318   2              yerr+=dy;
 319   2              if(xerr>distance)
 320   2              {
 321   3                  xerr-=distance;
 322   3                  PointX+=incx;
 323   3              }
 324   2              if(yerr>distance)
 325   2              {
 326   3                  yerr-=distance;
 327   3                  PointY+=incy;
 328   3              }
 329   2          }
 330   1      }
 331          /*----------------------------------------------------------------------------
 332           * 函数名:Rectangle
 333           * 功能:绘制一个矩形框
 334           * 输入:矩形的起始位置left,top 
 335           *               矩形的结束位置right,bottom 
 336           *               矩形框的颜色color
 337           * 输出:无
 338           -----------------------------------------------------------------------------*/
 339          void Rectangle( uchar left,
 340                                          uchar top,
 341                                          uchar right,
 342                                          uchar bottom,
 343                                          unsigned int color)
 344          {
 345   1              Line(left,top,right,top,color);
 346   1              Line(left,top,left,bottom,color);
 347   1              Line(right,top,right,bottom,color);
 348   1              Line(left,bottom,right,bottom,color);
 349   1      }
 350          /*----------------------------------------------------------------------------
 351           * 函数名:Bar
 352           * 功能:绘制一个填充的平面矩形
 353           * 输入:矩形的起始位置left,top 
 354           *               矩形的结束位置right,bottom 
 355           *               矩形颜色color
 356           * 输出:无
 357           -----------------------------------------------------------------------------*/
 358          /*void Bar(     uchar left,
 359                                  uchar top,
 360                                  uchar right,
 361                                  uchar bottom,
 362                                  unsigned int color)
 363          {
 364                  uchar i = 0,k = 0;
 365                  for(k = top;k < bottom;k++)
C51 COMPILER V7.06   ILI9163                                                               06/30/2010 14:30:33 PAGE 7   

 366                  {
 367                          for(i = left+1;i <= right;i++)
 368                          {
 369                           LCD_SetPos(i,i,k,k);
 370                    Write_Data_U16(color);
 371                          }
 372                  }
 373          }*/
 374          //=======================灰度===========================================//
 375          /*void grayscale(void)
 376          {
 377           unsigned char data c,s;
 378           addr();
 379             for(c=0;c<80;c++)//128/2个点=64
 380                       {
 381                          for(s=0;s<8;s++){WriteDAT(0xff,0xff);}
 382                          for(s=0;s<8;s++){WriteDAT(0xef,0x7d);}
 383                          for(s=0;s<8;s++){WriteDAT(0xd6,0x9a);}
 384                          for(s=0;s<8;s++){WriteDAT(0xc6,0x18);}
 385                          for(s=0;s<8;s++){WriteDAT(0xb5,0x96);}
 386                          for(s=0;s<8;s++){WriteDAT(0xa5,0x14);}
 387                          for(s=0;s<8;s++){WriteDAT(0x94,0x92);}
 388                          for(s=0;s<8;s++){WriteDAT(0x84,0x10);}
 389                          for(s=0;s<8;s++){WriteDAT(0x73,0x8e);}
 390                          for(s=0;s<8;s++){WriteDAT(0x63,0x0c);}
 391                          for(s=0;s<8;s++){WriteDAT(0x52,0x8a);}
 392                          for(s=0;s<8;s++){WriteDAT(0x42,0x08);}
 393                          for(s=0;s<8;s++){WriteDAT(0x31,0x86);}
 394                          for(s=0;s<8;s++){WriteDAT(0x21,0x04);}
 395                          for(s=0;s<8;s++){WriteDAT(0x10,0x82);}
 396                          for(s=0;s<8;s++){WriteDAT(0x00,0x00);}
 397                       }
 398                for(c=0;c<20;c++)
 399                {
 400                          for(s=0;s<64;s++){WriteDAT(0xff,0xff);}
 401                          for(s=0;s<64;s++){WriteDAT(0x00,0x00);}
 402                 }
 403                 for(c=0;c<40;c++)
 404                {
 405          
 406                          for(s=0;s<16;s++) {WriteDAT(0xff,0xff);}
 407                          for(s=0;s<32;s++) {WriteDAT(0xd6,0x9a);}
 408                          for(s=0;s<16;s++) {WriteDAT(0xff,0xff);}
 409                          for(s=0;s<16;s++) {WriteDAT(0x00,0x00);}
 410                          for(s=0;s<32;s++) {WriteDAT(0x21,0x04);}
 411                          for(s=0;s<16;s++) {WriteDAT(0x00,0x00);}
 412                }
 413                 for(c=0;c<20;c++)
 414                {
 415                          for(s=0;s<64;s++){WriteDAT(0xff,0xff);}
 416                          for(s=0;s<64;s++){WriteDAT(0x00,0x00);}
 417                 }
 418                 Delayms(200);//廷时大约2S
 419          
 420          }
 421          */
 422          //======================================显示===================================//
 423          /*void displayshow(void)
 424          {
 425            unsigned char data i,c,s;
 426            addr();
 427          
C51 COMPILER V7.06   ILI9163                                                               06/30/2010 14:30:33 PAGE 8   

 428            for(i=0;i<80;i++)
 429            {
 430            for(c=0;c<1;c++)
 431            {
 432            for(s=0;s<64;s++) {WriteDAT(0x00,0x00); WriteDAT(0xff,0xff);}
 433             }
 434            for(c=0;c<1;c++)
 435            {
 436            for(s=0;s<64;s++) {WriteDAT(0xff,0xff);WriteDAT(0x00,0x00);}
 437             }
 438             }
 439          Delayms(200);//廷时大约2S
 440          }
 441          */
 442          void CLR_Screen(unsigned int color)
 443          {
 444   1       unsigned int c,s;
 445   1       addr();
 446   1             
 447   1       for(c=0;c<160;c++)
 448   1              {
 449   2           for(s=0;s<128;s++)
 450   2                   {
 451   3                    Write_Data_U16(color);
 452   3                   }
 453   2              }
 454   1        
 455   1      }
 456          
 457          
 458          /////////////////////////////////////////////////////////////
 459          #include "8X16.h"
 460          void LCD_PutChar8x16(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor)
 461          {
 462   1       unsigned int i,j;
 463   1       LCD_SetPos(x,x+8-1,y,y+16-1);
 464   1       for(i=0; i<16;i++) {
 465   2                      unsigned char m=Font8x16[c*16+i];
 466   2                      for(j=0;j<8;j++) {
 467   3                              if((m&0x80)==0x80) {
 468   4                                      Write_Data_U16(fColor);
 469   4                                      }
 470   3                              else {
 471   4                                      Write_Data_U16(bColor);
 472   4                                      }
 473   3                              m<<=1;
 474   3                              }
 475   2                      }
 476   1      }
 477          
 478          
 479          void LCD_PutChar(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor) {
 480   1      
 481   1                      LCD_PutChar8x16( x, y, c, fColor, bColor );
 482   1              }
 483          
 484          //=================================================
 485          //函数名称: LCDShow_uCharNumber(();
 486          //入口参数:uCharNumber
 487          //返  回值:无
 488          //说    明:向LCD发送一个0--255的数值
 489          //=================================================
C51 COMPILER V7.06   ILI9163                                                               06/30/2010 14:30:33 PAGE 9   

 490          /*void LCDShow_uCharNumber(     uchar x,
 491                                                                  uchar y,
 492                                                                  uchar uCharNumber,
 493                                                                  unsigned int forecolor,
 494                                                                  unsigned int bkcolor)
 495          {
 496                  LCD_PutChar(x,y,uCharNumber/100+'0',forecolor,bkcolor);
 497                  LCD_PutChar(x+8,y,uCharNumber/10%10+'0',forecolor,bkcolor);
 498                  LCD_PutChar(x+16,y,uCharNumber%10+'0',forecolor,bkcolor);
 499          }*/
 500          
 501          #include "GB1616.h"     //16*16汉字字模
 502          
 503          void PutGB1616(unsigned short x, unsigned short  y, unsigned char c[2], unsigned int fColor,unsigned int b
             -Color){
 504   1              unsigned int i,j,k;
 505   1      
 506   1              LCD_SetPos(x,  x+16-1,y, y+16-1);
 507   1      
 508   1              for (k=0;k<64;k++) { //64标示自建汉字库中的个数,循环查询内码
 509   2                if ((codeGB_16[k].Index[0]==c[0])&&(codeGB_16[k].Index[1]==c[1])){ 
 510   3              for(i=0;i<32;i++) {
 511   4                        unsigned short m=codeGB_16[k].Msk[i];
 512   4                        for(j=0;j<8;j++) {
 513   5                              if((m&0x80)==0x80) {
 514   6                                      Write_Data_U16(fColor);
 515   6                                      }
 516   5                              else {
 517   6                                      Write_Data_U16(bColor);
 518   6                                      }
 519   5                              m<<=1;
 520   5                              } 
 521   4                        }
 522   3                      }  
 523   2                }     
 524   1              }
 525          
 526          void LCD_PutString(unsigned short x, unsigned short y, unsigned char *s, unsigned int fColor, unsigned int
             - bColor) {
 527   1               unsigned char l=0;
 528   1              while(*s) {
 529   2                      if( *s < 0x80) 
 530   2                          {
 531   3                              LCD_PutChar(x+l*8,y,*s,fColor,bColor);
 532   3                              s++;l++;
 533   3                              }
 534   2                      else
 535   2                          {
 536   3                              PutGB1616(x+l*8,y,(unsigned char*)s,fColor,bColor);
 537   3                              s+=2;l+=2;
 538   3                              }
 539   2                      }
 540   1              }
 541          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1739    ----
   CONSTANT SIZE    =   3518    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----      96
C51 COMPILER V7.06   ILI9163                                                               06/30/2010 14:30:33 PAGE 10  

   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 + -