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

📄 ili9163.lst

📁 2.4tft彩屏教程
💻 LST
📖 第 1 页 / 共 2 页
字号:
 286   3                              PointY++;
 287   3                      }
 288   2                      return;
 289   2              }
 290   1              if(dy == 0)             //k=0斜率为0
 291   1              {
 292   2                      PointY = Y0;
 293   2                      if(X0 < X1)
 294   2                      {
 295   3                              PointX = X0;
 296   3                      }
 297   2                      else
 298   2                      {
 299   3                              PointX = X1;
 300   3                      }
 301   2                      for(i = 0;i <= ((X0<X1) ? (X1-X0) : (X0-X1));i++)
 302   2                      {
C51 COMPILER V7.06   ILI9163                                                               02/03/2010 15:50:23 PAGE 6   

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

 365   1              Line(left,top,left,bottom,color);
 366   1              Line(right,top,right,bottom,color);
 367   1              Line(left,bottom,right,bottom,color);
 368   1      }
 369          /*----------------------------------------------------------------------------
 370           * 函数名:Bar
 371           * 功能:绘制一个填充的平面矩形
 372           * 输入:矩形的起始位置left,top 
 373           *               矩形的结束位置right,bottom 
 374           *               矩形颜色color
 375           * 输出:无
 376           -----------------------------------------------------------------------------*/
 377          void Bar(       uchar left,
 378                                  uchar top,
 379                                  uchar right,
 380                                  uchar bottom,
 381                                  unsigned int color)
 382          {
 383   1              uchar i = 0,k = 0;
 384   1              for(k = top;k < bottom;k++)
 385   1              {
 386   2                      for(i = left+1;i <= right;i++)
 387   2                      {
 388   3                       LCD_SetPos(i,i,k,k);
 389   3                Write_Data_U16(color);
 390   3                      }
 391   2              }
 392   1      }
 393          //=======================灰度===========================================//
 394          void grayscale(void)
 395          {
 396   1       unsigned char data c,s;
 397   1       addr();
 398   1         for(c=0;c<80;c++)//128/2个点=64
 399   1                   {
 400   2                      for(s=0;s<8;s++){WriteDAT(0xff,0xff);}
 401   2                      for(s=0;s<8;s++){WriteDAT(0xef,0x7d);}
 402   2                      for(s=0;s<8;s++){WriteDAT(0xd6,0x9a);}
 403   2                      for(s=0;s<8;s++){WriteDAT(0xc6,0x18);}
 404   2                      for(s=0;s<8;s++){WriteDAT(0xb5,0x96);}
 405   2                      for(s=0;s<8;s++){WriteDAT(0xa5,0x14);}
 406   2                      for(s=0;s<8;s++){WriteDAT(0x94,0x92);}
 407   2                      for(s=0;s<8;s++){WriteDAT(0x84,0x10);}
 408   2                      for(s=0;s<8;s++){WriteDAT(0x73,0x8e);}
 409   2                      for(s=0;s<8;s++){WriteDAT(0x63,0x0c);}
 410   2                      for(s=0;s<8;s++){WriteDAT(0x52,0x8a);}
 411   2                      for(s=0;s<8;s++){WriteDAT(0x42,0x08);}
 412   2                      for(s=0;s<8;s++){WriteDAT(0x31,0x86);}
 413   2                      for(s=0;s<8;s++){WriteDAT(0x21,0x04);}
 414   2                      for(s=0;s<8;s++){WriteDAT(0x10,0x82);}
 415   2                      for(s=0;s<8;s++){WriteDAT(0x00,0x00);}
 416   2                   }
 417   1            for(c=0;c<20;c++)
 418   1            {
 419   2                      for(s=0;s<64;s++){WriteDAT(0xff,0xff);}
 420   2                      for(s=0;s<64;s++){WriteDAT(0x00,0x00);}
 421   2             }
 422   1             for(c=0;c<40;c++)
 423   1            {
 424   2      
 425   2                      for(s=0;s<16;s++) {WriteDAT(0xff,0xff);}
 426   2                      for(s=0;s<32;s++) {WriteDAT(0xd6,0x9a);}
C51 COMPILER V7.06   ILI9163                                                               02/03/2010 15:50:23 PAGE 8   

 427   2                      for(s=0;s<16;s++) {WriteDAT(0xff,0xff);}
 428   2                      for(s=0;s<16;s++) {WriteDAT(0x00,0x00);}
 429   2                      for(s=0;s<32;s++) {WriteDAT(0x21,0x04);}
 430   2                      for(s=0;s<16;s++) {WriteDAT(0x00,0x00);}
 431   2            }
 432   1             for(c=0;c<20;c++)
 433   1            {
 434   2                      for(s=0;s<64;s++){WriteDAT(0xff,0xff);}
 435   2                      for(s=0;s<64;s++){WriteDAT(0x00,0x00);}
 436   2             }
 437   1             Delayms(200);//廷时大约2S
 438   1      
 439   1      }
 440          
 441          //======================================显示===================================//
 442          void displayshow(void)
 443          {
 444   1        unsigned char data i,c,s;
 445   1        addr();
 446   1      
 447   1        for(i=0;i<80;i++)
 448   1        {
 449   2        for(c=0;c<1;c++)
 450   2        {
 451   3        for(s=0;s<64;s++) {WriteDAT(0x00,0x00); WriteDAT(0xff,0xff);}
 452   3         }
 453   2        for(c=0;c<1;c++)
 454   2        {
 455   3        for(s=0;s<64;s++) {WriteDAT(0xff,0xff);WriteDAT(0x00,0x00);}
 456   3         }
 457   2         }
 458   1      Delayms(200);//廷时大约2S
 459   1      }
 460          
 461          void CLR_Screen(unsigned int color)
 462          {
 463   1       unsigned int c,s;
 464   1       addr();
 465   1             
 466   1       for(c=0;c<160;c++)
 467   1              {
 468   2           for(s=0;s<128;s++)
 469   2                   {
 470   3                    Write_Data_U16(color);
 471   3                   }
 472   2              }
 473   1        
 474   1      }
 475          
 476          
 477          /////////////////////////////////////////////////////////////
 478          #include "8X16.h"
 479          void LCD_PutChar8x16(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor)
 480          {
 481   1       unsigned int i,j;
 482   1       LCD_SetPos(x,x+8-1,y,y+16-1);
 483   1       for(i=0; i<16;i++) {
 484   2                      unsigned char m=Font8x16[c*16+i];
 485   2                      for(j=0;j<8;j++) {
 486   3                              if((m&0x80)==0x80) {
 487   4                                      Write_Data_U16(fColor);
 488   4                                      }
C51 COMPILER V7.06   ILI9163                                                               02/03/2010 15:50:23 PAGE 9   

 489   3                              else {
 490   4                                      Write_Data_U16(bColor);
 491   4                                      }
 492   3                              m<<=1;
 493   3                              }
 494   2                      }
 495   1      }
 496          
 497          
 498          void LCD_PutChar(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor) {
 499   1      
 500   1                      LCD_PutChar8x16( x, y, c, fColor, bColor );
 501   1              }
 502          
 503          //=================================================
 504          //函数名称: LCDShow_uCharNumber(();
 505          //入口参数:uCharNumber
 506          //返  回值:无
 507          //说    明:向LCD发送一个0--255的数值
 508          //=================================================
 509          void LCDShow_uCharNumber(       uchar x,
 510                                                                  uchar y,
 511                                                                  uchar uCharNumber,
 512                                                                  unsigned int forecolor,
 513                                                                  unsigned int bkcolor)
 514          {
 515   1              LCD_PutChar(x,y,uCharNumber/100+'0',forecolor,bkcolor);
 516   1              LCD_PutChar(x+8,y,uCharNumber/10%10+'0',forecolor,bkcolor);
 517   1              LCD_PutChar(x+16,y,uCharNumber%10+'0',forecolor,bkcolor);
 518   1      }
 519          
 520          #include "GB1616.h"     //16*16汉字字模
 521          
 522          void PutGB1616(unsigned short x, unsigned short  y, unsigned char c[2], unsigned int fColor,unsigned int b
             -Color){
 523   1              unsigned int i,j,k;
 524   1      
 525   1              LCD_SetPos(x,  x+16-1,y, y+16-1);
 526   1      
 527   1              for (k=0;k<64;k++) { //64标示自建汉字库中的个数,循环查询内码
 528   2                if ((codeGB_16[k].Index[0]==c[0])&&(codeGB_16[k].Index[1]==c[1])){ 
 529   3              for(i=0;i<32;i++) {
 530   4                        unsigned short m=codeGB_16[k].Msk[i];
 531   4                        for(j=0;j<8;j++) {
 532   5                              if((m&0x80)==0x80) {
 533   6                                      Write_Data_U16(fColor);
 534   6                                      }
 535   5                              else {
 536   6                                      Write_Data_U16(bColor);
 537   6                                      }
 538   5                              m<<=1;
 539   5                              } 
 540   4                        }
 541   3                      }  
 542   2                }     
 543   1              }
 544          
 545          void LCD_PutString(unsigned short x, unsigned short y, unsigned char *s, unsigned int fColor, unsigned int
             - bColor) {
 546   1               unsigned char l=0;
 547   1              while(*s) {
 548   2                      if( *s < 0x80) 
C51 COMPILER V7.06   ILI9163                                                               02/03/2010 15:50:23 PAGE 10  

 549   2                          {
 550   3                              LCD_PutChar(x+l*8,y,*s,fColor,bColor);
 551   3                              s++;l++;
 552   3                              }
 553   2                      else
 554   2                          {
 555   3                              PutGB1616(x+l*8,y,(unsigned char*)s,fColor,bColor);
 556   3                              s+=2;l+=2;
 557   3                              }
 558   2                      }
 559   1              }
 560          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   2318    ----
   CONSTANT SIZE    =   2993    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----     110
   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 + -