Skip to main content

Meadow.Foundation.Sensors.Hid.Xpt2046

Xpt2046
StatusStatus badge: working
Source codeGitHub
Datasheet(s)GitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Sensors.Hid.Xpt2046

Code Example

privateXpt2046 touchScreen;

publicoverrideTaskInitialize()
{
Resolver.Log.Info("Initialize...");

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

touchScreen =newXpt2046(
Device.CreateSpiBus(),
Device.Pins.D04.CreateDigitalInterruptPort(InterruptMode.EdgeFalling, ResistorMode.InternalPullUp),
Device.Pins.D05.CreateDigitalOutputPort(true));

touchScreen.TouchDown += TouchScreen_TouchDown;

return Task.CompletedTask;
}

privatevoidTouchScreen_TouchDown(ITouchScreen sender,TouchPoint point)
{
Resolver.Log.Info($"Touch at location: X:{point.ScreenX}, Y:{point.ScreenY}");
}

Sample project(s) available on GitHub

close