Remarks

Tsc2004
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Hid.Tsc2004

Code Example

Tsc2004 touchScreen;

public override Task Initialize()
{
    Console.WriteLine("Initialize...");

    var i2cBus = Device.CreateI2cBus(I2cBusSpeed.Fast, 0);

    touchScreen = new Tsc2004(i2cBus)
    {
        DisplayWidth = 240,
        DisplayHeight = 320,
        XMin = 260,
        XMax = 3803,
        YMin = 195,
        YMax = 3852,
        Rotation = RotationType._90Degrees
    };

    return Task.CompletedTask;
}

public override Task Run()
{
    return Task.Run(() =>
    {
        Point3d pt;

        while (true)
        {
            if (touchScreen.IsTouched())
            {
                pt = touchScreen.GetPoint();
                Console.WriteLine($"Location: X:{pt.X}, Y:{pt.Y}, Z:{pt.Z}");
            }

            Thread.Sleep(0);
        }
    });
}

Sample project(s) available on GitHub

Wiring Example

To wire a Tsc2004 to your Meadow board, connect the following:

Tsc2004 Meadow Pin
GND GND
SCL D08 (SCL)
SDA D07 (SDA)
VCC 3V3
Characteristic Locus
Inheritance System.Object > Tsc2004
Namespace Meadow.Foundation.Sensors.Hid
Assembly Tsc2004.dll

Syntax

public class Tsc2004 : object

Constructors

Tsc2004(II2cBus, Byte)

Create a new Tsc2004 object

Declaration
public Tsc2004(II2cBus i2cBus, byte address = null)

Parameters

Type Name Description
II2cBus i2cBus

The I2C bus

System.Byte address

The I2C address

Properties

DisplayHeight

Height of display in pixels at default rotation

Declaration
public int DisplayHeight { get; set; }

Property Value

Type Description
System.Int32

DisplayWidth

Width of display in pixels at default rotation

Declaration
public int DisplayWidth { get; set; }

Property Value

Type Description
System.Int32

Rotation

Touchscreen rotation

Declaration
public RotationType Rotation { get; set; }

Property Value

Type Description
RotationType

XMax

Maximum X value of touchscreen

Declaration
public int XMax { get; set; }

Property Value

Type Description
System.Int32

XMin

Minimum X value of touchscreen

Declaration
public int XMin { get; set; }

Property Value

Type Description
System.Int32

YMax

Maximum Y value of touchscreen

Declaration
public int YMax { get; set; }

Property Value

Type Description
System.Int32

YMin

Minimum Y value of touchscreen

Declaration
public int YMin { get; set; }

Property Value

Type Description
System.Int32

Methods

GetPoint()

Get the current scaled touch location

Declaration
public Point3d GetPoint()

Returns

Type Description
Point3d

GetPointRaw()

Get the current raw touch location

Declaration
public Point3d GetPointRaw()

Returns

Type Description
Point3d

IsBufferEmpty()

Is the touch buffer empty

Declaration
public bool IsBufferEmpty()

Returns

Type Description
System.Boolean

True if empty

IsTouched()

Does the screen detect an active touch

Declaration
public bool IsTouched()

Returns

Type Description
System.Boolean

True if touched