Open
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
- 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);
}
}
- 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