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

📄 lcdconf_7529.c

📁 控制器为ST7529的液晶模块针对ucGUI的驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
   if(x0==x1) 
   {
      DrawVPixLine(x0, y0, y1);
      return;
   }

   for(z=y0;z<y1+1;++z)
   {
      DrawHPixLine(x0+1, z, x1-1);	// 当前画水平线
   }
   Up_Lcd();
}
#endif

/*------------下面是GUI接口函数-------------------------------------------*/
void LCD_L0_SetPixelIndex(int x, int y, int PixelColor)   //上层调用的画点函数
{
    SETPIXEL(x, y, (PixelColor<<4));
}

unsigned int LCD_L0_GetPixelIndex(int x, int y)           //上层调用的取点函数
{
    return 0;
}

void LCD_L0_DrawHLine (int x0, int y,  int x1)           //上层调用的画横线函数
{
    LCD_HLine(x0, y,x1+1-x0);
    /*
    char startX,endX,n;
    char temp[3];
    char i;
    char pixelIndex;
   
    if (GUI_Context.DrawMode == GUI_DRAWMODE_NORMAL)     //正常模式
    {
        pixelIndex = 0xFF;
    }
    else if(GUI_Context.DrawMode & GUI_DRAWMODE_REV)    //翻转模式
    {
        pixelIndex = 0x00;
    }
    if((x1-x0)<=3)
    {
        for(i=x0;i<=x1;i++)
            SETPIXEL(i, y, pixelIndex);
        return;
    }
	startX = (95+x0)%3;
	endX = (95+x1)%3;	
	if(startX)
		n = (x1+1 - x0 -(3- startX) - (endX+1) );
	else
		n = (x1+1 - x0 - endX);
	
	SetWindow(x0,y,x1,159);
	
	if(startX)	
	{
		LCD_WRITE_A0(ReadModifyWriteOn);//DATA WRITE 
		LCD_READ_A1;		//dummy read
    	for(i=0;i<3;++i)
    		temp[i]=LCD_READ_A1;
	    for(i=0;i<startX;i++)
    		LCD_WRITE_A1(temp[i]);
    	for(i=startX;i<3;i++)
    		LCD_WRITE_A1(pixelIndex);
        LCD_WRITE_A0(ReadModifyWriteOff);//DATA WRITE 
	}
    
    
    LCD_WRITE_A0(MemWrite);//DATA WRITE
	for(i=0;i<n;++i)
	{
		LCD_WRITE_A1(pixelIndex);
	}
    
	if(endX<2)
	{
        LCD_WRITE_A0(ReadModifyWriteOn);//DATA WRITE 
		LCD_READ_A1;		//dummy read
		for(i=0;i<3;++i)
			temp[i]=LCD_READ_A1;
        for(i=0;i<startX;i++)
			LCD_WRITE_A1(pixelIndex);
		for(i=startX;i<3;i++)
			LCD_WRITE_A1(temp[i]);
        LCD_WRITE_A0(ReadModifyWriteOff);//DATA WRITE 
	}
    */
	
}

void LCD_L0_DrawVLine  (int x, int y0,  int y1)          //上层调用的画竖线函数
{
    char pixelIndex;
    u16 y = y0;
    if (GUI_Context.DrawMode == GUI_DRAWMODE_NORMAL) 
    {
        pixelIndex = 0xFF;
    }        
    else if(GUI_Context.DrawMode & LCD_DRAWMODE_XOR) 
    {
       pixelIndex = 0x00; 
    }
    for(y=y0;y<y1;y++)   
        SETPIXEL(x,y,pixelIndex); 
}

void LCD_L0_FillRect(int x0, int y0, int x1, int y1)                    //上层调用的画矩型函数
{
//    u8 remainder_x0 = x0%3;
//    u8 remainder_x1 = x1%3;
//    char pixelIndex;
    for (; y0 <= y1; y0++) 
    {
        LCD_L0_DrawHLine(x0, y0, x1);
    }
}

/**********************************************************************************************/
static void  DrawBitLine1BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) 
{
  u8  pixels;
  u8  Index0 = (*(pTrans+0))<<4;
  u8  Index1 = (*(pTrans+1))<<4;
  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;
            }
      break;
  }
/*
        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                                    *
        *                                                       *
        *********************************************************
*/

#if (LCD_MAX_LOG_COLORS > 2)
static void  DrawBitLine2BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) 
{
#if 0
  PixelIndex pixels;

  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:
    goto WriteBit1;
  case 2:
    goto WriteBit2;
  default:
    goto WriteBit3;
  }
/*
        Write without transparency
*/
WriteBit0:
  SETPIXEL(x+0, y, *(pTrans+(pixels>>6)));
  if (!--xsize)
    return;
WriteBit1:
  SETPIXEL(x+1, y, *(pTrans+(3&(pixels>>4))));
  if (!--xsize)
    return;
WriteBit2:
  SETPIXEL(x+2, y, *(pTrans+(3&(pixels>>2))));
  if (!--xsize)
    return;
WriteBit3:
  SETPIXEL(x+3, y, *(pTrans+(3&(pixels))));
  if (!--xsize)
    return;
  pixels = *(++p);
  x+=4;
  goto WriteBit0;
/*
        Write with transparency
*/
WriteTBit0:
  if (pixels&(3<<6))
    SETPIXEL(x+0, y, *(pTrans+(pixels>>6)));
  if (!--xsize)
    return;
WriteTBit1:
  if (pixels&(3<<4))
    SETPIXEL(x+1, y, *(pTrans+(3&(pixels>>4))));
  if (!--xsize)
    return;
WriteTBit2:
  if (pixels&(3<<2))
    SETPIXEL(x+2, y, *(pTrans+(3&(pixels>>2))));
  if (!--xsize)
    return;
WriteTBit3:
  if (pixels&(3<<0))
    SETPIXEL(x+3, y, *(pTrans+(3&(pixels))));
  if (!--xsize)
    return;
  pixels = *(++p);
  x+=4;
  goto WriteTBit0;
#endif
}

#endif


/*
        *********************************************************
        *                                                       *
        *  Draw Bitmap 4 BPP                                    *
        *                                                       *
        *********************************************************
*/

#if (LCD_MAX_LOG_COLORS > 4)
static void  DrawBitLine4BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) 
{
#if 0
  PixelIndex pixels;

  pixels = *p;
  if (GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) {
    if ((Diff&1) ==0)
      goto WriteTBit0;
    goto WriteTBit1;
  } else {
    if ((Diff&1) ==0)
      goto WriteBit0;
    goto WriteBit1;
  }
/*
        Write without transparency
*/
WriteBit0:
  SETPIXEL(x+0, y, *(pTrans+(pixels>>4)));
  if (!--xsize)
    return;
WriteBit1:
  SETPIXEL(x+1, y, *(pTrans+(pixels&0xf)));
  if (!--xsize)
    return;
  x+=2;
  pixels = *(++p);
  goto WriteBit0;
/*
        Write with transparency
*/
WriteTBit0:
  if (pixels>>4)
    SETPIXEL(x+0, y, *(pTrans+(pixels>>4)));
  if (!--xsize)
    return;
WriteTBit1:
  if (pixels&0xf)
    SETPIXEL(x+1, y, *(pTrans+(pixels&0xf)));
  if (!--xsize)
    return;
  x+=2;
  pixels = *(++p);
  goto WriteTBit0;
#endif
}
#endif


/*********************************************************************
*
*       LCD_L0_DrawBitmap
*/
void LCD_L0_DrawBitmap(int x0, int y0,
                       int xsize, int ysize,
                       int BitsPerPixel, 
                       int BytesPerLine,
                       const u8 * pData, int Diff,
                       const LCD_PIXELINDEX* pTrans)
{
  int i;
  /* Use _DrawBitLineXBPP */
  for (i=0; i<ysize; i++) {
    switch (BitsPerPixel) {
    case 1:
        DrawBitLine1BPP(x0, i + y0, pData, Diff, xsize, pTrans);
        /*
        for(j=0;j<2;j++)
        {
            //SETPIXEL(80+i, 80, 0xFF);
            Delay(115); //这个时间长短会影响系统正常运行
        }*/
      break;
    #if (LCD_MAX_LOG_COLORS > 2)
      case 2:
        DrawBitLine2BPP(x0, i + y0, pData, Diff, xsize, pTrans);
        break;
    #endif
    #if (LCD_MAX_LOG_COLORS > 4)
      case 4:
        DrawBitLine4BPP(x0, i + y0, pData, Diff, xsize, pTrans);
        break;
    #endif
    
    }
    pData += BytesPerLine;
  }
}

void LCD_L0_SetOrg(int x, int y) 
{
    
}

int  LCD_L0_Init(void)
{
    LCD_INIT_CONTROLLER();
    return 0;
}
void LCD_L0_SetLUTEntry(U8 Pos, LCD_COLOR color) 
{
    Pos=Pos;
  color=color;
}

void LCD_L0_XorPixel(int x, int y)                       //上层调用的异或函数
{
}


void LCD_On           (void) {
#ifdef LCD_ON
  LCD_ON();
#endif
}


/******************* (C) COPYRIGHT 千能电力 *****END OF FILE*******************/

⌨️ 快捷键说明

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