nanoFramework.Iot.Device.Chsc6540 1.1.580

前缀已保留
dotnet add package nanoFramework.Iot.Device.Chsc6540 --version 1.1.580                
NuGet\Install-Package nanoFramework.Iot.Device.Chsc6540 -Version 1.1.580                
此命令旨在在Visual Studio的包管理器控制台中使用,因为它使用NuGet模块的Install-Package版本。
<PackageReference Include="nanoFramework.Iot.Device.Chsc6540" Version="1.1.580" />                
对于支持PackageReference的 projects,将此 XML 节点复制到项目文件中,以引用此包。
paket add nanoFramework.Iot.Device.Chsc6540 --version 1.1.580                
#r "nuget: nanoFramework.Iot.Device.Chsc6540, 1.1.580"                
#r 指令可用于 F# Interactive 和 Polyglot Notebooks。将此复制到交互式工具或脚本的源代码中,以引用包。
// Install nanoFramework.Iot.Device.Chsc6540 as a Cake Addin
#addin nuget:?package=nanoFramework.Iot.Device.Chsc6540&version=1.1.580

// Install nanoFramework.Iot.Device.Chsc6540 as a Cake Tool
#tool nuget:?package=nanoFramework.Iot.Device.Chsc6540&version=1.1.580                

CHSC6540 - 触摸屏控制器

CHSC6540 是 M5Stack Tough 的触摸屏控制器。

文档

用法

重要:在创建I2cDevice之前,请确保正确设置 I2C 引脚,特别是针对 ESP32,确保已安装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);

对于 STM32等其他设备,请确保您使用的是您将要使用的 I2C 总线的预置引脚。

注意:此示例需要 M5Stack Tough。如果您想使用其他设备,只需删除所有相关的 NuGet 包。

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}");
    }
}
产品 兼容和额外的目标框架版本
.NET Framework net is compatible.
兼容目标框架(s)
包含目标框架(s)(在包中)
了解有关目标框架.NET Standard的更多信息。

NuGet 包 (1)

显示依赖于 nanoFramework.Iot.Device.Chsc6540 的 top 1 个 NuGet 包

下载
nanoFramework.Tough

该包包括 .NET nanoFramework C# 项目使用的 nanoFramework.Tough 程序集。

GitHub 仓库

该包没有被任何流行的 GitHub 仓库使用。

版本 下载 最后更新
1.1.580 236 6/28/2024
1.1.570 124 6/14/2024
1.1.548 177 5/15/2024
1.1.436 561 11/10/2023
1.1.329 564 5/26/2023
1.1.313 202 5/12/2023
1.1.308 209 5/11/2023
1.1.304 176 5/10/2023
1.1.297 205 5/3/2023
1.1.203 2,164 12/28/2022
1.1.141 1,910 10/25/2022
1.1.82 2,865 9/14/2022
1.0.1.61117 8,707 6/3/2022