コード例 #1
0
void Touch_Tests(void)
{
	int firstx ;
	int firsty ;
	int x ;
	int y ;
	int state ;
	gfx_Cls() ;
	putstr("Touch Tests\n") ;
	printf("Touch Tests.\n") ;
	putstr("Please ensure Touch is only\ndetected in the Blue area") ;
	printf("Detecting touch in Region\n") ;
	touch_Set(TOUCH_ENABLE) ;
	touch_DetectRegion(100,100, 200, 200) ;
	gfx_RectangleFilled(100,100, 200, 200, BLUE) ;
	do {} while (touch_Get(TOUCH_STATUS) != TOUCH_PRESSED);
	touch_Set(TOUCH_REGIONDEFAULT) ;
	gfx_Cls() ;
	putstr("Draw.. Drawing stops\nwhen touch released\n") ;
	printf("Drawing\n") ;

	while(touch_Get(TOUCH_STATUS) != TOUCH_PRESSED)
	{      // we"ll wait for a touch
	}
	firstx = touch_Get(TOUCH_GETX);                          // so we can get the first point
	firsty = touch_Get(TOUCH_GETY);
	while(state != TOUCH_RELEASED)
	{
		state = touch_Get(TOUCH_STATUS);                       // look for any touch activity
		x = touch_Get(TOUCH_GETX);                             // grab the x
		y = touch_Get(TOUCH_GETY);                             // and the y coordinates of the touch
		if (state == TOUCH_PRESSED)                               // if there"s a press
		{
			firstx = x;
			firsty = y;
		}

		if (state == TOUCH_MOVING)                                // if there"s movement
		{
			gfx_Line(firstx, firsty, x, y, BLUE);                 // but lines are much better
			firstx = x;
			firsty = y;
		}
	}
	putstr("Done!\n") ;
	touch_Set(TOUCH_DISABLE) ;
}
コード例 #2
0
int main() 
{
    int rc;
    int firstx ;
    int firsty ;
    int x ;
    int y ;
    int state ;
    
    TimeLimit4D = 2000;
    Callback4D = errCallback;
    // abort on detected 4D Serial error
    Error_Abort4D = 1 ;
    comspeed = 9600;
    //WORD *x = 0x001A;
    //char *s = sys_GetModel(&x);
    //x  = &0x001A;
    rc = OpenComm(SERIALPORT, comspeed);
    if (rc != 0)
    {
        printf("Error %d Opening: %s - %s\n", errno, SERIALPORT, strerror(errno));
        exit(EXIT_FAILURE);
    }

	gfx_Cls() ;
	putStr("Touch Tests\n") ;
	printf("Touch Tests.\n") ;
	putStr("Please ensure Touch is only\ndetected in the Blue area") ;
	printf("Detecting touch in Region\n") ;
	touch_Set(TOUCH_ENABLE) ;
	touch_DetectRegion(100,100, 200, 200) ;
	gfx_RectangleFilled(100,100, 200, 200, BLUE) ;
	do {} while (touch_Get(TOUCH_STATUS) != TOUCH_PRESSED);
	touch_Set(TOUCH_REGIONDEFAULT) ;
	gfx_Cls() ;
	putStr("Draw.. Drawing stops\nwhen touch released\n") ;
	printf("Drawing\n") ;

	while(touch_Get(TOUCH_STATUS) != TOUCH_PRESSED)
	{      // we"ll wait for a touch
	}
	firstx = touch_Get(TOUCH_GETX);                          // so we can get the first point
	firsty = touch_Get(TOUCH_GETY);
	while(state != TOUCH_RELEASED)
	{
		state = touch_Get(TOUCH_STATUS);                       // look for any touch activity
		x = touch_Get(TOUCH_GETX);                             // grab the x
		y = touch_Get(TOUCH_GETY);                             // and the y coordinates of the touch
		if (state == TOUCH_PRESSED)                               // if there"s a press
		{
			firstx = x;
			firsty = y;
		}
		if (state == TOUCH_MOVING)                                // if there"s movement
		{
			gfx_Line(firstx, firsty, x, y, BLUE);                 // but lines are much better
			firstx = x;
			firsty = y;
		}
	}
	putStr("Done!\n") ;
	touch_Set(TOUCH_DISABLE);
    	
    return (EXIT_SUCCESS);
}