TSC2003 Glide Calibration G120

Hello,

i am trying to get running the touch collecting on my G120 module with custom LCD. I have chosen the TSC2003 as TouchScreen controller. - resistive TouchScreen, I have working communication with chip in managed. Now i am feeding Glide with coordinates. But i can’t calibrate the screen. Is there any way to do it through Glide? As i have seen the calibration in Glide source, the calibration is feeded from MS.Spot.Touch Input. Is there any way to feed my Touches from managed code to MS.Spot.Touch Input? Or is there a possibility to do it in native?

How is it done on CP7? The Touchscreen controller have calibration on chip?

Thank you very much
ohala


        private static int Measure(Commands command)
        {     
            lock (_locker)
            {
                //mask interrupt
                _touchINT.DisableInterrupt();

                MeasTrans[0] = I2CDevice.CreateWriteTransaction(new byte[]{(byte)command});
                int resp = TSCdevice.Execute(MeasTrans, 100);

                Thread.Sleep(1);

                MeasTrans[0] = I2CDevice.CreateReadTransaction(ReceiveBuffer);
                resp = TSCdevice.Execute(MeasTrans, 100);

                _touchINT.EnableInterrupt();

                if (resp < 2) return -1;

                // ACK is 0 NACK is 1
                // Read Transaction: SACK D11 D10 D9 D8 D7 D6 D5 D4 MACK D3 D2 D1 D0 0 0 0 0 MNACK

                int high = ((int)(ReceiveBuffer[0] << 4));
                int low = ((int)(ReceiveBuffer[1] >> 4));

                return (high | low);
            }
        }
          
            // These are used for the touch up event
            static int lastX = 0;
            static int lastY = 0;
 
            // These store the current X and Y
            static int x;
            static int y;
 
            // Keeps track of whether the panel was touched or not
            static bool isTouched = false;
 
            // Create touch inputs that are used as arguments
            static Microsoft.SPOT.Touch.TouchInput[] touches = new Microsoft.SPOT.Touch.TouchInput[1];
            

            // Create I2C Transactions to retry

            static byte[] Xbuff = new byte[2];
            static byte[] Ybuff = new byte[2];


        private static void TouchINT_OnInterrupt(uint port, uint state, DateTime time)
        {
            _touchINT.DisableInterrupt();

            touches[0] = new Microsoft.SPOT.Touch.TouchInput();
            

            while (!_touchINT.Read()) //touch panel is touched
            {
                // Read the touch panel and
                // get the X & Y coordinates

                x = Measure(Commands.MeasX);
                y = Measure(Commands.MeasY);


                if (isTouched == false)
                {
                    // Touch down
                    touches[0].X = x;
                    touches[0].Y = y;
                    GlideTouch.RaiseTouchDownEvent(null, new TouchEventArgs(touches));

                    if (_debugMode) Debug.Print("TSC 2003>> TouchDown (X=" + touches[0].X + ";Y=" + touches[0].Y.ToString() + ")");

                    lastX = x;
                    lastY = y;
                    isTouched = true;
                }
                else
                {
                    // Filter finger movements to avoid spamming
                    if (System.Math.Abs(x - lastX) > pixelSpamming || System.Math.Abs(y - lastY) > pixelSpamming)
                    {
                        // Touch move
                        touches[0].X = x;
                        touches[0].Y = y;
                        GlideTouch.RaiseTouchMoveEvent(null, new TouchEventArgs(touches));

                        if (_debugMode) Debug.Print("TSC 2003>> TouchMove (X=" + touches[0].X.ToString() + ";Y=" + touches[0].Y.ToString() + ")");

                        lastX = x;
                        lastY = y;
                    }
                }
            Thread.Sleep(touchPollTime);
            }
            
            //touch end
            if (isTouched == true)
            {
                // Touch up
                touches[0].X = lastX;
                touches[0].Y = lastY;

                GlideTouch.RaiseTouchUpEvent(null, new TouchEventArgs(touches));

                if (_debugMode) Debug.Print("TSC 2003>> TouchUp (X=" + touches[0].X.ToString() + ";Y=" + touches[0].Y.ToString() + ")");
                isTouched = false;
            }

            _touchINT.EnableInterrupt();
        }

    }

This is not possible but we have requested this from Microsoft, to be able to feed in touch to the system so you can utilize the built in features like calibration.

The request has been “postponed” so maybe you can add your input here http://netmf.codeplex.com/workitem/1745

Thanks Gus.