31
31
32
32
#if SOC_TOUCH_SENSOR_SUPPORTED
33
33
34
- #if SOC_TOUCH_VERSION_1 // ESP32 only
34
+ #if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL (5 , 3 , 0 )
35
+ #if SOC_TOUCH_VERSION_1
36
+ #define SOC_TOUCH_SENSOR_VERSION (1)
37
+ #elif SOC_TOUCH_VERSION_2
38
+ #define SOC_TOUCH_SENSOR_VERSION (2)
39
+ #endif
40
+ #endif
41
+
42
+ #if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32 only
35
43
#include "driver/touch_pad.h"
36
- #elif SOC_TOUCH_VERSION_2 // All other SoCs with touch, to date
44
+ #elif SOC_TOUCH_SENSOR_VERSION == 2 // All other SoCs with touch, to date
37
45
#include "driver/touch_sensor.h"
38
46
#else
39
47
#error "Unknown touch hardware version"
@@ -98,13 +106,13 @@ static mp_obj_t mtp_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_
98
106
touch_pad_set_fsm_mode (TOUCH_FSM_MODE_TIMER );
99
107
initialized = 1 ;
100
108
}
101
- #if SOC_TOUCH_VERSION_1
109
+ #if SOC_TOUCH_SENSOR_VERSION == 1
102
110
esp_err_t err = touch_pad_config (self -> touchpad_id , 0 );
103
- #elif SOC_TOUCH_VERSION_2
111
+ #elif SOC_TOUCH_SENSOR_VERSION == 2
104
112
esp_err_t err = touch_pad_config (self -> touchpad_id );
105
113
#endif
106
114
if (err == ESP_OK ) {
107
- #if SOC_TOUCH_VERSION_2
115
+ #if SOC_TOUCH_SENSOR_VERSION == 2
108
116
touch_pad_fsm_start ();
109
117
#endif
110
118
@@ -115,10 +123,10 @@ static mp_obj_t mtp_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_
115
123
116
124
static mp_obj_t mtp_config (mp_obj_t self_in , mp_obj_t value_in ) {
117
125
mtp_obj_t * self = self_in ;
118
- #if SOC_TOUCH_VERSION_1
126
+ #if SOC_TOUCH_SENSOR_VERSION == 1
119
127
uint16_t value = mp_obj_get_int (value_in );
120
128
esp_err_t err = touch_pad_config (self -> touchpad_id , value );
121
- #elif SOC_TOUCH_VERSION_2
129
+ #elif SOC_TOUCH_SENSOR_VERSION == 2
122
130
esp_err_t err = touch_pad_config (self -> touchpad_id );
123
131
#endif
124
132
if (err == ESP_OK ) {
@@ -130,10 +138,10 @@ MP_DEFINE_CONST_FUN_OBJ_2(mtp_config_obj, mtp_config);
130
138
131
139
static mp_obj_t mtp_read (mp_obj_t self_in ) {
132
140
mtp_obj_t * self = self_in ;
133
- #if SOC_TOUCH_VERSION_1
141
+ #if SOC_TOUCH_SENSOR_VERSION == 1
134
142
uint16_t value ;
135
143
esp_err_t err = touch_pad_read (self -> touchpad_id , & value );
136
- #elif SOC_TOUCH_VERSION_2
144
+ #elif SOC_TOUCH_SENSOR_VERSION == 2
137
145
uint32_t value ;
138
146
esp_err_t err = touch_pad_read_raw_data (self -> touchpad_id , & value );
139
147
#endif
0 commit comments