EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #437 background imageLoading...
Page #437 background image
Chapter 2. API Reference
static touch_xxx_handle_t element_handle; //Declare a touch element handle
//Define the subscribed event handler
void event_handler(touch_xxx_handle_t out_handle, touch_xxx_message_t out_message,
,void *arg)
{
//Event handler logic
}
void app_main()
{
//Using the default initializer to config Touch Element library
touch_elem_global_config_t global_config = TOUCH_ELEM_GLOBAL_DEFAULT_CONFIG();
touch_element_install(&global_config);
//Using the default initializer to config Touch elements
touch_xxx_global_config_t elem_global_config = TOUCH_XXXX_GLOBAL_DEFAULT_
,CONFIG();
touch_xxx_install(&elem_global_config);
//Create a new instance
touch_xxx_config_t element_config = {
...
...
};
touch_xxx_create(&element_config, &element_handle);
//Subscribe the specified events by using the event mask
touch_xxx_subscribe_event(element_handle, TOUCH_ELEM_EVENT_ON_PRESS | TOUCH_
,ELEM_EVENT_ON_RELEASE, NULL);
//Choose CALLBACK as the dispatch method
touch_xxx_set_dispatch_method(element_handle, TOUCH_ELEM_DISP_CALLBACK);
//Register the callback routine
touch_xxx_set_callback(element_handle, event_handler);
//Start Touch Element library processing
touch_element_start();
}
Initialization
1. To initialize Touch Element library, user has to configure touch sensor peripheral and Touch Element library by
calling touch_element_install() with touch_elem_global_config_t, the default initializer
is available in TOUCH_ELEM_GLOBAL_DEFAULT_CONFIG() and this default configuration is suitable for
the most general application scene, and users are suggested not to change the default configuration before fully
understanding Touch Sensor peripheral, because some changes might bring several impacts to the system.
2. To initialize the specified element, all the elements will not work before its constructor
(touch_xxxx_install()) is called so as to save memory, so user has to call the constructor of
each used touch element respectively, to set up the specified element.
Touch Element Instance Startup
1. To create a new touch element instance by calling touch_xxxx_create(), selects channel and passes its
Sensitivity for the new element instance.
2. To subscribe events by calling touch_xxxx_subscribe_event(), there sev-
eral events in Touch Element library and the event mask is available on compo-
nents/touch_element/include/touch_element/touch_element.h, user could use those events mask to subscribe
specified event or combine them to subscribe multiple events.
Espressif Systems 426
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish