Example #1
0
File: GUI.c Project: eeinz/trochili
/**
  * @brief  Gui draw font to GBK16.
  * @param  x,y,fc,bc,*s.
  * @retval None
  */
void Gui_DrawFont_GBK16(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *s)
{
    unsigned char i,j;
    unsigned short k,x0;
    x0=x;

    LCD_CS_CLR;
    while(*s)
    {
        /* ASCII character table from 32 to 128 */
        if((*s) < 128)
        {
            k=*s;
            if(k==13) 
            {
                x=x0;
                y+=16;
            }
            else 
            {
                if (k>32) k-=32; else k=0;
                for(i=0;i<16;i++)
                    for(j=0;j<8;j++) 
                    {
                        if(asc16[k*16+i]&(0x80>>j))
                            Gui_DrawPoint(x+j,y+i,fc);
                        else 
                        {
                            if (fc!=bc) Gui_DrawPoint(x+j,y+i,bc);
                        }
                    }
                x+=8;
            }
            s++;
        }
Example #2
0
void Gui_DrawFont_GBK16(u16 x, u16 y, u16 fc, u16 bc, u8 *s)
{
	unsigned char i,j;
	unsigned short k,x0;
	x0=x;

	while(*s) 
	{	
		if((*s) < 128) 
		{
			k=*s;
			if (k==13) 
			{
				x=x0;
				y+=16;
			}
			else 
			{
				if (k>32) k-=32; else k=0;
	
			    for(i=0;i<16;i++)
				for(j=0;j<8;j++) 
					{
				    	if(asc16[k*16+i]&(0x80>>j))	Gui_DrawPoint(x+j,y+i,fc);
						else 
						{
							if (fc!=bc) Gui_DrawPoint(x+j,y+i,bc);
						}
					}
				x+=8;
			}
			s++;
		}
Example #3
0
static void send_glyph_byte_on_bakcground(uint16_t x,uint16_t y,uint8_t bajt, uint8_t width) {
	uint8_t i;
	for(i=0; i<width; i++ ) {


		//if(bajt&0x80) Draw_pixel();

		if(bajt&0x80)
			Gui_DrawPoint(x+i,y,Color);
		//else Draw_bk_pixel();





		bajt<<=1;
	}
}
Example #4
0
/*
*********************************************************************************************************
*	函 数 名: FrameDisp
*	功能说明: 显示波形窗口的边框和刻度线
*	形    参:无
*	返 回 值: 无
*********************************************************************************************************
*/
static void FrameDisp(void)
{
	uint16_t x, y;

	/* 绘制一个实线矩形框 x, y, h, w */
	LCD_DrawRect(9, 19, 202, 302, CL_WHITE);

	/* 绘制垂直刻度点 */
	for (x = 0; x < 13; x++)
	{
		for (y = 0; y < 41; y++)
		{
			Gui_DrawPoint(10 + (x * 25), 20 + (y * 5), CL_WHITE);
		}
	}

	/* 绘制水平刻度点 */
	for (y = 0; y < 9; y++)
	{
		for (x = 0; x < 61; x++)
		{
			Gui_DrawPoint(10 + (x * 5), 20 + (y * 25), CL_WHITE);
		}
	}

	/* 绘制垂直中心刻度点 */
	for (y = 0; y < 41; y++)
	{	 
		Gui_DrawPoint(9 + (6 * 25), 20 + (y * 5), CL_WHITE);
		Gui_DrawPoint(11 + (6 * 25), 20 + (y * 5), CL_WHITE);
	}

	/* 绘制水平中心刻度点 */
	for (x = 0; x < 61; x++)
	{	 
		Gui_DrawPoint(10 + (x * 5), 19 + (4 * 25), CL_WHITE);
		Gui_DrawPoint(10 + (x * 5), 21 + (4 * 25), CL_WHITE);
	}
}
Example #5
0
File: GUI.c Project: eeinz/trochili
/**
  * @brief  Gui draw Line.
  * @param  x0,y0,x1,y1,Color.
  * @retval None
  */
void Gui_DrawLine(uint16_t x0, uint16_t y0,uint16_t x1, uint16_t y1,uint16_t Color)
{
    /* -difference in x's
       -difference in y's
       -dx,dy * 2
       -amount in pixel space to move during drawing
       -amount in pixel space to move during drawing
       -the discriminant i.e. error i.e. decision variable
       -used for looping */
    int dx,dy,dx2,dy2,x_inc,y_inc,error,index;

    LCD_CS_CLR;

    Lcd_SetXY(x0,y0);
    /* Calculate X distance */
    dx = x1-x0;
    /* Calculate Y distance */
    dy = y1-y0;

    if (dx>=0)
    {
        x_inc = 1;
    }
    else
    {
        x_inc = -1;
        dx    = -dx;
    } 

    if (dy>=0)
    {
        y_inc = 1;
    }
    else
    {
        y_inc = -1;
        dy    = -dy; 
    } 

    dx2 = dx << 1;
    dy2 = dy << 1;

    if (dx > dy)
    {
        /* initialize error */
        error = dy2 - dx;
        /* draw the line */
        for (index=0; index <= dx; index++)
        {
            Gui_DrawPoint(x0,y0,Color);
            /* test if error has overflowed */
            if (error >= 0)
            {
                error-=dx2;
                /* move to next line */
                y0+=y_inc;
             }
            /* adjust the error term */
            error+=dy2;
            /* move to the next pixel */
            x0+=x_inc;
         }
    }
    else
    {
        /* initialize error term */
        error = dx2 - dy;
        /* draw the linedraw the line*/
        for (index=0; index <= dy; index++)
        {
            /* set the pixel */
            Gui_DrawPoint(x0,y0,Color);

            /* test if error overflowed */
            if (error >= 0)
            {
                error-=dy2;
                /* move to next line */
                x0+=x_inc;
            }
            /* adjust the error term */
            error+=dx2;

            /* move to the next pixel */
            y0+=y_inc;
        }
    }
    LCD_CS_SET;
}
Example #6
0
File: GUI.c Project: eeinz/trochili
/**
  * @brief  Gui circle.
  * @param  X,Y,R,fc.
  * @retval None
  */
void Gui_Circle(uint16_t X,uint16_t Y,uint16_t R,uint16_t fc)
{
    unsigned short a,b;
    int c;
    a=0;
    b=R;
    c=3-2*R;
    LCD_CS_CLR;

    while (a<b)
    {
        Gui_DrawPoint(X+a,Y+b,fc);
        Gui_DrawPoint(X-a,Y+b,fc);
        Gui_DrawPoint(X+a,Y-b,fc);
        Gui_DrawPoint(X-a,Y-b,fc);
        Gui_DrawPoint(X+b,Y+a,fc);
        Gui_DrawPoint(X-b,Y+a,fc);
        Gui_DrawPoint(X+b,Y-a,fc);
        Gui_DrawPoint(X-b,Y-a,fc);

        if(c<0) c=c+4*a+6;
        else 
        { 
            c=c+4*(a-b)+10;
            b-=1; 
        } 
       a+=1;
    } 
    if (a==b)
    { 
        Gui_DrawPoint(X+a,Y+b,fc);
        Gui_DrawPoint(X+a,Y+b,fc);
        Gui_DrawPoint(X+a,Y-b,fc);
        Gui_DrawPoint(X-a,Y-b,fc);
        Gui_DrawPoint(X+b,Y+a,fc);
        Gui_DrawPoint(X-b,Y+a,fc);
        Gui_DrawPoint(X+b,Y-a,fc);
        Gui_DrawPoint(X-b,Y-a,fc);
    } 
    LCD_CS_SET;
}
Example #7
0
//画线函数,使用Bresenham 画线算法
void Gui_DrawLine(u16 x0, u16 y0,u16 x1, u16 y1,u16 Color)   
{
int dx,             // difference in x's
    dy,             // difference in y's
    dx2,            // dx,dy * 2
    dy2, 
    x_inc,          // amount in pixel space to move during drawing
    y_inc,          // amount in pixel space to move during drawing
    error,          // the discriminant i.e. error i.e. decision variable
    index;          // used for looping	


	Lcd_SetXY(x0,y0);
	dx = x1-x0;//计算x距离
	dy = y1-y0;//计算y距离

	if (dx>=0)
	{
		x_inc = 1;
	}
	else
	{
		x_inc = -1;
		dx    = -dx;  
	} 
	
	if (dy>=0)
	{
		y_inc = 1;
	} 
	else
	{
		y_inc = -1;
		dy    = -dy; 
	} 

	dx2 = dx << 1;
	dy2 = dy << 1;

	if (dx > dy)//x距离大于y距离,那么每个x轴上只有一个点,每个y轴上有若干个点
	{//且线的点数等于x距离,以x轴递增画点
		// initialize error term
		error = dy2 - dx; 

		// draw the line
		for (index=0; index <= dx; index++)//要画的点数不会超过x距离
		{
			//画点
			Gui_DrawPoint(x0,y0,Color);
			
			// test if error has overflowed
			if (error >= 0) //是否需要增加y坐标值
			{
				error-=dx2;

				// move to next line
				y0+=y_inc;//增加y坐标值
			} // end if error overflowed

			// adjust the error term
			error+=dy2;

			// move to the next pixel
			x0+=x_inc;//x坐标值每次画点后都递增1
		} // end for
	} // end if |slope| <= 1
	else//y轴大于x轴,则每个y轴上只有一个点,x轴若干个点
	{//以y轴为递增画点
		// initialize error term
		error = dx2 - dy; 

		// draw the line
		for (index=0; index <= dy; index++)
		{
			// set the pixel
			Gui_DrawPoint(x0,y0,Color);

			// test if error overflowed
			if (error >= 0)
			{
				error-=dy2;

				// move to next line
				x0+=x_inc;
			} // end if error overflowed

			// adjust the error term
			error+=dx2;

			// move to the next pixel
			y0+=y_inc;
		} // end for
	} // end else |slope| > 1
}
Example #8
0
void Gui_Circle(u16 X,u16 Y,u16 R,u16 fc) 
{//Bresenham算法 
    unsigned short  a,b; 
    int c; 
    a=0; 
    b=R; 
    c=3-2*R; 
    while (a<b) 
    { 
        Gui_DrawPoint(X+a,Y+b,fc);     //        7 
        Gui_DrawPoint(X-a,Y+b,fc);     //        6 
        Gui_DrawPoint(X+a,Y-b,fc);     //        2 
        Gui_DrawPoint(X-a,Y-b,fc);     //        3 
        Gui_DrawPoint(X+b,Y+a,fc);     //        8 
        Gui_DrawPoint(X-b,Y+a,fc);     //        5 
        Gui_DrawPoint(X+b,Y-a,fc);     //        1 
        Gui_DrawPoint(X-b,Y-a,fc);     //        4 

        if(c<0) c=c+4*a+6; 
        else 
        { 
            c=c+4*(a-b)+10; 
            b-=1; 
        } 
       a+=1; 
    } 
    if (a==b) 
    { 
        Gui_DrawPoint(X+a,Y+b,fc); 
        Gui_DrawPoint(X+a,Y+b,fc); 
        Gui_DrawPoint(X+a,Y-b,fc); 
        Gui_DrawPoint(X-a,Y-b,fc); 
        Gui_DrawPoint(X+b,Y+a,fc); 
        Gui_DrawPoint(X-b,Y+a,fc); 
        Gui_DrawPoint(X+b,Y-a,fc); 
        Gui_DrawPoint(X-b,Y-a,fc); 
    } 
	
}