/***********************************************************************************
* @fn      getTsXY
*
* @brief   Main Function, called by App_Layer to get the co-ordinates (touched or not) of TouchScreen.
*
* @param   unsigned int *xCoord
*			Ptr to get X-Coordinate
*		   unsigned int *yCoord
*			Ptr to get Y-Coordinate
*
* @return  none
*/
void getTsXY(unsigned int *xCoord, unsigned int *yCoord) {
	
	Initialize_TouchScreen();               // Initialize device
	readXY();                             	// Get X,Y coordinates
	*xCoord = x;
	*yCoord = y;
}
Example #2
0
static gfxmatrix_t read_matrix(reader_t*r, state_t*state, U8 id, U8 flags)
{
    assert(id>=0 && id<16);
    if(flags&FLAG_SAME_AS_LAST) {
	gfxmatrix_t m = state->last_matrix[id];
	readXY(r, state, &m);
	return m;
    }
    gfxmatrix_t m = readMatrix(r, state);
    state->last_matrix[id] = m;
    return m;
}
void waitButton(u16 *x, u16 *y)
{
	while(1){
		while(T_IRQ){}
		delay_ms(5);
		if(!readXY(x, y)){
			continue;
		}
		break;
	}
	while(!T_IRQ){}
	delay_ms(20);
}
/***********************************************************************************
* @fn      TouchScreen
*
* @brief   Main Function, called by App_Layer to get the co-ordinates (touched or not) of TouchScreen.
*
* @param   none
*
* @return  none
*/
void TouchScreen(void)
{
	Initialize_TouchScreen();               // Initialize device
	waitForTouch();                         // Wait for touch on screen
	touched = 1;                            // Screen is touched
	while(1)
	{                                       // Loop while screen is touched
		readXY();                             // Get X,Y coordinates index 0
	
		// Take 2 values and see the difference between them.
		// If value is greater than 5 steps, discard packet.
		// This code is designed to take a majority vote of 2 packets.
		if(x > 1100 && x < 4600 && y > 700 && y < 5300)
				sendData(x,y);                // Send data to host
	}
}