nanoframework/Home

nanoFramework.Hardware.Esp32 --version 1.6.34 has bug in Touchpad.ValueChanged

開放

#1,628 建立於 2025年4月18日

 (0 則留言) (0 個反應) (0 位負責人) (89 個分叉)auto 404
Area: CL-nanoFramework.Hardware.Esp32Status: Waiting triageType: Buggood first issueup-for-grabs

倉庫指標

星標
 (936 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

Library/API/IoT binding

nanoFramework.Hardware.Esp32

Visual Studio version

VS2022 (17.13.6)

.NET nanoFramework extension version

2022.12.1.45

Target name(s)

ESP32_REV3

Firmware version

No response

Device capabilities

No response

Description

nanoFramework.Hardware.Esp32.Touch.Touchpad.ValueChanged has incorrect argument value. A part of code to show the bug:

// Touchpad.ValueChanged has bug: e.Touched is FALSE when i press finger and TRUE when i release finger
touchpad.ValueChanged += (s, e) => Console.WriteLine(e.Touched.ToString());

How to reproduce

  1. Solder the touchpad to Touch 0 (GPIO 4) to ESP32_REV3 (ESP32 WROOM 32) and run the code:
using nanoFramework.Hardware.Esp32.Touch;
using System;
using System.Threading;


public class Program
{
	public static void Main()
	{
		TouchPad.SetVoltage(TouchHighVoltage.Volt2V7, TouchLowVoltage.Volt0V5, TouchHighVoltageAttenuation.Volt1V0);
		TouchPad.MeasurementMode = MeasurementMode.Timer;

		var touchpad = new TouchPad(0);

		// Touchpad.ValueChanged has bug: e.Touched is FALSE when i press finger and TRUE when i release finger
		touchpad.ValueChanged += (s, e) => Console.WriteLine(e.Touched.ToString());
		touchpad.GetCalibrationData();
		touchpad.Threshold = (uint)(2 / 3f * touchpad.CalibrationData); // ESP32_REV3
		Thread.Sleep(Timeout.Infinite);
	}
}
  1. Debug code and see the output when pressing finger and releasing finger

Expected behaviour

Expected: TRUE when press finger and FALSE when release finger Real world happen: The opposite way: FALSE when press finger and TRUE when release finger

Screenshots

No response

Sample project or code

using nanoFramework.Hardware.Esp32.Touch;
using System;
using System.Threading;


public class Program
{
	public static void Main()
	{
		TouchPad.SetVoltage(TouchHighVoltage.Volt2V7, TouchLowVoltage.Volt0V5, TouchHighVoltageAttenuation.Volt1V0);
		TouchPad.MeasurementMode = MeasurementMode.Timer;

		var touchpad = new TouchPad(0);

		// Touchpad.ValueChanged has bug: e.Touched is FALSE when i press finger and TRUE when i release finger
		touchpad.ValueChanged += (s, e) => Console.WriteLine(e.Touched.ToString());
		touchpad.GetCalibrationData();
		touchpad.Threshold = (uint)(2 / 3f * touchpad.CalibrationData); // ESP32_REV3
		Thread.Sleep(Timeout.Infinite);
	}
}

Aditional information

No response

貢獻者指南