?? lcd.c
字號:
padrs = xadrs;
#ifdef APD_LCD_BEBO
if (hword)
padrs--;
else
padrs++;
#endif /* APD_LCD_BEBO */
LCDSetPixelByShort(padrs, (unsigned short)current_gc.c);
}
bit_mask >>= 1;
if (!(bit_mask))
bit_mask = LCD_PAT_MASK;
xadrs++;
hword ^= 0x01;
}
LCDMemcpyWord((unsigned long *)adrs, (unsigned long *)LineData,
(unsigned long)(bufsize >> 1) );
}
/******************************************************************************
@@
@@ [Name] : LCDOverwriteHline
@@
@@ [Summary] : Overwrite a horizontal line segment
@@
@@ [Argument] : adrs : Address of horizontal line
@@ hword : Half word offset of address
@@ byte : Byte offset of address
@@ bit : Bit offset of address
@@ size : Number of pixel
@@ color : Color to overwrite
@@ [Return] : None
@@
@@ [Desc] : Overwrite a horizontal line segment regardless of
@@ current raster operation
@@ Valid attribute : Color
@@
@@ [History] : Date Modifier Comment
@@
@@ [END]
******************************************************************************/
static void LCDOverwriteHline(
unsigned long *adrs,
unsigned char hword,
unsigned char byte,
unsigned char bit,
short size,
unsigned long color
)
{
/*
If APD_LCD_BPP is 16BPP, access to memory by a half word unit.
So if LCD byte endian is little endian, the half word address
to write pixel data isn't controlled.
But if it is big endian, the one is controlled in front and behind.
*/
unsigned long l_color;
APD_LCD_ROP_TYPE rop_bak = current_gc.rop;
color &= 0x0000FFFF;
l_color = (unsigned long)((color << 16) | color);
current_gc.rop = APD_LCD_ROP_S;
if (hword) {
unsigned long *hw_adrs;
hw_adrs = adrs;
#ifdef APD_LCD_BEBO
hw_adrs--;
#endif /* APD_LCD_BEBO */
LCDSetPixelByShort(hw_adrs, (unsigned short)color);
size--;
adrs++;
}
if (size >> 1) {
LCDMemsetWord((unsigned long *)adrs, l_color, size >> 1);
adrs += (unsigned long)size & 0xffffFFFE;
size &= 0x0001;
}
if (size) {
#if(defined(APD_LCD_BEBO))
adrs++;
#endif /* defined(APD_LCD_BEBO) */
LCDSetPixelByShort(adrs, (unsigned short)color);
}
current_gc.rop = rop_bak;
}
/******************************************************************************
@@ [Name] : apd_LCDDrawLine
@@ [Summary] : Draw line segment
@@ [Argument] : sp : Coordinate data of the start point
@@ ep : Coordinate data of the end point
@@ [Return] : None
@@ [Desc] : Draw the specific line data (neither vertical nor
@@ horizontal line) according to the current attribute.
@@ Include the start point in line segment,
@@ but not the stop point.
@@ Valid attribute : Color, Raster operation, Line width,Line type
@@ [History] : Date Modifier Comment
******************************************************************************/
void apd_LCDDrawLine(APD_LCD_POINT *sp,APD_LCD_POINT *ep)
{
short dx, dy;
unsigned short adx, ady, i;
APD_LCD_POINT p;
short sdx, sdy;
short x, y;
unsigned char bit_mask;
dx = ep->x - sp->x + 1;
dy = ep->y - sp->y + 1;
sdx = LCDSign( dx );
sdy = LCDSign( dy );
adx = abs( dx );
ady = abs( dy );
x = 0;
y = 0;
p.x = sp->x;
p.y = sp->y;
/* Set line type pattern */
bit_mask = LCD_PAT_MASK;
/* If the slope is less than 1 (calcurate the value of Y coordinate
every X coordinate) */
if (adx >= ady) {
for (i = 0; i < adx; i++) {
/* Check the renewal Y coordinate value */
y += ady;
if (y >= adx) {
y -= adx;
p.y += sdy;
}
/* Draw pixel */
if (current_line_pat & bit_mask) {
/* Case of less than 1 line width */
if (current_gc.lw <= 1)
apd_LCDDrawPixel( &p );
else {
APD_LCD_POINT vp1, vp2;
unsigned char lt_bak;
APD_LCD_LINE_WIDTH lw_bak;
/* Set vertical line for line width */
if (p.y < (current_gc.lw >> 1))
vp1.y = 0;
else
vp1.y = p.y - (current_gc.lw >> 1);
vp2.y = p.y + (current_gc.lw >> 1) +
(current_gc.lw & 0x01);
vp1.x = vp2.x = p.x;
/* Save line type and width */
lt_bak = current_line_pat;
lw_bak = current_gc.lw;
current_line_pat = LCD_LINE_PAT[APD_LCD_LINE_SOLID];
current_gc.lw = APD_LCD_LINE_THIN;
/* Draw vertical line for line width */
apd_LCDDrawVline(&vp1, &vp2);
/* Return line type and width */
current_line_pat = lt_bak;
current_gc.lw = lw_bak;
}
}
bit_mask >>= 1;
if (bit_mask == 0)
bit_mask = LCD_PAT_MASK;
p.x += sdx;
}
}
/* If the slope is more than 1 (calcurate the value of X coordinate
every Y coordinate) */
else {
for (i = 0; i < ady; i++, (p.y += sdy)) {
/* Check the reneal X coordinate value */
x += adx;
if (x >= ady) {
x -= ady;
p.x += sdx;
}
/* Draw pixel */
if (p.y < 0)
continue;
if (current_line_pat & bit_mask) {
/* case of less than 1 line width */
if (current_gc.lw <= 1)
apd_LCDDrawPixel( &p );
else {
APD_LCD_POINT vp1, vp2;
APD_LCD_LINE_TYPE lt_bak;
unsigned char lp_bak;
APD_LCD_LINE_WIDTH lw_bak;
/* Set vertical line for line width */
if (p.x < (current_gc.lw >> APD_LCD_LINE_THIN))
vp1.x = 0;
else
vp1.x = p.x - (current_gc.lw >> 1);
vp2.x = p.x + (current_gc.lw >> 1) +
(current_gc.lw & 0x01);
vp1.y = vp2.y = p.y;
/* Save line type and width */
lt_bak = current_gc.lt;
lp_bak = current_line_pat;
lw_bak = current_gc.lw;
#if (APD_LCD_BPP == 16)
current_line_pat = LCD_LINE_PAT[APD_LCD_LINE_SOLID];
#else
current_gc.lt = APD_LCD_LINE_SOLID;
#endif
current_gc.lw = APD_LCD_LINE_THIN;
/* Draw vertical line for line width */
apd_LCDDrawHline(&vp1, &vp2);
/* Return line type and width */
current_gc.lt = lt_bak;
current_line_pat = lp_bak;
current_gc.lw = lw_bak;
}
}
bit_mask >>= 1;
if (bit_mask == 0)
bit_mask = LCD_PAT_MASK;
}
}
return;
}
/******************************************************************************
@@ [Name] : apd_LCDDrawEllipse
@@ [Summary] : Draw an ellipse
@@ [Argument] : cx : center X coordinate value
@@ cy : center Y coordinate value
@@ rx : radius of width
@@ ry : radius of height
@@ [Return] : None
@@ [Desc] : Draw an ellipse which adjoins the corresponding rectangle
@@ data according to current attributes.
@@ Valid attribute : Color, Raster operation, Line type
@@ [Comment] : Line width = 1
@@ [History] : Date Modifier Comment
******************************************************************************/
void DrawEllipse(int cx,int cy,int rx,int ry)
{
int dx, dy, xx, yy, ddx, ddy, dd;
APD_LCD_POINT pt;
if (rx > ry)
{
dx = rx; dy = 0; xx = 0; yy = ry; ddx = ddy = dd = rx;
while(dx >= dy) {
pt.x = cx + dx;
pt.y = cy + xx;
apd_LCDDrawPixel(&pt);
pt.y = cy - xx;
apd_LCDDrawPixel(&pt);
pt.x = cx - dx;
apd_LCDDrawPixel(&pt);
pt.y = cy + xx;
apd_LCDDrawPixel(&pt);
pt.x = cx + dy;
pt.y = cy + yy;
apd_LCDDrawPixel(&pt);
pt.x = cx - dy;
apd_LCDDrawPixel(&pt);
pt.y = cy - yy;
apd_LCDDrawPixel(&pt);
pt.x = cx + dy;
apd_LCDDrawPixel(&pt);
dd -= (dy << 1) - 1;
dy++;
ddx -= ry;
if (ddx < 0) {
ddx += rx;
xx++;
}
if (dd < 0) {
dd += (dx << 1);
--dx;
ddy -= ry;
if (ddy < 0) {
ddy += rx;
yy--;
}
}
}
} else {
// Longer than width
dx = 0; dy = ry; xx = rx; yy = 0; ddx = ddy = dd = ry;
while(dx <= dy) {
pt.x = cx + xx;
pt.y = cy + dx;
apd_LCDDrawPixel(&pt);
pt.y = cy - dx;
apd_LCDDrawPixel(&pt);
pt.x = cx - xx;
apd_LCDDrawPixel(&pt);
pt.y = cy + dx;
apd_LCDDrawPixel(&pt);
pt.x = cx + yy;
pt.y = cy + dy;
apd_LCDDrawPixel(&pt);
pt.x = cx - yy;
apd_LCDDrawPixel(&pt);
pt.y = cy - dy;
apd_LCDDrawPixel(&pt);
pt.x = cx + yy;
apd_LCDDrawPixel(&pt);
dd -= (dx << 1) - 1;
dx++;
ddy -= rx;
if (ddy < 0) {
ddy += ry; ++yy;
}
if (dd < 0) {
dd += (dy << 1);
--dy;
ddx -= rx;
if (ddx < 0) {
ddx += ry;
--xx;
}
}
}
}
}
/******************************************************************************
@@ [Name] : apd_LCDDrawEllipse
@@ [Summary] : Draw an ellipse
@@ [Argument] : point : Coordinate data
@@ dim : Length and width
@@ [Return] : None
@@ [Desc] : Line width = 1
@@ [History] : Date Modifier Comment
******************************************************************************/
void apd_LCDDrawEllipse(APD_LCD_POINT *point,APD_LCD_DIM *dim)
{
int cx, cy,
rx = dim->width / 2,
ry = dim->height / 2;
cx = point->x + rx;
cy = point->y + ry;
DrawEllipse(cx, cy, rx, ry);
}
/******************************************************************************
@@ [Name] : apd_LCDDrawRect
@@ [Summary] : The function to draw line of a rectangle
@@ [Argument] : point : Coordinate data
@@ dim : Length and width
@@ [Return] : None
@@ [Desc] : Draw the specific rectangle data according to
@@ the current attribute.
@@ Valid attribute : Color, Raster operation, Line width,Line type
@@ [History] : Date Modifier Comment
******************************************************************************/
void apd_LCDDrawRect(APD_LCD_POINT *point,APD_LCD_DIM *dim)
{
APD_LCD_POINT lt, rb; /* The upper left and the lower right point
of a rectangle */
APD_LCD_POINT p1, p2; /* The start point and the end point
of the straight line */
short y_max;
/* Check the area to draw */
if (dim->width < 0) {
lt.x = point->x + dim->width - 1;
rb.x = point->x;
} else {
lt.x = point->x;
rb.x = point->x + dim->width - 1;
}
if (dim->height < 0) {
lt.y = point->y + dim->height - 1;
rb.y = point->y;
} else {
lt.y = point->y;
rb.y = point->y + dim->height - 1;
}
/* Draw the left vertical line segment of a rectangle */
p1 = lt;
p2 = rb;
p1.y += ((current_gc.lw >> 1) + (current_gc.lw % 2));
if (current_gc.lw >> 1)
p2.y -= 2;
else
p2.y--;
p2.x = p1.x;
apd_LCDDrawVline(&p1, &p2);
/* Draw the right vertival line segment of a rectangle */
p1.x = rb.x;
p2.x = p1.x;
/* X coordinate of the end point doesn't change for drawing
because isn't refer currently */
apd_LCDDrawVline(&p1, &p2);
/* Draw the upper horizontal line segment of a rectangle */
p1 = lt;
p2 = rb;
if (current_gc.lw >> 1) {
p1.x -= current_gc.lw >> 1;
p2.x += (current_gc.lw % 2);
p1.y -= current_gc.lw >> 1;
y_max = lt.y + (current_gc.lw % 2);
} else
y_max = lt.y;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -