📄 gpcdrv.c
字号:
else
mask=mask<<1;
if (d>=0) /*取像素E*/
{ d+=incrE;
y++;
}
else /*取像素NE*/
{ d+=incrNE;
y++;
x++;
}
}
}
}
else
{ dy=y0-y1;
if (dy<dx)
{ d=-(2*dy-dx); /*初始化判别式d*/
incrE=-2*dy; /*取像素E时判别式的增量*/
incrNE=-2*(dy-dx); /*取像素NE时判别式的增量*/
x=x0,y=y0;
while (x<=x1)
{
if( ( mask&0x8000 ) == 0x8000 )
{
seGetPixel(x,y, &invertcolor);
seSetPixel(x,y,~invertcolor);
mask=( mask<<1 )|0x0001 ;
}
else
mask=mask<<1;
if (d>=0) /*取像素E*/
{ d+=incrE;
x++;
}
else /*取像素NE*/
{ d+=incrNE;
x++;
y--;
}
}
}
else
{ d=-(2*dx-dy); /*初始化判别式d*/
incrE=-2*dx; /*取像素E时判别式的增量*/
incrNE=-2*(dx-dy); /*取像素NE时判别式的增量*/
x=x0,y=y0;
while (y>=y1)
{
if( ( mask&0x8000 ) == 0x8000 )
{
seGetPixel(x,y, &invertcolor);
seSetPixel(x,y,~invertcolor);
mask=( mask<<1 )|0x0001 ;
}
else
mask=mask<<1;
if (d>=0) /*取像素E*/
{ d+=incrE;
y--;
}
else /*取像素NE*/
{ d+=incrNE;
y--;
x++;
}
}
}
}
}
//return GPC_ERR_OK;
}
//-------------------------------------------------------------------------
// seSetImage()
//
// This function put a device depent image onto the screen. The image buffer format is device relative.
// The raster operation method defines how the color data for the source recangle is
// to be combined with the color data for the destination rectangle to achieve the final color
// Parameters:
// x,y: specified the left-up position where the image will be placed
// width: specified the image width
// height: specified the image height
// buffer: the buffer contains the image data
// method: raster operation method
// Returns:
// GPC_ERR_OK
//-------------------------------------------------------------------------
void seSetImage( S16 x, S16 y, S16 width, S16 height , U8 *buffer, U8 method )
{
S16 x1,y1,x2,y2,i;
unsigned short temp;
unsigned char *ucpTmpDispMem;
x1 = x;
y1 = y;
x2 = x1 + width;
y2 = y1 + height;
i = 0;
switch(method)
{
case NOT_PUT:
for (y=y1;y<y2;y++)
{
/*
vDisableInterrupt();
*(volatile unsigned char *)LCD_Command = 0x75; // Page Address Set
asm("nop");
*(volatile unsigned char *)LCD_Data = y;
*(volatile unsigned char *)LCD_Data = y;
*(volatile unsigned char *)LCD_Command = 0x15; // Column Address Set
asm("nop");
*(volatile unsigned char *)LCD_Data = x1;
*(volatile unsigned char *)LCD_Data = x2;
*(volatile unsigned short *)LCD_Command = 0x5C;
*/
for (x=x1;x<x2;x++)
{
*(volatile unsigned short *)LCD_Data = ~buffer[i];
i++;
}
//*(volatile unsigned char *)LCD_Command = 0x25; //NOP command
vEnableInterrupt();
}
break;
case XOR_PUT:
for (y=y1;y<y2;y++)
{
/*
vDisableInterrupt();
*(volatile unsigned char *)LCD_Command = 0x75; // Page Address Set
asm("nop");
*(volatile unsigned char *)LCD_Data = y;
*(volatile unsigned char *)LCD_Data = y;
*(volatile unsigned char *)LCD_Command = 0x15; // Column Address Set
asm("nop");
*(volatile unsigned char *)LCD_Data = x1;
*(volatile unsigned char *)LCD_Data = x2;
*(volatile unsigned short *)LCD_Command = 0xE0; // Read don't modify address(command 19)
*/
for (x=x1;x<x2;x++)
{
// *(volatile unsigned short *)LCD_Command = 0x5D; // Read command
temp = *(volatile unsigned short *)LCD_Data; // Dummy read
//seGetPixel(x,y,&temp1);
temp = *(volatile unsigned short *)LCD_Data; // Data read
temp ^= buffer[i];
//seSetPixel(x,y,temp);
// *(volatile unsigned short *)LCD_Command = 0x5C; // Data write(and address modified)
*(volatile unsigned short *)LCD_Data = temp;
i++;
}
*(volatile unsigned short *)LCD_Command = 0xEE; // Read don't modify address(command 20)
vEnableInterrupt();
}
break;
case OR_PUT:
for (y=y1;y<y2;y++)
{
vDisableInterrupt();
*(volatile unsigned char *)LCD_Command = 0x75; // Page Address Set
asm("nop");
*(volatile unsigned char *)LCD_Data = y;
*(volatile unsigned char *)LCD_Data = y;
*(volatile unsigned char *)LCD_Command = 0x15; // Column Address Set
asm("nop");
*(volatile unsigned char *)LCD_Data = x1;
*(volatile unsigned char *)LCD_Data = x2;
*(volatile unsigned short *)LCD_Command = 0xE0; // Read don't modify address(command 19)
for (x=x1;x<x2;x++)
{
// *(volatile unsigned short *)LCD_Command = 0x5D; // Read command
temp = *(volatile unsigned short *)LCD_Data; // Dummy read
//seGetPixel(x,y,&temp1);
temp = *(volatile unsigned short *)LCD_Data; // Data read
temp |= buffer[i];
//seSetPixel(x,y,temp);
// *(volatile unsigned short *)LCD_Command = 0x5C; // Data write(and address modified)
*(volatile unsigned short *)LCD_Data = temp;
i++;
}
*(volatile unsigned short *)LCD_Command = 0xEE; // Read don't modify address(command 20)
vEnableInterrupt();
}
break;
case AND_PUT:
for (y=y1;y<y2;y++)
{
vDisableInterrupt();
*(volatile unsigned char *)LCD_Command = 0x75; // Page Address Set
asm("nop");
*(volatile unsigned char *)LCD_Data = y;
*(volatile unsigned char *)LCD_Data = y;
*(volatile unsigned char *)LCD_Command = 0x15; // Column Address Set
asm("nop");
*(volatile unsigned char *)LCD_Data = x1;
*(volatile unsigned char *)LCD_Data = x2;
*(volatile unsigned short *)LCD_Command = 0xE0; // Read don't modify address(command 19)
for (x=x1;x<x2;x++)
{
// *(volatile unsigned short *)LCD_Command = 0x5D; // Read command
temp = *(volatile unsigned short *)LCD_Data; // Dummy read
//seGetPixel(x,y,&temp1);
temp = *(volatile unsigned short *)LCD_Data; // Data read
temp &= buffer[i];
//seSetPixel(x,y,temp);
// *(volatile unsigned short *)LCD_Command = 0x5C; // Data write(and address modified)
*(volatile unsigned short *)LCD_Data = temp;
i++;
}
*(volatile unsigned short *)LCD_Command = 0xEE; // Read don't modify address(command 20)
vEnableInterrupt();
}
break;
default:// COPY_PUT
for (y=y1;y<y2;y++)
{
ucpTmpDispMem = ucpMemBaseAddr;
ucpTmpDispMem+=y*S1D_ONE_LINE_BYTES_NUMBER;
for (x=x1;x<x2;x++)
{
unsigned char *DispMem =ucpTmpDispMem+x ;
*DispMem =*(buffer++);
}
}
}
}
//------------------------------------------------------------------------------
// Function name : seSetMonoImageLine
// Description : set mono line of a image in buffer onto screen
// No return value
// Argument : PPHYIMAGEINFO ppii
// S16 ppii->x
// S16 ppii->y
// S16 ppii->width
// U8* ppii->buffer
// U8 ppii->method
// U16 ppii->ColorIndex
// U16 ppii->BkColorIndex
// Remarks : before the line being put, it should be converted to
// hardware dependent format. In this driver, a 256 color one.
// Generally, this function is always used to implement font
// and text function.
// So also :
//------------------------------------------------------------------------------
void seSetMonoImageLine( PPHYIMAGEINFO ppii )
{
U8 TgtLine[320];// the maximum size of a line is width of the screen.
S16 i, sByte, sBit;
sByte = 0;
sBit = 0x80;
for(i=0;i<ppii->width;i++)
{
if( ppii->buffer[sByte] & sBit )
TgtLine[i] = (U8)(ppii->ColorIndex);
else
TgtLine[i] = (U8)(ppii->BkColorIndex);
sBit=sBit>>1;
if( !sBit )
{
sBit = 0x80;
sByte++;
}
}
seSetImage( ppii->x, ppii->y, ppii->width, 1, TgtLine, ppii->method );
}
//------------------------------------------------------------------------------
// Function name : seSetMonoImage
// Description :
// No return value
// Argument : PPHYIMAGEINFO ppii
// Remarks :
// So also :
//------------------------------------------------------------------------------
void seSetMonoImage( PPHYIMAGEINFO ppii )
{
S16 height;
PHYIMAGEINFO pii;
U8* pImageLineStart;
S16 sBytesPerLine;
// get a new physical image information header for put image line
memcpy( &pii, ppii, sizeof( PHYIMAGEINFO ) );
// pointer to data of first line
pImageLineStart = ppii->buffer;
// bytes per line
sBytesPerLine = ( ppii->width + 7 ) / 8;
height=ppii->height;
while( height-- )
{
pii.buffer = pImageLineStart;
pImageLineStart += sBytesPerLine;
seSetMonoImageLine( &pii );
pii.y++;
}
}
//-------------------------------------------------------------------------
// seGetImage()
//
// This function retrieves a block of screen data as an image into a buffer.
// the image buffer format is device relative.
//
// Parameters:
// x,y: specified the left-up position where the image will be placed
// width: specified the image width
// height: specified the image height
// buffer: the buffer contains the image data
// Returns:
// GPC_ERR_OK
//-------------------------------------------------------------------------
void seGetImage( S16 x, S16 y, S16 width, S16 height, U16 *buffer )
{
S16 x1,y1,x2,y2,i;
x1 = x;
y1 = y;
x2 = x1 + width;
y2 = y1 + height;
i = 0;
for (y=y1;y<y2;y++)
for (x=x1;x<x2;x++)
{
seGetPixel(x, y, &buffer[i]);
i++;
}
// return GPC_ERR_OK;
}
/*
void seGetImage( S16 x, S16 y, S16 width, S16 height, U16 *buffer )
{
S16 x1,y1,x2,y2,i,j,k;
U16 temp;
x1 = x;
y1 = y;
x2 = x1 + width;
y2 = y1 + height;
j = 0;
// *(volatile unsigned char *)LCD_Command = 0x75; // Page Address Set
// *(volatile unsigned char *)LCD_Data = y1;
// *(volatile unsigned char *)LCD_Data = y2;
// *(volatile unsigned char *)LCD_Command = 0x15; // Column Address Set
// *(volatile unsigned char *)LCD_Data = x1;
// *(volatile unsigned char *)LCD_Data = x2;
// *(volatile unsigned short *)LCD_Command = 0x5D;
// for (i = 0;i<width*height;i++)
// buffer[i] = *(volatile unsigned short *)LCD_Data;
for (y=y1;y<y2;y++)
{
vDisableInterrupt();
*(volatile unsigned char *)LCD_Command = 0x75; // Page Address Set
*(volatile unsigned char *)LCD_Data = y;
*(volatile unsigned char *)LCD_Data = y;
*(volatile unsigned char *)LCD_Command = 0x15; // Column Address Set
*(volatile unsigned char *)LCD_Data = x1;
*(volatile unsigned char *)LCD_Data = x2;
*(volatile unsigned char *)LCD_Command = 0xee;
*(volatile unsigned short *)LCD_Command = 0x5D;
i =0;
k =0;
for (x=x1;x<x2;x++)
{
if (i*2 < width)
buffer[j*width+i*2] = *(volatile unsigned short *)LCD_Data;
else
{
buffer[j*width+k*2+1] = *(volatile unsigned short *)LCD_Data;
k++;
}
i++;
}
j++;
*(volatile unsigned char *)LCD_Command = 0x25; //NOP command
vEnableInterrupt();
}
// return GPC_ERR_OK;
}
*/
//-------------------------------------------------------------------------
// seRGBtoIndex()
//
// This function maps the color value in RGB to a closest color index
//
// Parameters:
// rgb: a color value in RGB format to be converted
// index: retrieves the index value corresponding to the rgb value
// Returns:
// GPC_ERR_OK
//-------------------------------------------------------------------------
void seRGBtoIndex( RGB rgb, U16 *ColorIndex )
{ /*
unsigned short tempR;
unsigned short tempG;
unsigned short tempB;
tempR = (unsigned short)( rgb >> 8 )& 0xf000; /*Red color */
//tempG = (unsigned short)( rgb >> 4 )& 0x0f00; /*Green color*/
//tempB = (unsigned short) rgb & 0xf0; /*Blue color*/
//if (rgb==GPC_BLACK)
//*ColorIndex = tempR|tempG|tempB;
//*ColorIndex = 0x00;
//if (rgb==GPC_WHITE)
//*ColorIndex = 0xff;
//return GPC_ERR_OK;
*ColorIndex = (unsigned char)rgb;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -