Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.2k
Closed
Labels
Description
frommachineimportTouchPad,Pinimporttimet=TouchPad(Pin(5))foriinrange(100):time.sleep(0.5)print("%X"%t.read())
The same code changes the number with touch on ESP32, but the reading does not change on ESP32s3
Adjusting the initialization code as follows works fine, but I am not familiar enough with ESP32 and have not fully tested it, for reference only. Additionally, I suspect that the same issue also exists in ESP32s2
The changes are minimal, move the touch_Pad_Fsm_Start to touch_Pad_config After
STATICmp_obj_tmtp_make_new(constmp_obj_type_t*type,size_tn_args,size_tn_kw,constmp_obj_t*args) {mp_arg_check_num(n_args,n_kw,1,1, true);gpio_num_tpin_id=machine_pin_get_id(args[0]);constmtp_obj_t*self=NULL;for (inti=0;i<MP_ARRAY_SIZE(touchpad_obj);i++) {if (pin_id==touchpad_obj[i].gpio_id) {self=&touchpad_obj[i];break; } }if (!self) {mp_raise_ValueError(MP_ERROR_TEXT("invalid pin for touchpad")); }staticintinitialized=0;if (!initialized) {touch_pad_init();touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER);initialized=1; }#ifCONFIG_IDF_TARGET_ESP32esp_err_terr=touch_pad_config(self->touchpad_id,0);#elifCONFIG_IDF_TARGET_ESP32S2||CONFIG_IDF_TARGET_ESP32S3esp_err_terr=touch_pad_config(self->touchpad_id);touch_pad_fsm_start();#endifif (err==ESP_OK) {returnMP_OBJ_FROM_PTR(self); }mp_raise_ValueError(MP_ERROR_TEXT("Touch pad error"));}