Cobra3, NHVN and resistive touch display

I am using a resistive touch display NHD-4.3-480272EF-ATXL#-T connected on the GXP port and I am trying to use the touch feature but do not now how to instantiate it.

Here’s my code:

using GHI.Glide;
using GHI.Glide.Display;
using GHI.Glide.UI;
using Microsoft.SPOT;
using System.Threading;

namespace MFConsoleApplication3
    public class Program
        public static void Main()
            Window window = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Window));
            Glide.FitToScreen = true;

            Button btn = (Button)window.GetChildByName("btn");
            btn.TapEvent += OnTap;

            Glide.MainWindow = window;


        private static void OnTap(object sender)
            Debug.Print("Button tapped.");

Any help would be appreciate:

The chances are that you are seeing touch but not where you think it should be. You need to calibrate resistive screens so you need to run the calibration first.

if (GlideTouch.Calibrated == false)
            // 1st argument is auto start, which immediately starts calibration once the window is open.
            // 2nd argument is auto save, which saves the calibration settings for future restarts.
            CalibrationWindow calWindow = new CalibrationWindow(false, true);
            // Called after the calibration is complete
            calWindow.CloseEvent += new OnClose(calWindow_CloseEvent);
            // Create the your main window here

After this is done you should find that it now works.

1 Like

Ok good seems logical but not described in the getting started doc and as a dummies if it is not written I do not even think about it…

I will test that as soon as I am in the office…

Glide has very little documentation on how to use a lot of it. :slight_smile:

Hum this is not as simple as I tought…

I do not know if this is a problem with the touch surface or not. Is there’s a way to erase the calibration values and restart calibration?

I run the code provided in the calibration documentation but it does not enter in the OnTouchUp event…

How have you connected the display? Are you using one of the new GHI modules for this?

You don’t nee the erase it. Simply call the calibration routine to start it and when done it will erase the old one.

Hi Dave it is connected using 2GXP port and NHVN module on FEZ Cobra3.

First time I run the calibration code, a red circle appears on the screen in several place. I press on the surface on each circle. Then I tried to rerun calibration code and now the screen is black only (no red circle).

I then tried to use the code where a blue circle follow the touch location and it was in the upper right corner of the screen…

I have a doubt about the touch surface:

running this:

public class Program : Application
    private Bitmap lcd;

    public static void Main()
        Program app = new Program();


    public Program()
        this.lcd = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);


        this.MainWindow = new Window();

        this.MainWindow.TouchDown += MainWindow_TouchDown;
        this.MainWindow.TouchUp += MainWindow_TouchUp;
        //this.MainWindow.TouchMove += MainWindow_TouchMove;

    private void MainWindow_TouchMove(object sender, TouchEventArgs e)
        Debug.Print("Touch move at (" + e.Touches[0].X.ToString() + ", " + e.Touches[0].Y.ToString() + ")");

        this.lcd.DrawEllipse(Colors.Blue, e.Touches[0].X, e.Touches[0].Y, 5, 5);

    private void MainWindow_TouchUp(object sender, TouchEventArgs e)
        Debug.Print("Touch up at (" + e.Touches[0].X.ToString() + ", " + e.Touches[0].Y.ToString() + ")");

    private void MainWindow_TouchDown(object sender, TouchEventArgs e)
        Debug.Print("Touch down at (" + e.Touches[0].X.ToString() + ", " + e.Touches[0].Y.ToString() + ")");

The output shows without touching the panel:

[quote]Touch down at (29, 6)
Touching the panel prints out:

Touch up at (0, 0)
Touch down at (32, 6)[/quote]

This display is new from yesterday…

after moving the ribbon cable a little bit I succeed to have the red circle again an starts the calibration:
It tooks me a long time to perform each points as if the TouchUp event was not fired.

Finaly here’s the result:
Screen X:[240, 48, 48,432,432]
Screen Y:[136, 26, 246,246,26]
Uncalibrated X:[694,701,714,708,702]
Uncalibrated Y:[693,697,696,695,702]

I am just receiving an new display to rerun the test. with the same results… could it be a problem with the NHVN display adapter?

I am a little bit frustrated…

Touch XL and Touch YU are pull down with 10k resistors

Without any press on the surface, here’s the measurements relative to GND:
Touch YU: 9.98kΩ
TouchYD: 10.19kΩ
Touch XR:10.68kΩ
TouchXL: 10.00kΩ

NHD specifs:
Min Typ MAX
Circuit Resistance - X‐Axis 450 800 1300 Ω
Circuit Resistance - Y‐Axis 100 350 800

Any idea?

@ leforban - You need to remap the touch pins. The GXP pinout does not define where touch is, only GPIO and analog.

GHI.Processor.Display.SetTouchPins(GHI.Pins.G120.AnalogInput.P0_24, GHI.Pins.G120.AnalogInput.P0_23, GHI.Pins.G120.P0_4, GHI.Pins.G120.P0_5);

1 Like

@ andre.m - It will be in the GXP documentation.

1 Like

It’s better when we know that!

Are you sure about the GXP pinout? there’s a post on the forum where the pins are:

instead of:

Display.SetTouchPins(G120.AnalogInput.P0_24, G120.AnalogInput.P0_23, G120.P0_4, G120.P0_5);

@ leforban - The Display NHVN and the GXP Gadgeteer Bridge use different pins for resistive touch. The Display NHVN uses pins 28, 30, 24, and 26 while the GXP Gadgeteer Bridge uses 28, 30, 38, and 34.