mirror of
https://github.com/micropython/micropython.git
synced 2025-07-21 13:01:10 +02:00
esp32: Fix machine_touchpad compiling on IDFv5.3.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
committed by
Damien George
parent
5564f3042c
commit
5fb846df67
@@ -31,9 +31,17 @@
|
||||
|
||||
#if SOC_TOUCH_SENSOR_SUPPORTED
|
||||
|
||||
#if SOC_TOUCH_VERSION_1 // ESP32 only
|
||||
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 0)
|
||||
#if SOC_TOUCH_VERSION_1
|
||||
#define SOC_TOUCH_SENSOR_VERSION (1)
|
||||
#elif SOC_TOUCH_VERSION_2
|
||||
#define SOC_TOUCH_SENSOR_VERSION (2)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32 only
|
||||
#include "driver/touch_pad.h"
|
||||
#elif SOC_TOUCH_VERSION_2 // All other SoCs with touch, to date
|
||||
#elif SOC_TOUCH_SENSOR_VERSION == 2 // All other SoCs with touch, to date
|
||||
#include "driver/touch_sensor.h"
|
||||
#else
|
||||
#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_
|
||||
touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER);
|
||||
initialized = 1;
|
||||
}
|
||||
#if SOC_TOUCH_VERSION_1
|
||||
#if SOC_TOUCH_SENSOR_VERSION == 1
|
||||
esp_err_t err = touch_pad_config(self->touchpad_id, 0);
|
||||
#elif SOC_TOUCH_VERSION_2
|
||||
#elif SOC_TOUCH_SENSOR_VERSION == 2
|
||||
esp_err_t err = touch_pad_config(self->touchpad_id);
|
||||
#endif
|
||||
if (err == ESP_OK) {
|
||||
#if SOC_TOUCH_VERSION_2
|
||||
#if SOC_TOUCH_SENSOR_VERSION == 2
|
||||
touch_pad_fsm_start();
|
||||
#endif
|
||||
|
||||
@@ -115,10 +123,10 @@ static mp_obj_t mtp_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_
|
||||
|
||||
static mp_obj_t mtp_config(mp_obj_t self_in, mp_obj_t value_in) {
|
||||
mtp_obj_t *self = self_in;
|
||||
#if SOC_TOUCH_VERSION_1
|
||||
#if SOC_TOUCH_SENSOR_VERSION == 1
|
||||
uint16_t value = mp_obj_get_int(value_in);
|
||||
esp_err_t err = touch_pad_config(self->touchpad_id, value);
|
||||
#elif SOC_TOUCH_VERSION_2
|
||||
#elif SOC_TOUCH_SENSOR_VERSION == 2
|
||||
esp_err_t err = touch_pad_config(self->touchpad_id);
|
||||
#endif
|
||||
if (err == ESP_OK) {
|
||||
@@ -130,10 +138,10 @@ MP_DEFINE_CONST_FUN_OBJ_2(mtp_config_obj, mtp_config);
|
||||
|
||||
static mp_obj_t mtp_read(mp_obj_t self_in) {
|
||||
mtp_obj_t *self = self_in;
|
||||
#if SOC_TOUCH_VERSION_1
|
||||
#if SOC_TOUCH_SENSOR_VERSION == 1
|
||||
uint16_t value;
|
||||
esp_err_t err = touch_pad_read(self->touchpad_id, &value);
|
||||
#elif SOC_TOUCH_VERSION_2
|
||||
#elif SOC_TOUCH_SENSOR_VERSION == 2
|
||||
uint32_t value;
|
||||
esp_err_t err = touch_pad_read_raw_data(self->touchpad_id, &value);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user