Table of Contents

Class TouchPad

Namespace
nanoFramework.Hardware.Esp32.Touch
Assembly
nanoFramework.Hardware.Esp32.dll

The touch pad. Some of the configurations are specific for each touch pad. Some are applied to all the touch pad like filtering, voltage and the capture mode.

public class TouchPad : IDisposable
Inheritance
TouchPad
Implements
Inherited Members
Extension Methods

Constructors

TouchPad(int)

Creates a TouchPad.

public TouchPad(int touchPadNumber)

Parameters

touchPadNumber int

A valid touch pad number.

Remarks

Use the GetGpioNumberFromTouchNumber(int) to get the associated GPIO of a touch pad.

Properties

CalibrationData

Gets the calibration data which can be used as a reference point.

public int CalibrationData { get; }

Property Value

int

DenoiseEnabled

Gets or sets the denoise enabled. This is available only for ESP32-S2 and ESP32-S3.

public static bool DenoiseEnabled { get; set; }

Property Value

bool

IsFilterOn

Gets if the filtering is running.

public static bool IsFilterOn { get; }

Property Value

bool

MeasurementMode

The measurement mode mode is the same for ALL the touch pads. Chaning this value will change the behavior for all of them. The default measurement mode is software, meaning you have to manually request a value to get it and also to potentially have the events. The timer value will automatically read in the background all the values and generates the touched events.

public static MeasurementMode MeasurementMode { get; set; }

Property Value

MeasurementMode

Threshold

Gets or sets the threshold used to detect a touch. Using a value of 2/3 of the calibration data is a good estimation to start with for ESP32. Using a value of x 1.3 of the calibration data is a good estimation to start with for S2/S3. This will depends of the surface you have as touch point. To understand the best value, you should read values to find the lower point.

public uint Threshold { get; set; }

Property Value

uint

TouchHighVoltage

Gets the high voltage.

public static TouchHighVoltage TouchHighVoltage { get; }

Property Value

TouchHighVoltage

TouchHighVoltageAttenuation

Gets the high voltage attenuation.

public static TouchHighVoltageAttenuation TouchHighVoltageAttenuation { get; }

Property Value

TouchHighVoltageAttenuation

TouchLowVoltage

Gets the low voltage.

public static TouchLowVoltage TouchLowVoltage { get; }

Property Value

TouchLowVoltage

TouchPadNumber

The touch pad number.

public int TouchPadNumber { get; }

Property Value

int

TouchTriggerMode

The trigger mode is the same for ALL the touch pads. Chaning this value will change the behavior for all of them. The default vaue is bellow the threshold. This is the normal pattern. Values when not touched are high and low when touched.

public static TouchTriggerMode TouchTriggerMode { get; set; }

Property Value

TouchTriggerMode

WakeUpSource

The wakeup source mode is the same for ALL the touch pads. Chaning this value will change the behavior for all of them. By default, you need 2 different sources to be touched to wake the board. You can adjut for only one.

public static WakeUpSource WakeUpSource { get; set; }

Property Value

WakeUpSource

Methods

Dispose()

Disposes all the resources.

public void Dispose()

GetCalibrationData(int)

Gets the calibration data which can be used as a reference point.

public int GetCalibrationData(int count = 5)

Parameters

count int

The number of read you want to do. If you have a signal that varies a lot, you may want to run more than the default one.

Returns

int

GetChargeSpeed()

Gets the touch charge configuration.

public TouchChargeSpeed GetChargeSpeed()

Returns

TouchChargeSpeed

The TouchChargeSpeed configuration.

GetDenoise()

Gets denoise. This is available only for ESP32-S2 and ESP32-S3.

public static DenoiseSetting GetDenoise()

Returns

DenoiseSetting

The DenoiseSetting.

GetGpioNumberFromTouchNumber(int)

Gets the gpio number associated to a specific Touch Pad. Those are different depeending on the ESP32. Touch is available on ESP32 and ESP32-S2. Pins are different depending on the board used.

public static int GetGpioNumberFromTouchNumber(int touchpadNumber)

Parameters

touchpadNumber int

The number of touch pad to get the GPIO. For 0 to 9 for ESP32, from 0 to 14 for ESP32-S2.

Returns

int

The Gpio number.

GetMeasurementTime()

Gets the measurement time settings. This is the same for ALL the touch pads. Chaning this value will change the behavior for all of them.

public static MeasurementTime GetMeasurementTime()

Returns

MeasurementTime

The MeasurementTime settings.

Read()

Reads a value. This is accessible regardless of the mode used.

public uint Read()

Returns

uint

A touch value.

SetChargeSpeed(TouchChargeSpeed)

Sets the charge speed and initial charge. High charge/discharge speed increases the system's anti-interference ability. Therefore, TouchChargeSpeed.Fastest is recommended.

public void SetChargeSpeed(TouchChargeSpeed touchChargeSpeed)

Parameters

touchChargeSpeed TouchChargeSpeed

The TouchChargeSpeed configuration.

SetDenoise(DenoiseSetting)

Sets denoise. This is available only for ESP32-S2 and ESP32-S3.

public static void SetDenoise(DenoiseSetting denoiseSetting)

Parameters

denoiseSetting DenoiseSetting

The DenoiseSetting.

SetMeasurementTime(MeasurementTime)

Sets the measurement time settings. This is the same for ALL the touch pads. Chaning this value will change the behavior for all of them.

public static void SetMeasurementTime(MeasurementTime measurementTime)

Parameters

measurementTime MeasurementTime

The MeasurementTime settings.

Exceptions

ArgumentException

The measurement cycle should be less than 8.19 milliseconds

SetVoltage(TouchHighVoltage, TouchLowVoltage, TouchHighVoltageAttenuation)

Sets the different voltage for operation. This is the same for ALL the touch pads. Chaning this value will change the behavior for all of them. The voltage parameters affect the system's stability and sensitivity. The greater the voltage threshold range, the stronger the anti-interference ability of the system, and the smaller the pulse count value. The voltage parameters (refh = 2.7V, refl = 0.5V, atten = 1V) suit most designs.

public static void SetVoltage(TouchHighVoltage touchHighVoltage, TouchLowVoltage touchLowVoltage, TouchHighVoltageAttenuation touchHighVoltageAttenuation)

Parameters

touchHighVoltage TouchHighVoltage

The high voltage.

touchLowVoltage TouchLowVoltage

The low voltage.

touchHighVoltageAttenuation TouchHighVoltageAttenuation

The attenuation.

StartFilter(IFilterSetting)

Starts a filtering on a specific period. This is the same for ALL the touch pads. Chaning this value will change the behavior for all of them. Warning: this consume CPU and should be used carefully.

public static void StartFilter(IFilterSetting filterSetting)

Parameters

filterSetting IFilterSetting

The IFilterSetting depending on your ESP32 series. ESP32 Esp32FilterSetting and ESP32-S2/S3 S2S3FilterSetting have different settings.

StopFilter()

Stops the filtering. This is the same for ALL the touch pads. Chaning this value will change the behavior for all of them.

public static void StopFilter()

Events

ValueChanged

Occurs when the value of the touch pad changes. this happens when the touch pad is touched or released.

public event TouchPadValueChangedEventHandler ValueChanged

Event Type

TouchPadValueChangedEventHandler