igorantolic / ai-esp32-rotary-encoder

Easy implement rotary encoder to your application using microcontroler like ESP32
GNU General Public License v2.0
284 stars 70 forks source link

Question about the basic example #48

Closed Chen-YanZhang closed 1 year ago

Chen-YanZhang commented 1 year ago

Hi, i am using ESP32 Dev board with your library. Your examples are really good. But i found a small problem.

In ''Esp32RotaryEncoderBasics.ino'' .If i delete //delay(50); //or do whatever you need to do... in the void loop, and flash this programm to my board. My board will stuck in reboot. The following codes are what i got from the serial monitor.

01:08:18.613 -> ELF file SHA256: 0000000000000000 01:08:18.613 -> 01:08:18.613 -> Rebooting... 01:08:18.613 -> ets Jun 8 2016 00:22:57 01:08:18.613 -> 01:08:18.613 -> rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) 01:08:18.613 -> configsip: 0, SPIWP:0xee 01:08:18.613 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 01:08:18.613 -> mode:DIO, clock div:1 01:08:18.661 -> load:0x3fff0030,len:1344 01:08:18.661 -> load:0x40078000,len:13864 01:08:18.661 -> load:0x40080400,len:3608 01:08:18.661 -> entry 0x400805f0 01:08:18.753 -> E (132) gpio: gpio_set_level(226): GPIO output gpio_num error

This is a really weird problem. All examples will run flawlessly only with this delay(50). I have also tried other examples... I don't understand why....

igorantolic commented 1 year ago

Is is more about esp32 internals and how it detects unusual behaviour, forcing using notifications that everything is fine when doing too long or like here too short operations. in this example it is not normal that there are no other operations except rotary_loop(); probably causing this protection to activate and doing auto reboot.

In normal apps there will never be normal that loop is that short, so try using yield or delay to do that.

Of course if you would like to know what is actualy going on - you should investigate more time to explore ESP32 protection watchdog mechanisms. Otherwise keep some delay and enjoy :) If I do delay inside rotary_loop that might help but it is against rules to waste time without actual need.

void loop() { //in loop call your custom function which will process rotary encoder values rotary_loop(); delay(50); //or do whatever you need to do... }