📄 lcd_grph.c
字号:
else
{
di = dx_x2 - dy;
while(y0 != y1)
{
lcd_point(x0, y0, color);
y0 += dy_sym;
if(di < 0)
{
di += dx_x2;
}
else
{
di += dx_x2 - dy_x2;
x0 += dx_sym;
}
}
lcd_point(x0, y0, color);
}
return;
}
/******************************************************************************
** Function name: lcd_circle
**
** Descriptions: Use x0 and y0 as the center point to draw a
** a cycle with radius length r, and the latest parameter
** is the color of the circle
**
** parameters: x0, y0, radius, color
** Returned value: None
**
******************************************************************************/
void lcd_circle(WORD x0, WORD y0, WORD r, lcd_color_t color)
{
signed short draw_x0, draw_y0;
signed short draw_x1, draw_y1;
signed short draw_x2, draw_y2;
signed short draw_x3, draw_y3;
signed short draw_x4, draw_y4;
signed short draw_x5, draw_y5;
signed short draw_x6, draw_y6;
signed short draw_x7, draw_y7;
signed short xx, yy;
signed short di;
if(r == 0) /* no radius */
{
return;
}
draw_x0 = draw_x1 = x0;
draw_y0 = draw_y1 = y0 + r;
if(draw_y0 < DISPLAY_HEIGHT)
{
lcd_point(draw_x0, draw_y0, color); /* 90 degree */
}
draw_x2 = draw_x3 = x0;
draw_y2 = draw_y3 = y0 - r;
if(draw_y2 >= 0)
{
lcd_point(draw_x2, draw_y2, color); /* 270 degree */
}
draw_x4 = draw_x6 = x0 + r;
draw_y4 = draw_y6 = y0;
if(draw_x4 < DISPLAY_WIDTH)
{
lcd_point(draw_x4, draw_y4, color); /* 0 degree */
}
draw_x5 = draw_x7 = x0 - r;
draw_y5 = draw_y7 = y0;
if(draw_x5>=0)
{
lcd_point(draw_x5, draw_y5, color); /* 180 degree */
}
if(r == 1)
{
return;
}
di = 3 - 2*r;
xx = 0;
yy = r;
while(xx < yy)
{
if(di < 0)
{
di += 4*xx + 6;
}
else
{
di += 4*(xx - yy) + 10;
yy--;
draw_y0--;
draw_y1--;
draw_y2++;
draw_y3++;
draw_x4--;
draw_x5++;
draw_x6--;
draw_x7++;
}
xx++;
draw_x0++;
draw_x1--;
draw_x2++;
draw_x3--;
draw_y4++;
draw_y5++;
draw_y6--;
draw_y7--;
if( (draw_x0 <= DISPLAY_WIDTH) && (draw_y0>=0) )
{
lcd_point(draw_x0, draw_y0, color);
}
if( (draw_x1 >= 0) && (draw_y1 >= 0) )
{
lcd_point(draw_x1, draw_y1, color);
}
if( (draw_x2 <= DISPLAY_WIDTH) && (draw_y2 <= DISPLAY_HEIGHT) )
{
lcd_point(draw_x2, draw_y2, color);
}
if( (draw_x3 >=0 ) && (draw_y3 <= DISPLAY_HEIGHT) )
{
lcd_point(draw_x3, draw_y3, color);
}
if( (draw_x4 <= DISPLAY_HEIGHT) && (draw_y4 >= 0) )
{
lcd_point(draw_x4, draw_y4, color);
}
if( (draw_x5 >= 0) && (draw_y5 >= 0) )
{
lcd_point(draw_x5, draw_y5, color);
}
if( (draw_x6 <= DISPLAY_WIDTH) && (draw_y6 <= DISPLAY_HEIGHT) )
{
lcd_point(draw_x6, draw_y6, color);
}
if( (draw_x7 >= 0) && (draw_y7 <= DISPLAY_HEIGHT) )
{
lcd_point(draw_x7, draw_y7, color);
}
}
return;
}
/******************************************************************************
** Function name: lcd_putChar
**
** Descriptions: Put one chacter on the LCD for display
**
** parameters: pixel X and Y, and the character
** Returned value: TRUE or FALSE, if the pixels given are out of range,
** nothing will be written.
**
******************************************************************************/
DWORD lcd_putChar(WORD x, WORD y, BYTE ch)
{
BYTE data = 0;
BYTE i = 0, j = 0;
lcd_color_t color = BLACK;
if((x >= (DISPLAY_WIDTH - 8)) || (y >= (DISPLAY_HEIGHT - 8)) )
{
return( FALSE );
}
if( (ch < 0x20) || (ch > 0x7f) )
{
ch = 0x20; /* unknown character will be set to blank */
}
ch -= 0x20; for(i=0; i<8; i++)
{
data = font5x7[ch][i];
for(j=0; j<6; j++)
{
if( (data&font_mask[j])==0 )
{
color = backgroundColor;
}
else
{
color = foregroundColor;
}
lcd_point(x, y, color);
x++;
}
y++;
x -= 6;
}
return( TRUE );
}
/******************************************************************************
** Function name: lcd_putString
**
** Descriptions: Put a string of characters for display
**
** parameters: x and y pixels, and the pointer to the string characters
** Returned value: None
**
******************************************************************************/
void lcd_putString(WORD x, WORD y, BYTE *pStr)
{
while(1)
{
if( (*pStr)=='\0' )
{
break;
}
if( lcd_putChar(x, y, *pStr++) == 0 )
{
break;
}
x += 6;
}
return;
}
/******************************************************************************
** Function name: lcd_fontColor
**
** Descriptions: foreground and back ground color setting
**
** parameters: foreground color and background color
** Returned value: None
**
******************************************************************************/
void lcd_fontColor(lcd_color_t foreground, lcd_color_t background)
{
foregroundColor = foreground;
backgroundColor = background;
return;
}
/******************************************************************************
** Function name: lcd_pictureBegin
**
** Descriptions: Set where the pixels of the picture should be set, the
** size of the picture.
**
** parameters: x, y, width, and height
** Returned value: None
**
******************************************************************************/
void lcd_pictureBegin(WORD x, WORD y, WORD width, WORD height)
{
/* set window */
lcd_setWindow(x,y, x+width-1,y+height-1);
lcd_movePen(x, y);
return;
}
/******************************************************************************
** Function name: lcd_pictureData
**
** Descriptions:
**
** parameters: pointer to the picture and total size which is normally
** the width multiply by the height.
** Returned value: None
**
******************************************************************************/
void lcd_pictureData(WORD *pPicture, WORD len)
{
WORD i = 0;
for (i=0; i<len; i++)
{
LCD_DATA = *pPicture++;
}
return;
}
/******************************************************************************
** Function name: lcd_pictureEnd
**
** Descriptions: Restore window
**
** parameters: None
** Returned value: None
**
******************************************************************************/
void lcd_pictureEnd(void)
{
/* restore window */
lcd_setWindow(0,0, DISPLAY_WIDTH-1,DISPLAY_HEIGHT-1);
return;
}
/******************************************************************************
** Function name: lcd_picture
**
** Descriptions: put a picture file on the LCD display
** pixels, width, and height are the parameters of
** of the location, pPicuture is the pointer to the
** picture
**
** parameters: x, y, width, height, pointer to the picture
** Returned value: None
**
******************************************************************************/
void lcd_picture(WORD x, WORD y, WORD width, WORD height, WORD *pPicture)
{
lcd_pictureBegin(x, y, width, height);
lcd_pictureData(pPicture, width*height);
lcd_pictureEnd();
return;
}
/******************************************************************************
** End Of File
******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -