nanoframework/Home

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

Open

#1,628 opened on Apr 18, 2025

 (0 comments) (0 reactions) (0 assignees) (89 forks)auto 404
Area: CL-nanoFramework.Hardware.Esp32Status: Waiting triageType: Buggood first issueup-for-grabs

Repository metrics

Stars
 (936 stars)
PR merge metrics
 (PR metrics pending)

Description

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

Contributor guide