File tree Expand file tree Collapse file tree
ports/espressif/peripherals Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -119,19 +119,29 @@ uint16_t peripherals_touch_read(int channel_id) {
119119 }
120120
121121 uint32_t touch_value = 0 ;
122- touch_channel_read_data (touch_channels [idx ], TOUCH_CHAN_DATA_TYPE_RAW , & touch_value );
123122
124123 #if SOC_TOUCH_SENSOR_VERSION == 1
125124 // ESP32 touch reads a lower value when touched.
126125 // Flip the values to be consistent with TouchIn assumptions.
126+ touch_channel_read_data (touch_channels [idx ], TOUCH_CHAN_DATA_TYPE_RAW , & touch_value );
127127 if (touch_value > UINT16_MAX ) {
128128 return 0 ;
129129 }
130130 return UINT16_MAX - (uint16_t )touch_value ;
131- #else
131+ touch_channel_read_data (touch_channels [idx ], TOUCH_CHAN_DATA_TYPE_RAW , & touch_value );
132+ return UINT16_MAX - (uint16_t )touch_value ;
133+ #elif SOC_TOUCH_SENSOR_VERSION == 2
132134 if (touch_value > UINT16_MAX ) {
133135 return UINT16_MAX ;
134136 }
135137 return (uint16_t )touch_value ;
138+ #elif SOC_TOUCH_SENSOR_VERSION == 3
139+ touch_channel_read_data (touch_channels [idx ], TOUCH_CHAN_DATA_TYPE_SMOOTH , & touch_value );
140+ if (touch_value > UINT16_MAX ) {
141+ return UINT16_MAX ;
142+ }
143+ return (uint16_t )touch_value ;
144+ #else
145+ #error bad SOC_TOUCH_SENSOR_VERSION
136146 #endif
137147}
You can’t perform that action at this time.
0 commit comments