⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xslcdtest.c

📁 PXA270的LCD测试程序
💻 C
字号:
/******************************************************************************
**
**  COPYRIGHT (C) 2000, 2001 Intel Corporation.
**
**  This software, as well as the software described in it, is furnished under
**  license and may only be used or copied in accordance with the terms of the
**  license. The information in this file is furnished for informational use
**  only, is subject to change without notice, and should not be construed as
**  a commitment by Intel Corporation. Intel Corporation assumes no
**  responsibility or liability for any errors or inaccuracies that may appear
**  in this document or any software that may be provided in association with
**  this document.
**  Except as permitted by such license, no part of this document may be
**  reproduced, stored in a retrieval system, or transmitted in any form or by
**  any means without the express written consent of Intel Corporation.
**
**  FILENAME:       XsLcdTest.c
**
**  PURPOSE:        This file contains Test functions for the LCD Controller.
**
**  LAST MODIFIED:  $Modtime: 7/17/03 1:01p $
******************************************************************************/

/************* Header Files *************/

#include <stdio.h>
#include <string.h>
#include "systypes.h"
#include "dm_errors.h"
#include "platform.h"
#include "xslcdcontroller.h"
#include "XsLcdTest.h"
#include "timedelays.h"
#include "mallocx.h"
#include "ROS.h"

/************* Global Functions *************/

/*
*******************************************************************************
*
* FUNCTION:         XsLcdPictureTest
*
* DESCRIPTION:      This test will display a (640 * 480 pixels;16bpp) Windows BMP
*                   file. It calls ParseWindowsBmpFile() to convert a 24bpp BMP into
*                   16bpp format, before displaying the picture is possible.
*
* INPUT PARAMETERS: None.
*
* RETURNS:          Number of errors.
*
* GLOBAL EFFECTS:   None.
*
* ASSUMPTIONS:      None.
*
* CALLS:            VerifyBmpHeader
*                   ParseBmpFile
*
* CALLED BY:
*
* PROTOTYPE:        UINT XsLcdPictureTest(void);
*
*******************************************************************************
*/

UINT XsLcdPictureTest(void)
{
    ErrorT retVal;
    
	printf(" Testing LCD\r\n");
    PostDisplayProgress(ERR_L_LCD, 0x80, 0);
    retVal = XsLcdHWSetup();
    if (retVal != ERR_NONE) {
        XllpUtilityOutputError(retVal);
    	return 1;
    }
    PostDisplayProgress(ERR_L_LCD, 0x80, 1);

	if (XsLcdBmp((BmpT *)BMP_FILE_START_VIRT_ADDR)) 
	{;
	}
	else
	{
		// no bitmap found so create a default picture
		XsLcdCreateDefaultPicture();
	}
        PostDisplayProgress(ERR_L_LCD, 0x80, 2);
        XsLcdOn();  // Enable the LCD Controller.
        PostDisplayProgress(ERR_L_LCD, 0x80, 3);
        DM_WaitMs(500); // Let the LCD settle down before turning on the backlight,
    	XsLcdBackLightOn(); //Turn on the backlight
        PostDisplayProgress(ERR_L_LCD, 0x80, 4);
        //DM_WaitS(2);	masked by hzh
    	printf(" Success!\r\n");
    	return 0;
//	} else {
//        XllpUtilityOutputError(ERRORCODEX(ERR_L_LCD, 0x80, 0, ERR_T_BMP));
//    	return 1;
//    }
}

/************* Global Kludge Functions *************/

/*
*******************************************************************************
*
* FUNCTION:         KXsLcdPictureTest
*
* DESCRIPTION:      Kludge for legacy code.
*
* INPUT PARAMETERS: void *arg - Ignored.
*                   CHAR *param - Ignored.
*
* RETURNS:			None.
*
* GLOBAL EFFECTS:	None.
*
* ASSUMPTIONS:		None.
*
* CALLS:            XsLcdPictureTest()
*
* CALLED BY:        Command List.
*
* PROTOTYPE:        void KXsLcdPictureTest(PVOID arg, PCHAR param);
*
*******************************************************************************
*/

void KXsLcdPictureTest(PVOID arg, PCHAR param)
{
    XsLcdPictureTest();
}

/*
*******************************************************************************
*
* FUNCTION:         XsLcdCreateDefaultPicture
*
* DESCRIPTION:      Creates a test image directly in the frame buffer.
*
* INPUT PARAMETERS: void .
*                   
*
* RETURNS:			None.
*
* GLOBAL EFFECTS:	None.
*
* ASSUMPTIONS:		None.
*
* CALLS:            
*
* CALLED BY:        XsLcdPictureTest
*
* PROTOTYPE:        void XsLcdCreateDefaultPicture(VOID);
*
*******************************************************************************
*/
void XsLcdCreateDefaultPicture()
{
	UINT16 xmax;
	UINT16 ymax; 		
	UINT16 x, y;
	UINT16 color_red =   0xF800;
	UINT16 color_green = 0x07e0;
	UINT16 color_blue =  0x001F;
	UINT16 color_white = 0xFFFF;
	UINT16 color_yellow =  0xFFE0;
	UINT16 color_cyan   =0x07FF;
	UINT16 color_magenta = 0xF81F;
	UINT16 color;
	UINT16 color_bar_startx;
	UINT16 color_bar_starty;
	UINT16 bar = 6;
	UINT16 step;
	UINT16 characters_across;
	char * title = "POST Test Image";
	UINT16 i;


	// determine the size limits by the type of screen
	if (GetLcdPanelID() == LCDID_SHARP_QVGA)
	{
		if (GetLcdPanelOrientation())
		{	// landscape
			xmax = 239;
			ymax = 319;
			characters_across = 40; 
		}
		else
		{	// portrait
			xmax = 319;
			ymax = 239;
			characters_across = 30; 
		}
	}
	else
	{
		if (GetLcdPanelOrientation())
		{	// landscape
			xmax = 639;
			ymax = 479;
			characters_across = 40; 
		}
		else
		{	// portrait
			xmax = 479;
			ymax = 639;
			characters_across = 30; 
		}
		
	}
	
	// put some text up
	// characters are already sized to work in the screens
	
	// skip the first line
	for(i=0; i<characters_across; i++)
		XsLcdStr(" ");

	// center the text
	for(i=0; i<(characters_across/2) - strlen(title)/2; i++)
		XsLcdStr(" ");

	XsLcdStr(title);


	// create the border
	
	color = color_white;

	for (x=0; x<=xmax; x++)
	{
		y = 0;
		XsLcdPutXY(x, y, color);
	}
	for (x=0; x<=xmax; x++)
	{
		y = ymax;
		XsLcdPutXY(x, y, color);
	}
	for (y=0; y<=ymax; y++)
	{
		x = 0;
		XsLcdPutXY(x, y, color);
	}
	for (y=0; y<=ymax; y++)
	{
		x = xmax;
		XsLcdPutXY(x, y, color);
	}


	// create the color bars 40 x 40 pixels
	color_bar_startx = (xmax/2) - 80; 
	color_bar_starty = 20;
	
	// create a white background
	for(x=color_bar_startx; x<color_bar_startx +160; x++)
	{
		for(y = color_bar_starty; y <color_bar_starty + 40; y++)
		XsLcdPutXY(x, y, color_white);
			
	}

	// put in color bars
	do
	{
		if(bar == 6)
		{
			color = color_red;
			step = 5;
		//	printf("red\r\n");
		}
		else if(bar == 5)
		{
			color = color_green;
			step = 30;
		//	printf("green\r\n");

		}
		else if(bar == 4)
		{
			color = color_blue;
			step = 55;
		//	printf("blue\r\n");

		}
		else if(bar == 3)
		{
			color = color_cyan;
			step = 80;
		//	printf("cyan\r\n");

		}
		else if(bar == 2)
		{
			color = color_yellow;
			step = 105;
		//	printf("yellow\r\n");

		}
		else if(bar == 1)
		{
			color = color_magenta;
			step = 130;
	   //		printf("magenta\r\n");

		}



		for(x=color_bar_startx + step; x<color_bar_startx + step +25; x++)
		{
			for(y = color_bar_starty + 5; y <color_bar_starty + 35; y++)
			XsLcdPutXY(x, y, color);
				
		}

		bar--;
		//printf("bar = %d\r\n", bar);
	} while(bar != 0);
	
	// mark the center of the screen and touch points on the corners
	
	color = color_white;

	color_bar_startx = 0;
	color_bar_starty = 0;
	
	for(x=color_bar_startx; x<color_bar_startx +xmax/25; x++)
	{
		for(y = color_bar_starty ; y <color_bar_starty + ymax/25; y++)
		XsLcdPutXY(x, y, color);
			
	}
	color_bar_startx = xmax - xmax/25;
	color_bar_starty = 0;
	
	for(x=color_bar_startx; x<color_bar_startx +xmax/25; x++)
	{
		for(y = color_bar_starty ; y <color_bar_starty + ymax/25; y++)
		XsLcdPutXY(x, y, color);
			
	}
	color_bar_startx = 0;
	color_bar_starty = ymax - ymax/25;
	
	for(x=color_bar_startx; x<color_bar_startx +xmax/25; x++)
	{
		for(y = color_bar_starty ; y <color_bar_starty + ymax/25; y++)
		XsLcdPutXY(x, y, color);
			
	}
	color_bar_startx = xmax - xmax/25;
	color_bar_starty = ymax	- ymax/25;
	
	for(x=color_bar_startx; x<color_bar_startx +xmax/25; x++)
	{
		for(y = color_bar_starty ; y <color_bar_starty + ymax/25; y++)
		XsLcdPutXY(x, y, color);
			
	}
	
	color_bar_startx = xmax/2 - xmax/50;
	color_bar_starty = ymax/2 - ymax/50;
	
	for(x=color_bar_startx; x<color_bar_startx +xmax/25; x++)
	{
		for(y = color_bar_starty ; y <color_bar_starty + ymax/25; y++)
		XsLcdPutXY(x, y, color);
			
	}

	// put the red dot at the first pixel and a green at the last.
	// used for clock timing inspection
	XsLcdPutXY(0, 0, color_red);
	XsLcdPutXY(xmax, ymax, color_green);


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -