📄 tsttouchscreen.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: TstTouchscreen.c
**
** PURPOSE: This module contains the tests for the TouchScreen.
**
** LAST MODIFIED: $Modtime: 7/25/03 2:13p $
******************************************************************************/
/************* Header Files *************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "systypes.h"
#include "dm_errors.h"
#include "DM_Debug.h"
#include "timedelays.h"
#include "TstAc97Api.h"
#include "Ucb1400_Touch.h"
#include "AD7873_Touch.h"
#include "TstTouchscreen.h"
#include "xsuart.h"
#include "DM_SerialInOut.h"
#include "BoardControl.h"
#include "XsPwm.h"
#include "xslcdcontroller.h"
#include "XsLcdTest.h"
/************* Global Functions *************/
/*
*******************************************************************************
*
* FUNCTION: TstTouchscreen
*
* DESCRIPTION: Test the AC97 connected UCB1400 Touchscreen.
*
* INPUT PARAMETERS: None.
*
* RETURNS: Number of errors.
*
* GLOBAL EFFECTS: None.
*
* ASSUMPTIONS: None.
*
* CALLS:
*
* CALLED BY: POST
*
* PROTOTYPE: UINT TstTouchscreen(void);
*
*******************************************************************************
*/
#define WAITFORTOUCH 3000 // 30 seconds.
#define DEBOUNCE 50 // .5 seconds.
#define POINTS 50
UINT TstTouchscreen(void)
{
ErrorT retVal;
UINT16 x, y, z;
UINT16 timeout=WAITFORTOUCH, timeout2;
INT16 px[50], py[50];
INT32 meanX, meanY;
BOOL debug_mode = FALSE;
UINT touchcount = 5;
INT32 touchpointx;
INT32 touchpointy;
int i;
//#define take_samples // go into a loop to take empirical samples
#ifdef take_samples
int sample_count = 0;
int x_tally = 0;
int y_tally = 0;
#endif
PostDisplayProgress(ERR_L_TS, 0x80, 0);
retVal = PostAc97Init();
if (retVal != ERR_NONE) {
printf(" Testing UCB1400 rev.?? Touch Screen\r\n");
goto error;
}
//swStatus = ReadUserSwitches();
// Check if Debug mode
if (POSTRunState() & VS_DEBUG_ON)
{
// Enable debug mode
debug_mode = TRUE;
}
PostDisplayProgress(ERR_L_TS, 0x80, 1);
retVal = TS_HWSetup();
PostDisplayProgress(ERR_L_TS, 0x80, 2);
printf(" Testing UCB1400 rev.%s Touch Screen\r\n",
ucb1400rev==REVISION1B ? "1B" :
ucb1400rev==REVISION2A ? "2A" : "??"
);
if (retVal != ERR_NONE) goto error;
// printf(" User! Set the four touchscreen switches set to \"UCB1400\".\r\n");
// GetUserResponse(YES);
XsLcdClear();
XsLcdCreateDefaultPicture();
// Do this 5 times. Each test is at a different position
printf(" User! Touch the squares on the screen in the following order:\r\n");
printf(" User! Center, Upper Left, Upper Right, Lower Left, Lower Right\r\n");
printf(" User! Begin touching after you continue.\r\n");
GetUserResponse(YES);
do
{
if (GetLcdPanelID() == LCDID_SHARP_QVGA)
{
switch(touchcount)
{
case 5:
// printf(" User! Touch the center of the screen.\r\n");
// GetUserResponse(YES);
if (GetLcdPanelOrientation()){
touchpointx = 0x206;
touchpointy = 0x21b;
}
else{
touchpointx = 0x1ff;
touchpointy = 0x220;
}
break;
case 4:
// printf(" Testing UCB1400 Touch Screen - upper left\r\n");
// printf(" User! Touch the upper left target after you continue.\r\n");
// GetUserResponse(YES);
if (GetLcdPanelOrientation()){
touchpointx = 0x75;
touchpointy = 0x3a7;
}
else {
touchpointx = 0x071;
touchpointy = 0x088;
}
break;
case 3:
// printf(" Testing UCB1400 Touch Screen - upper right\r\n");
// printf(" User! Touch the upper right target after you continue.\r\n");
// GetUserResponse(YES);
if (GetLcdPanelOrientation()){
touchpointx = 0x079;
touchpointy = 0x085;
}
else{
touchpointx = 0x38a;
touchpointy = 0x8e;
}
break;
case 2:
// printf(" Testing UCB1400 Touch Screen - lower left\r\n");
// printf(" User! Touch the lower left target after you continue.\r\n");
// GetUserResponse(YES);
if (GetLcdPanelOrientation()){
touchpointx = 0x392;
touchpointy = 0x3ac;
}
else{
touchpointx = 0x6f;
touchpointy = 0x3a5;
}
break;
case 1:
// printf(" Testing UCB1400 Touch Screen - lower right\r\n");
// printf(" User! Touch the lower right target after you continue.\r\n");
// GetUserResponse(YES);
if (GetLcdPanelOrientation()){
touchpointx = 0x38d;
touchpointy = 0x08b;
}
else{
touchpointx = 0x391;
touchpointy = 0x3a7;
}
break;
default:
printf(" User! Internal error in program.\r\n");
break;
}
}
else
{
switch(touchcount)
{
case 5:
// printf(" User! Touch the center of the screen after you continue.\r\n");
// GetUserResponse(YES);
if (GetLcdPanelOrientation()){
touchpointx = 0x220;
touchpointy = 0x1f2;
}
else{
touchpointx = 0x21e;
touchpointy = 0x1f4;
}
break;
case 4:
// printf(" Testing UCB1400 Touch Screen - upper left\r\n");
// printf(" User! Touch the upper left target after you continue.\r\n");
// GetUserResponse(YES);
if (GetLcdPanelOrientation()){
touchpointx = 0x08d;
touchpointy = 0x38b;
}
else {
touchpointx = 0x3AA;
touchpointy = 0x392;
}
break;
case 3:
// printf(" Testing UCB1400 Touch Screen - upper right\r\n");
// printf(" User! Touch the upper right target after you continue.\r\n");
// GetUserResponse(YES);
if (GetLcdPanelOrientation()){
touchpointx = 0x3ac;
touchpointy = 0x38f;
}
else{
touchpointx = 0x3AB;
touchpointy = 0x5B;
}
break;
case 2:
// printf(" Testing UCB1400 Touch Screen - lower left\r\n");
// printf(" User! Touch the lower left target after you continue.\r\n");
// GetUserResponse(YES);
if (GetLcdPanelOrientation()){
touchpointx = 0x89;
touchpointy = 0x59;
}
else{
touchpointx = 0x8F;
touchpointy = 0x38D;
}
break;
case 1:
// printf(" Testing UCB1400 Touch Screen - lower right\r\n");
// printf(" User! Touch the lower right target after you continue.\r\n");
// GetUserResponse(YES);
if (GetLcdPanelOrientation()){
touchpointx = 0x3a5;
touchpointy = 0x058;
}
else{
touchpointx = 0x8b;
touchpointy = 0x05B;
}
break;
default:
printf(" User! Internal error in program.\r\n");
break;
}
}
#ifdef take_samples
debug_mode = TRUE;
do {
#endif
do {
retVal = TS_GetPenStatus();
if (retVal == TS_PENDOWN) {
if (timeout == WAITFORTOUCH) {
retVal = ERRORCODEX(ERR_L_TS, 0x80, 2, ERR_T_UNEXPECTED);
goto error;
} else if (timeout2-- == 0) break;
} else {
watchPen:
timeout2 = DEBOUNCE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -