![]() |
VOOZH | about |
dotnet add package nanoFramework.Iot.Device.Chsc6540 --version 1.1.931
NuGet\Install-Package nanoFramework.Iot.Device.Chsc6540 -Version 1.1.931
<PackageReference Include="nanoFramework.Iot.Device.Chsc6540" Version="1.1.931" />
<PackageVersion Include="nanoFramework.Iot.Device.Chsc6540" Version="1.1.931" />Directory.Packages.props
<PackageReference Include="nanoFramework.Iot.Device.Chsc6540" />Project file
paket add nanoFramework.Iot.Device.Chsc6540 --version 1.1.931
#r "nuget: nanoFramework.Iot.Device.Chsc6540, 1.1.931"
#:package nanoFramework.Iot.Device.Chsc6540@1.1.931
#addin nuget:?package=nanoFramework.Iot.Device.Chsc6540&version=1.1.931Install as a Cake Addin
#tool nuget:?package=nanoFramework.Iot.Device.Chsc6540&version=1.1.931Install as a Cake Tool
The CHSC6540 is the touch screen controllers of the M5Stack Tough.
Important: make sure you properly setup the I2C pins especially for ESP32 before creating the I2cDevice, make sure you install the nanoFramework.Hardware.ESP32 nuget:
//////////////////////////////////////////////////////////////////////
// when connecting to an ESP32 device, need to configure the I2C GPIOs
// used for the bus
Configuration.SetPinFunction(21, DeviceFunction.I2C1_DATA);
Configuration.SetPinFunction(22, DeviceFunction.I2C1_CLOCK);
For other devices like STM32, please make sure you're using the preset pins for the I2C bus you want to use.
Note: this sample requires a M5Stack Tough. If you want to use another device, just remove all the related NuGet packages.
using System.Device.Gpio;
using System.Device.I2c;
using System.Diagnostics;
using System.Threading;
using Iot.Device.Chsc6540;
using nanoFramework.Hardware.Esp32;
//////////////////////////////////////////////////////////////////////
// when connecting to an ESP32 device, need to configure the I2C GPIOs
// used for the bus
Configuration.SetPinFunction(21, DeviceFunction.I2C1_DATA);
Configuration.SetPinFunction(22, DeviceFunction.I2C1_CLOCK);
I2cConnectionSettings settings = new(1, Chsc6540.DefaultI2cAddress);
using I2cDevice device = I2cDevice.Create(settings);
using GpioController gpio = new();
using Chsc6540 sensor = new(device);
sensor.SetInterruptMode(true);
gpio.OpenPin(39, PinMode.Input);
// This will enable an event on GPIO39 on falling edge when the screen if touched
gpio.RegisterCallbackForPinValueChangedEvent(39, PinEventTypes.Falling, TouchInterrupCallback);
while (true)
{
Thread.Sleep(20);
}
void TouchInterrupCallback(object sender, PinValueChangedEventArgs pinValueChangedEventArgs)
{
Debug.WriteLine("Touch interrupt");
var points = sensor.GetNumberPoints();
if (points == 1)
{
var point = sensor.GetPoint(true);
// Some controllers supports as well events, you can get access to them as well thru point.Event
Debug.WriteLine($"ID: {point.TouchId}, X: {point.X}, Y: {point.Y}, Weight: {point.Weigth}, Misc: {point.Miscelaneous}");
}
else if (points == 2)
{
var dp = sensor.GetDoublePoints();
Debug.WriteLine($"ID: {dp.Point1.TouchId}, X: {dp.Point1.X}, Y: {dp.Point1.Y}, Weight: {dp.Point1.Weigth}, Misc: {dp.Point1.Miscelaneous}");
Debug.WriteLine($"ID: {dp.Point2.TouchId}, X: {dp.Point2.X}, Y: {dp.Point2.Y}, Weight: {dp.Point2.Weigth}, Misc: {dp.Point2.Miscelaneous}");
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net net is compatible. |
Showing the top 1 NuGet packages that depend on nanoFramework.Iot.Device.Chsc6540:
| Package | Downloads |
|---|---|
|
nanoFramework.Tough
This package includes the nanoFramework.Tough assembly for .NET nanoFramework C# projects. |
Showing the top 1 popular GitHub repositories that depend on nanoFramework.Iot.Device.Chsc6540:
| Repository | Stars |
|---|---|
|
nanoframework/nanoFramework.M5Stack
📦 Board support package for M5Stack, M5StickC and M5StickCPlus for .NET nanoFramework
|
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0-preview.85 | 52 | 6/1/2026 |
| 2.0.0-preview.80 | 62 | 5/27/2026 |
| 2.0.0-preview.69 | 84 | 5/18/2026 |
| 2.0.0-preview.62 | 63 | 5/13/2026 |
| 2.0.0-preview.49 | 71 | 5/4/2026 |
| 2.0.0-preview.45 | 56 | 4/29/2026 |
| 2.0.0-preview.40 | 59 | 4/27/2026 |
| 2.0.0-preview.32 | 57 | 4/20/2026 |
| 2.0.0-preview.18 | 87 | 3/11/2026 |
| 2.0.0-preview.16 | 65 | 3/10/2026 |
| 1.1.931 | 468 | 11/10/2025 |
| 1.1.907 | 314 | 10/2/2025 |
| 1.1.864 | 473 | 4/2/2025 |
| 1.1.852 | 404 | 3/11/2025 |
| 1.1.822 | 573 | 2/26/2025 |
| 1.1.785 | 523 | 2/4/2025 |
| 1.1.775 | 377 | 2/4/2025 |
| 1.1.772 | 268 | 2/4/2025 |
| 1.1.755 | 383 | 1/31/2025 |
| 1.1.737 | 306 | 1/13/2025 |