Meadow.Foundation.Sensors.Hid.Xpt2046
Xpt2046 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
private Xpt2046 touchScreen;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var i2cBus = Device.CreateI2cBus(I2cBusSpeed.Fast);
touchScreen = new Xpt2046(
Device.CreateSpiBus(),
Device.Pins.D04.CreateDigitalInterruptPort(InterruptMode.EdgeFalling, ResistorMode.InternalPullUp),
Device.Pins.D05.CreateDigitalOutputPort(true));
touchScreen.TouchDown += TouchScreen_TouchDown;
return Task.CompletedTask;
}
private void TouchScreen_TouchDown(ITouchScreen sender, TouchPoint point)
{
Resolver.Log.Info($"Touch at location: X:{point.ScreenX}, Y:{point.ScreenY}");
}
Sample project(s) available on GitHub
Class Xpt2046
Represents an XPT2046 4-wire touch screen controller
Assembly: Xpt2046.dll
View Source
public class Xpt2046 : ICalibratableTouchscreen, ITouchScreen
Implements:
Meadow.Hardware.ICalibratableTouchscreen
, Meadow.Hardware.ITouchScreen
Properties
Rotation
Gets the current rotation of the touchscreen
View Source
public RotationType Rotation { get; }
IsCalibrated
Returns <b>true</b> if the touchscreen has been calibrated, otherwise <b>false</b>
View Source
public bool IsCalibrated { get; }
IsTouched
Returns <b>true</b> if the touchscreen is currently being touched, otherwise <b>false</b>
View Source
public bool IsTouched { get; }
Methods
SetCalibrationData(IEnumerable<CalibrationPoint>)
Sets the calibration data for the touchscreen
View Source
public void SetCalibrationData(IEnumerable<CalibrationPoint> data)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Meadow.Hardware.CalibrationPoint> | data | The calibration point |
Events
TouchDown
Event raised when the touchscreen is pressed
View Source
public event TouchEventHandler? TouchDown
Event Type
Meadow.Hardware.TouchEventHandler
TouchUp
Event raised when the touchscreen is released
View Source
public event TouchEventHandler? TouchUp
Event Type
Meadow.Hardware.TouchEventHandler
TouchClick
Event raised when a cycle of press and release has occurred
View Source
public event TouchEventHandler? TouchClick
Event Type
Meadow.Hardware.TouchEventHandler
TouchMoved
Event raised when a cycle of press and release has occurred
View Source
public event TouchEventHandler? TouchMoved
Event Type
Meadow.Hardware.TouchEventHandler
Implements
Meadow.Hardware.ICalibratableTouchscreen
Meadow.Hardware.ITouchScreen