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)

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

Parameters

Type Name Description
II2cBus i2cBus
System.Byte address

Properties

DisplayHeight

Declaration
public int DisplayHeight { get; set; }

Property Value

Type Description
System.Int32

DisplayWidth

Declaration
public int DisplayWidth { get; set; }

Property Value

Type Description
System.Int32

Rotation

Declaration
public RotationType Rotation { get; set; }

Property Value

Type Description
RotationType

XMax

Declaration
public int XMax { get; set; }

Property Value

Type Description
System.Int32

XMin

Declaration
public int XMin { get; set; }

Property Value

Type Description
System.Int32

YMax

Declaration
public int YMax { get; set; }

Property Value

Type Description
System.Int32

YMin

Declaration
public int YMin { get; set; }

Property Value

Type Description
System.Int32

Methods

GetPoint()

Declaration
public Point3d GetPoint()

Returns

Type Description
Point3d

GetPointRaw()

Declaration
public Point3d GetPointRaw()

Returns

Type Description
Point3d

GetXForRotation(Int32, Int32)

Declaration
public int GetXForRotation(int x, int y)

Parameters

Type Name Description
System.Int32 x
System.Int32 y

Returns

Type Description
System.Int32

GetYForRotation(Int32, Int32)

Declaration
public int GetYForRotation(int x, int y)

Parameters

Type Name Description
System.Int32 x
System.Int32 y

Returns

Type Description
System.Int32

IsBufferEmpty()

Declaration
public bool IsBufferEmpty()

Returns

Type Description
System.Boolean

IsTouched()

Declaration
public bool IsTouched()

Returns

Type Description
System.Boolean