Example #1
0
/*******************************************************************************
* Function Name  : TP_DrawPoint
* Description    : 
* Input          : - Xpos: Row Coordinate
*                  - Ypos: Line Coordinate 
* Output         : None
* Return         : None
* Attention		 : None
*******************************************************************************/
void TP_DrawPoint(uint16_t Xpos,uint16_t Ypos)
{
  LCD_SetPoint(Xpos,Ypos,Blue);     /* Center point */
  LCD_SetPoint(Xpos+1,Ypos,Blue);
  LCD_SetPoint(Xpos,Ypos+1,Blue);
  LCD_SetPoint(Xpos+1,Ypos+1,Blue);	
}	
Example #2
0
/*******************************************************************************
* Function Name  : TP_DrawPoint
* Description    : 在指定座标画点
* Input          : - Xpos: Row Coordinate
*                  - Ypos: Line Coordinate 
* Output         : None
* Return         : None
* Attention		 : None
*******************************************************************************/
void TP_DrawPoint(uint16_t Xpos,uint16_t Ypos)
{
  LCD_SetPoint(Xpos,Ypos,0xf800);     /* 中心点 */
  LCD_SetPoint(Xpos+1,Ypos,0xf800);
  LCD_SetPoint(Xpos,Ypos+1,0xf800);
  LCD_SetPoint(Xpos+1,Ypos+1,0xf800);	
}
Example #3
0
//LCD画圆
void LCD_Circle(u16 Xpos, u16 Ypos, u16 Radius, u16 color)
{
  	s32  Dec;
  	u32  CurX;
  	u32  CurY;

  	CurX=0;
  	CurY=Radius;
  	Dec=3-(Radius<<1);
  	while(CurX<=CurY)
  	{
		LCD_SetPoint(Xpos+CurX,Ypos+CurY,color);
		LCD_SetPoint(Xpos+CurX,Ypos-CurY,color);
		LCD_SetPoint(Xpos-CurX,Ypos+CurY,color);
		LCD_SetPoint(Xpos-CurX,Ypos-CurY,color);
		LCD_SetPoint(Xpos+CurY,Ypos+CurX,color);
		LCD_SetPoint(Xpos+CurY,Ypos-CurX,color);
		LCD_SetPoint(Xpos-CurY,Ypos+CurX,color);
		LCD_SetPoint(Xpos-CurY,Ypos-CurX,color);
		if(Dec<0)Dec+=(CurX<<2)+6;
	    else
	    {
	      	Dec+=((CurX-CurY)<<2)+10;
	      	CurY--;
	    }
	    CurX++;
  	}
}
Example #4
0
//LCD画任意斜线
void LCD_Line(u16 x1, u16 y1, u16 x2, u16 y2, u16 color)
{
	u16 t;
	int xerr=0,yerr=0,delta_x,delta_y,distance;
	int incx,incy,uRow,uCol;

	delta_x=x2-x1; //计算坐标增量
	delta_y=y2-y1;
	uRow=x1;
	uCol=y1;
	if(delta_x>0)incx=1; //设置单步方向
	else if(delta_x==0)incx=0;//垂直线
	else {incx=-1;delta_x=-delta_x;}
	if(delta_y>0)incy=1;
	else if(delta_y==0)incy=0;//水平线
	else{incy=-1;delta_y=-delta_y;}
	if( delta_x>delta_y)distance=delta_x; //选取基本增量坐标轴
	else distance=delta_y;
	for(t=0;t<=distance+1;t++ )//画线输出
	{
		LCD_SetPoint(uRow,uCol,color);//画点
		xerr+=delta_x ;
		yerr+=delta_y ;
		if(xerr>distance)
		{
			xerr-=distance;
			uRow+=incx;
		}
		if(yerr>distance)
		{
			yerr-=distance;
			uCol+=incy;
		}
	}
}
Example #5
0
void LCD_DrawVLine(u16 x,u16 y,u16 L,u8 color)//画垂直线,指定起点,长度,颜色
{
	u16 i;
	for(i=0;i<L;i++)
	{
		LCD_SetPoint(x,y+i,color);
	}
}
Example #6
0
void LCD_DrawHLine(u16 x,u16 y,u16 L,u8 color)//画水平线,指定起点,长度,颜色
{
	u16 i;
	for(i=0;i<L;i++)
	{
		LCD_SetPoint(x+i,y,color);
	}
}
Example #7
0
void Clear(u8 color)//逐点刷屏
{
	u16 i,j;
	for(i=0;i<400;i++)
	{
		for(j=0;j<240;j++)
		{
			LCD_SetPoint(j,i,color);
		}
	}
}
Example #8
0
void LCD_Line(u16 x0, u16 y0, u16 x1, u16 y1,u16 color)
{
	s32 dx = x1 - x0, dy = y1 - y0;
	s32 sx = 1, sy = 1;
	if(dx<0)
		sx = -1;
	if(dy<0)
		sy = -1;

	LCD_SetPoint(x0, y0, color);

	if(dx*sx>dy*sy) {
		s32 x = x0;
		if(dy==0) {
			while (x!=x1) {
				x += sx;
				LCD_SetPoint(x, y0, color);
			}
		} else {
			while (x!=x1) {
				x += sx;
				LCD_SetPoint(x, y0+dy*(x-(s32)x0)/dx, color);
			}
		}
	} else {
		s32 y = y0;
		if(dx==0) {
			while (y!=y1) {
				y += sy;
				LCD_SetPoint(x0, y, color);
			}
		} else {
			while (y!=y1) {
				y += sy;
				LCD_SetPoint(x0+dx*(y-(s32)y0)/dy, y, color);
			}
		}
	}
}
Example #9
0
void drawMap(void)
{
	u8 i=0;
	LCD_Color_Fill(40,40,280,125, Black);
	LCD_DrawLine(40,120,280,120,Blue2);
	
	LCD_DrawLine(100,40,100,125,Blue);
	LCD_DrawLine(160,40,160,125,Blue);
	LCD_DrawLine(220,40,220,125,Blue);
	
	LCD_DrawLine(40+cursor,40,40+cursor,125,Cyan);
	for(i=0; i<240; i++)
		LCD_SetPoint(i+40, 120-data[i]/50,Red);
}
Example #10
0
void LCD_Circle(u16 cx,u16 cy,u16 r,u16 color,u8 fill)
{
	u16 x,y;
	s16 delta,tmp;
	x=0;
	y=r;
	delta=3-(r<<1);

	while(y>x)
	{
		if(fill)
		{
			LCD_Line(cx+x,cy+y,cx-x,cy+y,color);
			LCD_Line(cx+x,cy-y,cx-x,cy-y,color);
			LCD_Line(cx+y,cy+x,cx-y,cy+x,color);
			LCD_Line(cx+y,cy-x,cx-y,cy-x,color);
		}
		else
		{
			LCD_SetPoint(cx+x,cy+y,color);
			LCD_SetPoint(cx-x,cy+y,color);
			LCD_SetPoint(cx+x,cy-y,color);
			LCD_SetPoint(cx-x,cy-y,color);
			LCD_SetPoint(cx+y,cy+x,color);
			LCD_SetPoint(cx-y,cy+x,color);
			LCD_SetPoint(cx+y,cy-x,color);
			LCD_SetPoint(cx-y,cy-x,color);
		}
		x++;
		if(delta>=0)
		{
			y--;
			tmp=(x<<2);
			tmp-=(y<<2);
			delta+=(tmp+10);
		}
		else
		{
			delta+=((x<<2)+6);
		}
	}
}
Example #11
0
void LCD_Draw_Line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2,
    uint16_t color) {
  uint16_t x, y, dx, dy;
  if (y1 == y2) {
    if (x1 <= x2)
      x = x1;
    else {
      x = x2;
      x2 = x1;
    }

    while (x <= x2) {
      LCD_SetPoint(x, y1, color);
      x++;
    }
    return;
  }

  else if (y1 > y2)
    dy = y1 - y2;
  else
    dy = y2 - y1;

  if (x1 == x2) {
    if (y1 <= y2)
      y = y1;
    else {
      y = y2;
      y2 = y1;
    }

    while (y <= y2) {
      LCD_SetPoint(x1, y, color);
      y++;
    }
    return;
  }

  else if (x1 > x2) {
    dx = x1 - x2;
    x = x2;
    x2 = x1;
    y = y2;
    y2 = y1;
  } else {
    dx = x2 - x1;
    x = x1;
    y = y1;
  }
  if (dx == dy) {
    while (x <= x2) {
      x++;
      if (y > y2)
        y--;

      else
        y++;
      LCD_SetPoint(x, y, color);
    }
  } else {
    LCD_SetPoint(x, y, color);
    if (y < y2) {
      if (dx > dy) {
        int16_t p = dy * 2 - dx;
        int16_t twoDy = 2 * dy;
        int16_t twoDyMinusDx = 2 * (dy - dx);
        while (x < x2) {
          x++;
          if (p < 0)
            p += twoDy;
          else {
            y++;
            p += twoDyMinusDx;
          }
          LCD_SetPoint(x, y, color);
        }
      } else {
        int16_t p = dx * 2 - dy;
        int16_t twoDx = 2 * dx;
        int16_t twoDxMinusDy = 2 * (dx - dy);
        while (y < y2) {
          y++;
          if (p < 0)
            p += twoDx;
          else {
            x++;
            p += twoDxMinusDy;
          }
          LCD_SetPoint(x, y, color);
        }
      }
    } else {
      if (dx > dy) {
        int16_t p = dy * 2 - dx;
        int16_t twoDy = 2 * dy;
        int16_t twoDyMinusDx = 2 * (dy - dx);
        while (x < x2) {
          x++;
          if (p < 0)
            p += twoDy;
          else {
            y--;
            p += twoDyMinusDx;
          }
          LCD_SetPoint(x, y, color);
        }
      } else {
        int16_t p = dx * 2 - dy;
        int16_t twoDx = 2 * dx;
        int16_t twoDxMinusDy = 2 * (dx - dy);
        while (y2 < y) {
          y--;
          if (p < 0)
            p += twoDx;
          else {
            x++;
            p += twoDxMinusDy;
          }
          LCD_SetPoint(x, y, color);
        }
      }
    }
  }
}