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

📄 lcdmem.lst

📁 Keil C下通过的UCGUI,UCGUI的移植源代码
💻 LST
📖 第 1 页 / 共 4 页
字号:
                  #define GETPIXEL(x, y)         _GetPixel   ((y), (x))
                  #define XORPIXEL(x, y)         XorPixel    ((y), (x))
                #elif (!LCD_MIRROR_X &&  LCD_MIRROR_Y && !LCD_SWAP_XY) 
                  #define SETPIXEL(x, y, c)      SETPIXELPHYS((x), (LCD_YSIZE-1-(y)), (c))
                  #define SETPIXELFAST(x, y, c)  SETPIXELPHYS((x), (LCD_YSIZE-1-(y)), (c))
                  #define GETPIXEL(x, y)         _GetPixel   ((x), (LCD_YSIZE-1-(y)))
                  #define XORPIXEL(x, y)         XorPixel    ((x), (LCD_YSIZE-1-(y)))
                #elif (!LCD_MIRROR_X &&  LCD_MIRROR_Y &&  LCD_SWAP_XY) 
                  #define SETPIXEL(x, y, c)      SETPIXELPHYS((LCD_YSIZE-1-(y)), (x), (c))
                  #define GETPIXEL(x, y)         _GetPixel   ((LCD_YSIZE-1-(y)), (x))
                  #define XORPIXEL(x, y)         XorPixel    ((LCD_YSIZE-1-(y)), (x))
                #elif ( LCD_MIRROR_X && !LCD_MIRROR_Y && !LCD_SWAP_XY) 
                  #define SETPIXEL(x, y, c)      SETPIXELPHYS((LCD_XSIZE-1-(x)), (y), (c))
                  #define SETPIXELFAST(x, y, c)  SETPIXELPHYS((LCD_XSIZE-1-(x)), (y), (c))
                  #define GETPIXEL(x, y)         _GetPixel   ((LCD_XSIZE-1-(x)), (y))
                  #define XORPIXEL(x, y)         XorPixel    ((LCD_XSIZE-1-(x)), (y))
                #elif ( LCD_MIRROR_X && !LCD_MIRROR_Y &&  LCD_SWAP_XY) 
                  #define SETPIXEL(x, y, c)      SETPIXELPHYS((y), (LCD_XSIZE-1-(x)), (c))
                  #define GETPIXEL(x, y)         _GetPixel   ((y), (LCD_XSIZE-1-(x)))
                  #define XORPIXEL(x, y)         XorPixel    ((y), (LCD_XSIZE-1-(x)))
                #elif ( LCD_MIRROR_X &&  LCD_MIRROR_Y && !LCD_SWAP_XY) 
                  #define SETPIXEL(x, y, c)      SETPIXELPHYS((LCD_XSIZE-1-(x)), (LCD_YSIZE-1-(y)), (c))
                  #define SETPIXELFAST(x, y, c)  SETPIXELPHYS((LCD_XSIZE-1-(x)), (LCD_YSIZE-1-(y)), (c))
                  #define GETPIXEL(x, y)         _GetPixel   ((LCD_XSIZE-1-(x)), (LCD_YSIZE-1-(y)))
                  #define XORPIXEL(x, y)         XorPixel    ((LCD_XSIZE-1-(x)), (LCD_YSIZE-1-(y)))
                #elif ( LCD_MIRROR_X &&  LCD_MIRROR_Y &&  LCD_SWAP_XY) 
                  #error This combination of mirroring/swapping not yet supported
                #endif
 334          #elif (LCD_SUPPORT_COMTRANS && !LCD_SUPPORT_SEGTRANS)
                #if (!LCD_SWAP_XY)
                  #define SETPIXEL(x, y, c)      SetPixelPhys(x,LCD__aLine2Com0[y], c)
                  #define SETPIXELFAST(x, y, c)  SETPIXELPHYS(x,LCD__aLine2Com0[y], c)
                  #define GETPIXEL(x, y)     _GetPixel(x,LCD__aLine2Com0[y])
                  #define XORPIXEL(x, y)      XorPixel(x,LCD__aLine2Com0[y])
                #else
                  #define SETPIXEL(x, y, c)      SetPixelPhys(y,LCD__aLine2Com0[x], c)
                  #define SETPIXELFAST(x, y, c)  SETPIXELPHYS(y,LCD__aLine2Com0[x], c)
                  #define GETPIXEL(x, y)     _GetPixel(y,LCD__aLine2Com0[x])
                  #define XORPIXEL(x, y)      XorPixel(y,LCD__aLine2Com0[x])
                #endif
              #else
                #error This combination of switches not yet supported
              #endif
 349          
 350          
 351          
 352          
 353          /*
 354                  *********************************************************
 355                  *                                                       *
 356                  *       Internal set pixel routines                     *
 357                  *                                                       *
 358                  *********************************************************
 359          */
 360          
 361          #if LCD_BITSPERPIXEL == 1
 362            #define SETPIXELPHYS(x,y,c)                       \
 363            {                                                 \
 364              unsigned int Off = y*LCD_BYTESPERLINE+((x)>>3);       \
C51 COMPILER V8.05a   LCDMEM                                                               04/11/2008 14:19:25 PAGE 7   

 365              U8 Data = 0x80>>((x)&7);                                                          \
 366              if (c&1) LCD_VRam[0][Off] |=  Data;                               \
 367              else     LCD_VRam[0][Off] &= ~Data;                               \
 368            }
 369          #elif LCD_BITSPERPIXEL == 2
                #define SETPIXELPHYS(x,y,c)                       \
                {                                                 \
                  unsigned int Off = y*LCD_BYTESPERLINE+((x)>>3);       \
                  U8 Data = 0x80>>((x)&7);                                                          \
                  if (c&1) LCD_VRam[0][Off] |=  Data;                               \
                  else     LCD_VRam[0][Off] &= ~Data;                               \
                  if (c&2) LCD_VRam[1][Off] |=  Data;                               \
                  else     LCD_VRam[1][Off] &= ~Data;             \
                }
              #else
                #error unsupported Configuration
              #endif
 382          
 383          
 384          static void SetPixelPhys(int x, int y, PIXELCOLOR c) {
 385   1        SETPIXELPHYS(x,y,c);
 386   1      }
 387          
 388          static U8 _GetPixel(int x, int y) {
 389   1      #if LCD_BITSPERPIXEL == 1
 390   1        unsigned int Off = y*LCD_BYTESPERLINE+(x>>3);
 391   1        U8 Data  = (LCD_VRam[0][Off] >> (7-(x&7))) &1;
 392   1        return Data;
 393   1      #elif LCD_BITSPERPIXEL == 2
                unsigned int Off = y*LCD_BYTESPERLINE+(x>>3);
                U8 Data  = (LCD_VRam[0][Off] >> (7-(x&7))) &1;
                Data |= ((LCD_VRam[1][Off] >> (7-(x&7)))<<1) &2;
                return Data;
              #else
                #error Colordepth not supported by this driver !
              #endif
 401   1      }
 402          
 403          
 404          static void XorPixel   (int x, int y) {
 405   1        PIXELCOLOR Index = _GetPixel(x,y);
 406   1        Index = LCD_NUM_COLORS-1-Index;
 407   1        SetPixelPhys(x,y,Index);
 408   1      }
 409          
 410          
 411          /*
 412                  *********************************************************
 413                  *                                                       *
 414                  *       LCD_L0_XorPixel                                 *
 415                  *                                                       *
 416                  *********************************************************
 417          
 418          Purpose:  This routine is called by emWin. It writes 1 pixel into the
 419                    display.
 420          
 421          */
 422          
 423          void LCD_L0_XorPixel(int x, int y) {
 424   1        XORPIXEL(x, y);
 425   1      }
 426          
C51 COMPILER V8.05a   LCDMEM                                                               04/11/2008 14:19:25 PAGE 8   

 427          /*
 428                  *********************************************************
 429                  *                                                       *
 430                  *       LCD_L0_SetPixelIndex                            *
 431                  *                                                       *
 432                  *********************************************************
 433          
 434          Purpose:  This routine is called by emWin. It writes 1 pixel into the
 435                    display.
 436          
 437          */
 438          void LCD_L0_SetPixelIndex(int x, int y, int ColorIndex) {
 439   1        SETPIXEL(x, y, ColorIndex);
 440   1      }
 441          
 442          
 443          unsigned int LCD_L0_GetPixelIndex(int x, int y) {
 444   1        return GETPIXEL(x,y);
 445   1      }
 446          
 447          
 448          /*
 449                  *********************************************************
 450                  *                                                       *
 451                  *          LCD_DrawLine  vertical/horizontal            *
 452                  *          LCD_DrawRect                                 *
 453                  *                                                       *
 454                  *********************************************************
 455          */
 456          
 457          #if (!LCD_SWAP_XY)
 458          
 459          static const U8 aMask[] = {255,127,63,31,15,7,3,1,0};
 460          
 461          void LCD_L0_DrawHLine  (int x0, int y,  int x1) {
 462   1        int Off0, Off1;
 463   1        U8 EndMask;
 464   1        #if LCD_MIRROR_X
                {
                  int t = (LCD_XSIZE-1-(x0));
                  x0 = (LCD_XSIZE-1-(x1));
                  x1 = t;
                }
                #endif
 471   1        #if LCD_MIRROR_Y
                  y = (LCD_YSIZE-1-(y));
                #endif
 474   1        EndMask = ~aMask[1+((x1)&7)];
 475   1        Off0 = y*LCD_BYTESPERLINE+(x0>>3);
 476   1        Off1 = y*LCD_BYTESPERLINE+(x1>>3);
 477   1        if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
 478   2          if (Off0==Off1) {
 479   3            U8 Data = aMask[x0&7] & EndMask;
 480   3            LCD_VRam[0][Off0] ^= Data;
 481   3            #if LCD_BITSPERPIXEL == 2
                      LCD_VRam[1][Off0] ^= Data;
                    #endif
 484   3          } else {
 485   3            U8 Data = aMask[x0&7];
 486   3            LCD_VRam[0][Off0] ^= Data;
 487   3            #if LCD_BITSPERPIXEL == 2
                      LCD_VRam[1][Off0] ^= Data;
C51 COMPILER V8.05a   LCDMEM                                                               04/11/2008 14:19:25 PAGE 9   

                    #endif
 490   3            for (Off0++;Off0<Off1; Off0++) {
 491   4              LCD_VRam[0][Off0] ^= 255;
 492   4              #if LCD_BITSPERPIXEL == 2
                        LCD_VRam[1][Off0] ^= 255;
                      #endif
 495   4            }
 496   3            LCD_VRam[0][Off0] ^= EndMask;
 497   3            #if LCD_BITSPERPIXEL == 2
                      LCD_VRam[1][Off0] ^= EndMask;
                    #endif
 500   3          }
 501   2        } else {
 502   2          if (Off0==Off1) {
 503   3            U8 Data = aMask[x0&7] & EndMask;
 504   3            if (COLOR &1) LCD_VRam[0][Off0] |= Data;
 505   3            else          LCD_VRam[0][Off0] &= ~Data; 
 506   3            #if LCD_BITSPERPIXEL == 2
                      if (COLOR &2) LCD_VRam[1][Off0] |= Data;
                      else          LCD_VRam[1][Off0] &= ~Data; 
                    #endif
 510   3          } else {
 511   3            U8 Data = aMask[x0&7];
 512   3            if (COLOR &1) LCD_VRam[0][Off0] |= Data;
 513   3            else          LCD_VRam[0][Off0] &= ~Data; 
 514   3            #if LCD_BITSPERPIXEL == 2
                      if (COLOR &2) LCD_VRam[1][Off0] |= Data;
                      else          LCD_VRam[1][Off0] &= ~Data; 
                    #endif
 518   3            while (++Off0<Off1) {
 519   4              LCD_VRam[0][Off0] = (COLOR &1) ? 255 : 0;
 520   4              #if LCD_BITSPERPIXEL == 2
                        LCD_VRam[1][Off0] = (COLOR &2) ? 255 : 0;
                      #endif
 523   4            }
 524   3            if (COLOR &1) LCD_VRam[0][Off0] |= EndMask;
 525   3            else          LCD_VRam[0][Off0] &= ~EndMask; 
 526   3            #if LCD_BITSPERPIXEL == 2
                      if (COLOR &2) LCD_VRam[1][Off0] |= EndMask;
                      else          LCD_VRam[1][Off0] &= ~EndMask; 
                    #endif
 530   3          }
 531   2        }
 532   1      }
 533          
 534          #else
              
              void LCD_L0_DrawHLine  (int x0, int y,  int x1) {
                if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
                  while (x0 <= x1) {
                    XORPIXEL(x0, y);
                    x0++;
                  }
                } else {
                  while (x0 <= x1) {
                    SETPIXEL(x0, y, COLOR);
                    x0++;
                  }
                }
              }
              
              #endif
C51 COMPILER V8.05a   LCDMEM                                                               04/11/2008 14:19:25 PAGE 10  

 551          
 552          void LCD_L0_DrawVLine  (int x, int y0,  int y1) {
 553   1        if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
 554   2          while (y0 <= y1) {
 555   3            XORPIXEL(x, y0);
 556   3            y0++;
 557   3          }
 558   2        } else {
 559   2          while (y0 <= y1) {
 560   3            SETPIXEL(x, y0, COLOR);
 561   3            y0++;
 562   3          }
 563   2        }
 564   1      }
 565          
 566          void LCD_L0_FillRect(int x0, int y0, int x1, int y1) {
 567   1        for (; y0 <= y1; y0++) {
 568   2          LCD_L0_DrawHLine(x0,y0, x1);
 569   2        }
 570   1      }
 571          
 572          
 573          
 574          
 575          
 576          /*
 577            ***************************************************************
 578            *                                                             *
 579            *            Internal bitmap routines                         *
 580            *                                                             *
 581            ***************************************************************
 582          
 583          */
 584          
 585          
 586          /*
 587              *********************************************
 588              *                                           *
 589              *      Draw Bitmap 1 BPP                    *
 590              *                                           *
 591              *********************************************
 592          */
 593          
 594          static void  DrawBitLine1BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) {
 595   1        PIXELCOLOR pixels;
 596   1        PIXELCOLOR Index0 = *(pTrans+0);
 597   1        PIXELCOLOR Index1 = *(pTrans+1);
 598   1      /*
 599   1         Jump to right entry point
 600   1      */
 601   1        pixels = *p;
 602   1        switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS|LCD_DRAWMODE_XOR)) {
 603   2        case 0:
 604   2          switch (Diff&7) {
 605   3          case 0:   
 606   3            goto WriteBit0;
 607   3          case 1:   
 608   3            goto WriteBit1;
 609   3          case 2:
 610   3            goto WriteBit2;
 611   3          case 3:
 612   3            goto WriteBit3;
C51 COMPILER V8.05a   LCDMEM                                                               04/11/2008 14:19:25 PAGE 11  

 613   3          case 4:
 614   3            goto WriteBit4;
 615   3          case 5:   
 616   3            goto WriteBit5;
 617   3          case 6:   
 618   3            goto WriteBit6;
 619   3          case 7:   
 620   3            goto WriteBit7;

⌨️ 快捷键说明

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