Bad touch position from FEZ Spider with CP7 display

Hi all,

Recently I discovered some strange behaviour with my CP7 display. A faulty touch postion is returned in Display_CP7.TouchStatus by the Display_CP7.TouchEventHandler if the display is touched for a [em]very short[/em] time. Instead of the touched position, the previous touch position is returned.

I have 2 buttons Yes and No positioned on the display. Normally touching button Yes returns the postion of button Yes and touching button No returns the postion of button No. However, I noticed that sometimes the [em]wrong [/em]button was activated. Lateron I discovered the most recent touch position is returned if the display is touched for a very short time. This behaviour can be reproduced very easily.

Anyone else noticed this behaviour? Could this be a bug?

Regards, Jos

Below is my code from the ScreenPressed handler:



        static GHIElectronics.NETMF.Glide.Geom.Point lastTouch;
        static bool isTouched = false;
        const int MAX_TOUCH_MOVE = 5;

        void display_CP7_ScreenPressed(Display_CP7 sender, Display_CP7.TouchStatus touchStatus)
        {
            //Reset display timeout mode
            SetDisplayTimeoutMode(false);

            GHIElectronics.NETMF.Glide.Geom.Point currTouch;
            if (touchStatus.numTouches > 0)
            {
                //Only processing 1st touch
                currTouch.X = touchStatus.touchPos[0].xPos;
                currTouch.Y = touchStatus.touchPos[0].yPos;

                //Touch down?
                if (!isTouched)
                {
		if ((currTouch.X == lastTouch.X) && (currTouch.Y == lastTouch.Y))
		{
			//This is a bug
			//If the display is pressed for a very short time
			//The previous touch position is returned
			Debug.Print("Ignored faulty touch at" + currTouch.ToString());
		}
		else
		{
			GlideTouch.RaiseTouchDownEvent(null, new TouchEventArgs(currTouch));
			isTouched = true;
		}
                }
                //Touch move? (filter small finger movements to avoid spamming)
                else if ((System.Math.Abs(currTouch.X - lastTouch.X) > MAX_TOUCH_MOVE) ||
                    (System.Math.Abs(currTouch.Y - lastTouch.Y) > MAX_TOUCH_MOVE))
                {
                    GlideTouch.RaiseTouchMoveEvent(null, new TouchEventArgs(currTouch));
                }
                //Still touched
                else
                {
                    //No actions
                }
	lastTouch = currTouch;

 #if TRACE
	BeepSoft();
	Debug.Print("lastTouch=" + lastTouch.ToString());

	int iLast = touchStatus.numTouches;
	if (iLast > touchStatus.touchPos.Length)
		iLast = touchStatus.touchPos.Length;
	for (int i = 1; i < iLast; i++)
	{
		Debug.Print("xPos[" + i.ToString() + "] = " + touchStatus.touchPos[i].xPos.ToString());
		Debug.Print("yPos[" + i.ToString() + "] = " + touchStatus.touchPos[i].yPos.ToString());
	}
 #endif
	}

        }

        void display_CP7_screenReleased(Display_CP7 sender)
        {
            //Touch up
            if (isTouched)
            {
                BeepLoud();
                GlideTouch.RaiseTouchUpEvent(null, new TouchEventArgs(lastTouch));
                isTouched = false;
            }


 #if DEBUG_TOUCH
            Debug.Print("Screen released ");
 #endif
        }


It is very easy to reproduce this behaviour. If the display is pressed fore a very short time often the previous touch position is returned (sometimes wit a difference of 1 in X or Y.

This display requires a lot of power. Double check your power source.

@ Andre: by touching the display as short as I can, I can reproduce this behaviour.

@ Gus: the display is connected to FEZ Spider. Fez Spider is power from the DP USB Client V 1.3, which in turn is powerd from 12 V. That should do the trick isn’t it?

Yes 12V 1A should be fine.

I am not familiar with the touch input process. Of course, there is always the possibility something’s going wrong in the driver.

The code for the touch handler display_CP7_ScreenPressed() has been derived from this page: http://www.ghielectronics.com/glide/example/5/
From the example I understand I have to feed the touch events into Glide myself, which is exactly what is done.

I followed the touch events going into glide. The calculations to determine if a control (e.g. a button) is touched is completely done in the Glide library.

Yes I use a GHI display, the CP7.
Will try without my own handler an post the result here.

I closely followed the guidelines of the example and build a console application.
Unfortunately with this program nothing happens when I touch the screen.
But then again: I wonder how is the application to know where the display’s touch is connected?

With the above result in mind I build a Gadgeteer application (4.2)
However, no touch response there either.