EasyManuals Logo

Freenove ESP32 User Manual

Default Icon
159 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 #117 background imageLoading...
Page #117 background image
Need support? support@freenove.com
115
Chapter 11 Touch
www.freenove.com
TouchPad.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "TouchPad.h"
static uint32_t s_pad_init_val;
static void tp_example_set_thresholds(void) {
uint16_t touch_value;
// read filtered value
touch_pad_read_filtered(PIN_TOUCH_PAD, &touch_value);
s_pad_init_val = touch_value;
// set interrupt threshold.
touch_pad_set_thresh(PIN_TOUCH_PAD, touch_value * 4 / 5);
}
bool touchPadVal = false;
void isr_touchpad(void *arg) {
// uint16_t touchVal = 0;
uint32_t touchStatus = 0;
touchStatus = touch_pad_get_status(); // TOUCHPAD3 : 0000 1000 = 0x08
if (touchStatus == 0x08) // TOUCHPAD3
{
touchPadVal = true;
}
touch_pad_clear_status();
}
void setupTouchPad(void) {
// Initialize touch pad peripheral, it will start a timer to run a filter
ESP_ERROR_CHECK(touch_pad_init());
// If use interrupt trigger mode, should set touch sensor FSM mode at 'TOUCH_FSM_MODE_TIMER'.
touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER);
// Set reference voltage for charging/discharging
// For most usage scenarios, we recommend using the following combination:
// the high reference valtage will be 2.7V - 1V = 1.7V, The low reference voltage will be 0.5V.
touch_pad_set_voltage(TOUCH_HVOLT_2V7, TOUCH_LVOLT_0V5, TOUCH_HVOLT_ATTEN_1V);
// Init touch pad IO
touch_pad_config(PIN_TOUCH_PAD, TOUCH_THRESH_NO_USE);
// Initialize and start a software filter to detect slight change of capacitance.
touch_pad_filter_start(TOUCHPAD_FILTER_TOUCH_PERIOD);
// Set thresh hold
tp_example_set_thresholds();
// set isr trigger mode
touch_pad_set_trigger_mode(TOUCH_TRIGGER_BELOW);
// Register touch interrupt ISR
touch_pad_isr_register(isr_touchpad, NULL);
// enable isr

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Freenove ESP32 and is the answer not in the manual?

Freenove ESP32 Specifications

General IconGeneral
BrandFreenove
ModelESP32
CategoryComputer Hardware
LanguageEnglish

Related product manuals