Hi Guys,
Does anybody know if the 3.5 TFT display on the G120E development board is touch sensitive?
If so, how would I go about reading it in TinyCLR OS? Is it just a case of having to read the lines via the ADC?
Thanks
David
Hi Guys,
Does anybody know if the 3.5 TFT display on the G120E development board is touch sensitive?
If so, how would I go about reading it in TinyCLR OS? Is it just a case of having to read the lines via the ADC?
Thanks
David
The display does support resistive touch. However, TinyCLR doesn’t have a resistive touch driver at the moment. You’d have to try and implement one on your own if needed.
Thanks John,
I haven’t got the board here with me at the moment but in theory can I just do something like this:
public class Touch
{
private readonly GpioPin _x2Pin;
private readonly GpioPin _y2Pin;
private readonly GpioPin _x1Pin;
private readonly GpioPin _y1Pin;
private readonly AdcChannel _x1Adc;
private readonly AdcChannel _y1Adc;
public Touch()
{
var gpioController = GpioController.GetDefault();
_x1Pin = gpioController.OpenPin(G120E.GpioPin.P0_23);
_x2Pin = gpioController.OpenPin(G120E.GpioPin.P2_23);
_y1Pin = gpioController.OpenPin(G120E.GpioPin.P0_24);
_y2Pin = gpioController.OpenPin(G120E.GpioPin.P3_31);
var adcController = AdcController.GetDefault();
_x1Adc = adcController.OpenChannel(G120E.AdcChannel.P0_23);
_y1Adc = adcController.OpenChannel(G120E.AdcChannel.P0_24);
new Thread(Monitor).Start();
}
private void Monitor()
{
while (true)
{
//Read X
_y1Pin.SetDriveMode(GpioPinDriveMode.Input);
_y2Pin.SetDriveMode(GpioPinDriveMode.Input);
_y2Pin.Write(GpioPinValue.Low);
_x1Pin.SetDriveMode(GpioPinDriveMode.Output);
_x1Pin.Write(GpioPinValue.High);
_x2Pin.SetDriveMode(GpioPinDriveMode.Output);
_x2Pin.Write(GpioPinValue.Low);
var x = _y1Adc.ReadValue();
// Read Y
_x1Pin.SetDriveMode(GpioPinDriveMode.Input);
_x2Pin.SetDriveMode(GpioPinDriveMode.Input);
_x2Pin.Write(GpioPinValue.Low);
_y1Pin.SetDriveMode(GpioPinDriveMode.Output);
_y1Pin.Write(GpioPinValue.High);
_y2Pin.SetDriveMode(GpioPinDriveMode.Output);
_y2Pin.Write(GpioPinValue.Low);
var y = _x1Adc.ReadValue();
if (x != 0)
Debug.WriteLine(x + "," + y);
Thread.Sleep(10);
}
}
}
Is there an existing NetMF driver that I could port over?
It’ll be something along those lines, yes. I don’t have a test program handy at the moment.