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

📄 lcdmem.c

📁 UCOS_UCGUI_MDK_LPC2134的移植代码.rar
💻 C
📖 第 1 页 / 共 3 页
字号:
        *********************************************************
        *                                                       *
        *       LCD_L0_XorPixel                                 *
        *                                                       *
        *********************************************************

Purpose:  This routine is called by emWin. It writes 1 pixel into the
          display.

*/

void LCD_L0_XorPixel(int x, int y) {
  XORPIXEL(x, y);
}

/*
        *********************************************************
        *                                                       *
        *       LCD_L0_SetPixelIndex                            *
        *                                                       *
        *********************************************************

Purpose:  This routine is called by emWin. It writes 1 pixel into the
          display.

*/
void LCD_L0_SetPixelIndex(int x, int y, int ColorIndex) {
  SETPIXEL(x, y, ColorIndex);
}


unsigned int LCD_L0_GetPixelIndex(int x, int y) {
  return GETPIXEL(x,y);
}


/*
        *********************************************************
        *                                                       *
        *          LCD_DrawLine  vertical/horizontal            *
        *          LCD_DrawRect                                 *
        *                                                       *
        *********************************************************
*/

#if (!LCD_SWAP_XY)

static const U8 aMask[] = {255,127,63,31,15,7,3,1,0};

void LCD_L0_DrawHLine  (int x0, int y,  int x1) {
  int Off0, Off1;
  U8 EndMask;
  #if LCD_MIRROR_X
  {
    int t = (LCD_XSIZE-1-(x0));
    x0 = (LCD_XSIZE-1-(x1));
    x1 = t;
  }
  #endif
  #if LCD_MIRROR_Y
    y = (LCD_YSIZE-1-(y));
  #endif
  EndMask = ~aMask[1+((x1)&7)];
  Off0 = y*LCD_BYTESPERLINE+(x0>>3);
  Off1 = y*LCD_BYTESPERLINE+(x1>>3);
  if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
    if (Off0==Off1) {
      U8 Data = aMask[x0&7] & EndMask;
      LCD_VRam[0][Off0] ^= Data;
      #if LCD_BITSPERPIXEL == 2
        LCD_VRam[1][Off0] ^= Data;
      #endif
    } else {
      U8 Data = aMask[x0&7];
      LCD_VRam[0][Off0] ^= Data;
      #if LCD_BITSPERPIXEL == 2
        LCD_VRam[1][Off0] ^= Data;
      #endif
      for (Off0++;Off0<Off1; Off0++) {
        LCD_VRam[0][Off0] ^= 255;
        #if LCD_BITSPERPIXEL == 2
          LCD_VRam[1][Off0] ^= 255;
        #endif
      }
      LCD_VRam[0][Off0] ^= EndMask;
      #if LCD_BITSPERPIXEL == 2
        LCD_VRam[1][Off0] ^= EndMask;
      #endif
    }
  } else {
    if (Off0==Off1) {
      U8 Data = aMask[x0&7] & EndMask;
      if (COLOR &1) LCD_VRam[0][Off0] |= Data;
      else          LCD_VRam[0][Off0] &= ~Data; 
      #if LCD_BITSPERPIXEL == 2
        if (COLOR &2) LCD_VRam[1][Off0] |= Data;
        else          LCD_VRam[1][Off0] &= ~Data; 
      #endif
    } else {
      U8 Data = aMask[x0&7];
      if (COLOR &1) LCD_VRam[0][Off0] |= Data;
      else          LCD_VRam[0][Off0] &= ~Data; 
      #if LCD_BITSPERPIXEL == 2
        if (COLOR &2) LCD_VRam[1][Off0] |= Data;
        else          LCD_VRam[1][Off0] &= ~Data; 
      #endif
      while (++Off0<Off1) {
        LCD_VRam[0][Off0] = (COLOR &1) ? 255 : 0;
        #if LCD_BITSPERPIXEL == 2
          LCD_VRam[1][Off0] = (COLOR &2) ? 255 : 0;
        #endif
      }
      if (COLOR &1) LCD_VRam[0][Off0] |= EndMask;
      else          LCD_VRam[0][Off0] &= ~EndMask; 
      #if LCD_BITSPERPIXEL == 2
        if (COLOR &2) LCD_VRam[1][Off0] |= EndMask;
        else          LCD_VRam[1][Off0] &= ~EndMask; 
      #endif
    }
  }
}

#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

void LCD_L0_DrawVLine  (int x, int y0,  int y1) {
  if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
    while (y0 <= y1) {
      XORPIXEL(x, y0);
      y0++;
    }
  } else {
    while (y0 <= y1) {
      SETPIXEL(x, y0, COLOR);
      y0++;
    }
  }
}

void LCD_L0_FillRect(int x0, int y0, int x1, int y1) {
  for (; y0 <= y1; y0++) {
    LCD_L0_DrawHLine(x0,y0, x1);
  }
}





/*
  ***************************************************************
  *                                                             *
  *            Internal bitmap routines                         *
  *                                                             *
  ***************************************************************

*/


/*
    *********************************************
    *                                           *
    *      Draw Bitmap 1 BPP                    *
    *                                           *
    *********************************************
*/

static void  DrawBitLine1BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) {
  PIXELCOLOR pixels;
  PIXELCOLOR Index0 = *(pTrans+0);
  PIXELCOLOR Index1 = *(pTrans+1);
/*
   Jump to right entry point
*/
  pixels = *p;
  switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS|LCD_DRAWMODE_XOR)) {
  case 0:
    switch (Diff&7) {
    case 0:   
      goto WriteBit0;
    case 1:   
      goto WriteBit1;
    case 2:
      goto WriteBit2;
    case 3:
      goto WriteBit3;
    case 4:
      goto WriteBit4;
    case 5:   
      goto WriteBit5;
    case 6:   
      goto WriteBit6;
    case 7:   
      goto WriteBit7;
    }
    break;
  case LCD_DRAWMODE_TRANS:
    switch (Diff&7) {
    case 0:
      goto WriteTBit0;
    case 1:
      goto WriteTBit1;
    case 2:
      goto WriteTBit2;
    case 3:
      goto WriteTBit3;
    case 4:
      goto WriteTBit4;
    case 5:   
      goto WriteTBit5;
    case 6:   
      goto WriteTBit6;
    case 7:   
      goto WriteTBit7;
    }
    break;
  case LCD_DRAWMODE_XOR:
    switch (Diff&7) {
    case 0:   
      goto WriteXBit0;
    case 1:   
      goto WriteXBit1;
    case 2:
      goto WriteXBit2;
    case 3:
      goto WriteXBit3;
    case 4:
      goto WriteXBit4;
    case 5:   
      goto WriteXBit5;
    case 6:   
      goto WriteXBit6;
    case 7:   
      goto WriteXBit7;
    }
  }
/*
        Write with transparency
*/
  WriteTBit0:
    if (pixels&(1<<7)) SETPIXEL(x+0, y, Index1);
    if (!--xsize)
      return;
  WriteTBit1:
    if (pixels&(1<<6)) SETPIXEL(x+1, y, Index1);
    if (!--xsize)
      return;
  WriteTBit2:
    if (pixels&(1<<5)) SETPIXEL(x+2, y, Index1);
    if (!--xsize)
      return;
  WriteTBit3:
    if (pixels&(1<<4)) SETPIXEL(x+3, y, Index1);
    if (!--xsize)
      return;
  WriteTBit4:
    if (pixels&(1<<3)) SETPIXEL(x+4, y, Index1);
    if (!--xsize)
      return;
  WriteTBit5:
    if (pixels&(1<<2)) SETPIXEL(x+5, y, Index1);
    if (!--xsize)
      return;
  WriteTBit6:
    if (pixels&(1<<1)) SETPIXEL(x+6, y, Index1);
    if (!--xsize)
      return;
  WriteTBit7:
    if (pixels&(1<<0)) SETPIXEL(x+7, y, Index1);
    if (!--xsize)
      return;
    x+=8;
    pixels = *(++p);
    goto WriteTBit0;

/*
        Write without transparency
*/
  WriteBit0:
    SETPIXEL(x+0, y, (pixels&(1<<7)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit1:
    SETPIXEL(x+1, y, (pixels&(1<<6)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit2:
    SETPIXEL(x+2, y, (pixels&(1<<5)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit3:
    SETPIXEL(x+3, y, (pixels&(1<<4)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit4:
    SETPIXEL(x+4, y, (pixels&(1<<3)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit5:
    SETPIXEL(x+5, y, (pixels&(1<<2)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit6:
    SETPIXEL(x+6, y, (pixels&(1<<1)) ? Index1 : Index0);
    if (!--xsize)
      return;
  WriteBit7:
    SETPIXEL(x+7, y, (pixels&(1<<0)) ? Index1 : Index0);
    if (!--xsize)
      return;
    x+=8;
    pixels = *(++p);
    goto WriteBit0;
/*
        Write XOR mode
*/
  WriteXBit0:
    if (pixels&(1<<7))
      XORPIXEL(x+0, y);
    if (!--xsize)
      return;
  WriteXBit1:
    if (pixels&(1<<6))
      XORPIXEL(x+1, y);
    if (!--xsize)
      return;
  WriteXBit2:
    if (pixels&(1<<5))
      XORPIXEL(x+2, y);
    if (!--xsize)
      return;
  WriteXBit3:
    if (pixels&(1<<4))
      XORPIXEL(x+3, y);
    if (!--xsize)
      return;
  WriteXBit4:
    if (pixels&(1<<3))
      XORPIXEL(x+4, y);
    if (!--xsize)
      return;
  WriteXBit5:
    if (pixels&(1<<2))
      XORPIXEL(x+5, y);
    if (!--xsize)
      return;
  WriteXBit6:
    if (pixels&(1<<1))
      XORPIXEL(x+6, y);
    if (!--xsize)
      return;
  WriteXBit7:
    if (pixels&(1<<0))
      XORPIXEL(x+7, y);
    if (!--xsize)
      return;
    x+=8;
    pixels = *(++p);
    goto WriteXBit0;
}


/*
    *********************************************
    *                                           *
    *      Draw Bitmap 2 BPP, optimized
    *                                           *
    *********************************************
*/

#if (LCD_MAX_LOG_COLORS > 2)

#if  (!LCD_SWAP_XY)

static void  DrawBitLine2BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) {
  PIXELCOLOR pixels;
/*
   Jump to right entry point
*/
  pixels = *p;
  if (GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) {
    switch (Diff&3) {
    case 0:
      goto WriteTBit0;
    case 1:
      goto WriteTBit1;
    case 2:
      goto WriteTBit2;
    default:
      goto WriteTBit3;
    }
  } else {
    switch (Diff&3) {
    case 0:
      goto WriteBit0;
    case 1:

⌨️ 快捷键说明

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