📄 xslcdcontroller.c
字号:
// PostDisplayProgress(ERR_L_LCD, 0xa, 1);
XsLcdScroll();
}
// PostDisplayProgress(ERR_L_LCD, 0xa, 2);
for (py=0; py<FONT_VERT_PIX; py++)
for (px=0; px<FONT_HORZ_PIX; px++)
for (s1=0; s1<XsLcdFontScale; s1++)
for (s2=0; s2<XsLcdFontScale; s2++)
XsLcdPutXY(
(x*FONT_HORZ_PIX+px)*XsLcdFontScale+s1,
(XsLcdOrient!=LRTB?frameP->header.horizPixel:frameP->header.vertPixel)-1 // Max y pixel.
- ((y*FONT_VERT_PIX+py)*XsLcdFontScale+s2),
(font[c][py]&(0x80>>px))?XsLcdFg:XsLcdBg
);
x++;
}
// PostDisplayProgress(ERR_L_LCD, 0xa, 3);
if (!XsLcdTask) {
if (FIFOcharsAvailable(fifo)) continue;
return; // If the task isn't running, just return.
}
ROS_Sleep(ROS_Task);
// PostDisplayProgress(ERR_L_LCD, 0xa, 4);
ROS_Release();
// PostDisplayProgress(ERR_L_LCD, 0xa, 5);
}
}
/*
*******************************************************************************
*
* FUNCTION: XsLcdPutXY
*
* DESCRIPTION: This function writes a pixel to the LCD.
* The origin (0,0) is the lower left hand corner.
*
* INPUT PARAMETERS: UINT16 x - The "X" coordinate.
* UINT16 y - The "Y" coordinate.
* UINT16 p - The pixel data to put.
*
* RETURNS: None.
*
* GLOBAL EFFECTS: None.
*
* ASSUMPTIONS: 16 bits per pixel
*
* CALLS: None.
*
* CALLED BY: Anyone.
*
* PROTOTYPE: void XsLcdPutXY(UINT16 x, UINT16 y, UINT16 p);
*
*******************************************************************************
*/
void XsLcdPutXY(UINT16 x, UINT16 y, UINT16 p)
{
if (XsLcdOrient == BTLR) { // Scan is Bottom to Top, Left to Right
// PostDisplayProgress(ERR_L_LCD, 0xd, 0);
*(frameP->buffer + y +
x*frameP->header.horizPixel) = p;
} else if (XsLcdOrient == LRTB) { // Scan is Left to Right, Top to Bottom
// PostDisplayProgress(ERR_L_LCD, 0xd, 1);
*(frameP->buffer + x +
(frameP->header.vertPixel-y-1)*frameP->header.horizPixel) = p;
// *(frameP->buffer +y*frameP->header.horizPixel//Scan is Left to Right, Top to Bottom
// +x) = p;
} else if (XsLcdOrient == TBRL) { // Scan is Top to Bottom, Right to Left
*(frameP->buffer + (frameP->header.horizPixel-y-1) +
(frameP->header.vertPixel-x-1)*frameP->header.horizPixel) = p;
} else if(XsLcdOrient == 3 ) { // Scan is Right to Left, Bottom to Top
*(frameP->buffer +y*frameP->header.horizPixel
+x) = p;
}
// PostDisplayProgress(ERR_L_LCD, 0xd, 2);
}
void XsLcdPutXY1(UINT16 x, UINT16 y, UINT16 p)
{
if (XsLcdOrient == BTLR) { // Scan is Bottom to Top, Left to Right
// PostDisplayProgress(ERR_L_LCD, 0xd, 0);
*(frameP->buffer + y +
x*frameP->header.horizPixel) = p;
} else if (XsLcdOrient == LRTB) { // Scan is Left to Right, Top to Bottom
// PostDisplayProgress(ERR_L_LCD, 0xd, 1);
// *(frameP->buffer + x +
// (frameP->header.vertPixel-y-1)*frameP->header.horizPixel) = p;
*(frameP->buffer +y*frameP->header.horizPixel//Scan is Left to Right, Top to Bottom
+x) = p;
} else if (XsLcdOrient == TBRL) { // Scan is Top to Bottom, Right to Left
*(frameP->buffer + (frameP->header.horizPixel-y-1) +
(frameP->header.vertPixel-x-1)*frameP->header.horizPixel) = p;
} else if(XsLcdOrient == 3 ) { // Scan is Right to Left, Bottom to Top
*(frameP->buffer +y*frameP->header.horizPixel
+x) = p;
}
// PostDisplayProgress(ERR_L_LCD, 0xd, 2);
}
void XsLcdGetXY(U16 x,U16 y, U16 *mem)
{
//if ( (x < SCR_XSIZE_TFT_240320) && (y < SCR_YSIZE_TFT_240320) )
//{
// *mem = LCD_BUFER[ y*SCR_XSIZE_TFT_240320 + x ] ;
// return 0 ;
//}
if (XsLcdOrient == BTLR) { // Scan is Bottom to Top, Left to Right
// PostDisplayProgress(ERR_L_LCD, 0xd, 0);
*mem=*(frameP->buffer + y +
x*frameP->header.horizPixel);
} else if (XsLcdOrient == LRTB) { // Scan is Left to Right, Top to Bottom
// PostDisplayProgress(ERR_L_LCD, 0xd, 1);
// *mem=*(frameP->buffer + x +
// (frameP->header.vertPixel-y-1)*frameP->header.horizPixel);
*mem=*(frameP->buffer +y*frameP->header.horizPixel//Scan is Left to Right, Top to Bottom
+x) ;
} else if (XsLcdOrient == TBRL) { // Scan is Top to Bottom, Right to Left
*mem=*(frameP->buffer + (frameP->header.horizPixel-y-1) +
(frameP->header.vertPixel-x-1)*frameP->header.horizPixel);
}
//return -1;
}
void Glib_Line(int x1,int y1,int x2,int y2,int color)
{
int dx,dy,e;
dx=x2-x1;
dy=y2-y1;
if(dx>=0)
{
if(dy >= 0) // dy>=0
{
if(dx>=dy) // 1/8 octant
{
e=dy-dx/2;
while(x1<=x2)
{
XsLcdPutXY1(x1,y1,color);
if(e>0){y1+=1;e-=dx;}
x1+=1;
e+=dy;
}
}
else // 2/8 octant
{
e=dx-dy/2;
while(y1<=y2)
{
XsLcdPutXY1(x1,y1,color);
if(e>0){x1+=1;e-=dy;}
y1+=1;
e+=dx;
}
}
}
else // dy<0
{
dy=-dy; // dy=abs(dy)
if(dx>=dy) // 8/8 octant
{
e=dy-dx/2;
while(x1<=x2)
{
XsLcdPutXY1(x1,y1,color);
if(e>0){y1-=1;e-=dx;}
x1+=1;
e+=dy;
}
}
else // 7/8 octant
{
e=dx-dy/2;
while(y1>=y2)
{
XsLcdPutXY1(x1,y1,color);
if(e>0){x1+=1;e-=dy;}
y1-=1;
e+=dx;
}
}
}
}
else //dx<0
{
dx=-dx; //dx=abs(dx)
if(dy >= 0) // dy>=0
{
if(dx>=dy) // 4/8 octant
{
e=dy-dx/2;
while(x1>=x2)
{
XsLcdPutXY1(x1,y1,color);
if(e>0){y1+=1;e-=dx;}
x1-=1;
e+=dy;
}
}
else // 3/8 octant
{
e=dx-dy/2;
while(y1<=y2)
{
XsLcdPutXY1(x1,y1,color);
if(e>0){x1-=1;e-=dy;}
y1+=1;
e+=dx;
}
}
}
else // dy<0
{
dy=-dy; // dy=abs(dy)
if(dx>=dy) // 5/8 octant
{
e=dy-dx/2;
while(x1>=x2)
{
XsLcdPutXY1(x1,y1,color);
if(e>0){y1-=1;e-=dx;}
x1-=1;
e+=dy;
}
}
else // 6/8 octant
{
e=dx-dy/2;
while(y1>=y2)
{
XsLcdPutXY(x1,y1,color);
if(e>0){x1-=1;e-=dy;}
y1-=1;
e+=dx;
}
}
}
}
}
/*
*******************************************************************************
*
* FUNCTION: XsLcdBmp
*
* DESCRIPTION: This function is responsible for parsing a BMP
* file (24bpp depth), converting it into a 16bpp
* depth format and displaying the converted file.
*
* INPUT PARAMETERS: BmpT *bmpP - Pointer to the BMP.
*
* RETURNS: TRUE if successful, else FALSE.
*
* GLOBAL EFFECTS: None.
*
* ASSUMPTIONS: None.
*
* CALLS:
*
* CALLED BY: Anyone.
*
* PROTOTYPE: void XsLcdBmp(BmpT *bmpP);
*
*******************************************************************************
*/
BOOL XsLcdBmp(BmpT *bmpP)
{
UINT x, y, z=0;
BOOL twist = FALSE;
UINT orient = XsLcdOrient;
// First, verify it.
// look for the expected width and height
PostDisplayProgress(ERR_L_LCD, 0xc, 0);
((PUINT16)bmpHeader)[9] = frameP->header.horizPixel;
((PUINT16)bmpHeader)[11] = frameP->header.vertPixel;
// compute the expected file size.
x = frameP->header.horizPixel;
x *= frameP->header.vertPixel;
x *= 3; // 3 bytes per pixel
((PUINT16)bmpHeader)[17] = (UINT16)(x % 0x10000);
((PUINT16)bmpHeader)[18] = (UINT16)(x / 0x10000);
x += 54; // .BMP header size
((PUINT16)bmpHeader)[1] = (UINT16)(x % 0x10000);
((PUINT16)bmpHeader)[2] = (UINT16)(x / 0x10000);
for (x=0; x<sizeof(bmpP->header)/4; x++) {
if (((PUINT32)bmpP->header)[x] != bmpHeader[x]) {
PostDisplayProgress(ERR_L_LCD, 0xc, 1);
if (x==4 && !twist) { // try the other orientation
PostDisplayProgress(ERR_L_LCD, 0xc, 2);
x = bmpHeader[4]; // swap expected width and height
bmpHeader[4] = bmpHeader[5];
bmpHeader[5] = x;
twist = TRUE;
x = 3;
} else return FALSE;
}
}
// Now, parse it.
if (twist) {
if (XsLcdOrient == LRTB) XsLcdOrient = BTLR;
PostDisplayProgress(ERR_L_LCD, 0xc, 3);
for (y=0; y<frameP->header.horizPixel; y++) {
for (x=0; x<frameP->header.vertPixel; x++) {
XsLcdPutXY(
x,
y,
XsLcdRGB565(
bmpP->pixel[z].red,
bmpP->pixel[z].green,
bmpP->pixel[z].blue
)
);
z++;
}
if (!(y&0xf)) ROS_Release();
}
} else {
if (XsLcdOrient != LRTB) XsLcdOrient = LRTB;
PostDisplayProgress(ERR_L_LCD, 0xc, 4);
for (y=0; y<frameP->header.vertPixel; y++) {
for (x=0; x<frameP->header.horizPixel; x++) {
XsLcdPutXY(
x,
y,
XsLcdRGB565(
bmpP->pixel[z].red,
bmpP->pixel[z].green,
bmpP->pixel[z].blue
)
);
z++;
}
if (!(y&0xf)) ROS_Release();
}
}
XsLcdOrient = orient; // Restore orientation;
PostDisplayProgress(ERR_L_LCD, 0xc, 5);
return TRUE;
}
/**************************************************************
320×240 16Bpp TFT LCD全屏填充特定颜色单元或清屏
**************************************************************/
void Lcd_ClearScr( U32 c)
{
unsigned int x,y ;
for( y = 0 ; y < LCD_XSIZE_TFT_240320 ; y++ )
{
for( x = 0 ; x < LCD_XSIZE_TFT_240320 ; x++ )
{
//LCD_BUFER[y*SCR_XSIZE_TFT_240320+x] = c;
*(frameP->buffer + y*frameP->header.horizPixel+x)=c;
}
}
}
void Glib_ClearScr( U32 c )
{
unsigned int x,y ;
for( y = 0 ; y < LCD_XSIZE_TFT_240320 ; y++ )
{
for( x = 0 ; x < LCD_XSIZE_TFT_240320 ; x++ )
{
//LCD_BUFER[y*SCR_XSIZE_TFT_240320+x] = c;
*(frameP->buffer + y*frameP->header.horizPixel+x)=c;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -