Comments (13)
Please note that I have replaced
typedef void (*func_ptr_t)(void); // Typedef to faciliate managing pointers to external action functions
with
typedef std::function<void()> func_ptr_t;
from interruptbutton.
Please note that I have replaced
typedef void (*func_ptr_t)(void); // Typedef to faciliate managing pointers to external action functionswith
typedef std::function<void()> func_ptr_t;
So funny ! That's the change we've talked about ;-)
from interruptbutton.
HI Mathieu,
Good question. If you choose to use Mode_Synchronous, then all actions are carried out in main loop hook, ie:
void main () [
button1.processSyncEvents();
}
And shouldn't require much additional memory.
But, using Mode_Synchronous, you have to wait for the code execution to reach this hook in the main loop for the action to happen. Which can take some time for some main loops, and be unpredictable timing and lead to a clunky user experience.
If you choose Mode_Asynchronous or Mode_Hybrid then the action (procedure) bound to your particular event (Event_KeyPress, Event_DoubleClick, etc) is run in an RTOS task which sorta happens outside of the main loop in parallel like a new thread. So it happens nearly instantaneously but not inside the interrupt itself. This is a good thing because you can do MUCH more inside this task than you can inside an interrupt. But the cost of this is that you have to reserve some memory when creating this space for this parallel task to run, this is probably what you are seeing as increased heap usage but I think it's actually reserved stack.. Note that Mode_Hybrid processes most events syncronously in the main loop hook, but Event_KeyUp and Event_KeyDown are processed immediately Asynchronously.
Now, you can reduce the default amount of reserved stack by changing the default value of the stack reservation (currently 2048 bytes)
ie:
InterruptButton::m_RTOSservicerStackDepth = 1024;
But do this before you call 'setMode' for it to work properly, because it uses that value to reserve the required amount of memory. And I think you can only set it once, ie once it's reserved, its reserved, but i suppose that needs to be confirmed.
And that change above will halve the stack usage, or more if you like to take risks. 😁 But if any of the routines you intend on running require more than this, well, it may lead to instabilities. So in this case I went a little bigger. Ie "when in doubt, build it stout"
Hope this helps 👍
from interruptbutton.
But looking back at your graph, it's only 5 parts out of 130, so you get a lot for only about 3-4% of your memory.
from interruptbutton.
also with your comment regarding:
typedef void (*func_ptr_t)(void); // Typedef to faciliate managing pointers to external action functions
with
typedef std::function<void()> func_ptr_t;
Im a bit rusty on some of the more modern stuff. Is it worth updating the library and why?
Cheers.
from interruptbutton.
also with your comment regarding:
typedef void (*func_ptr_t)(void); // Typedef to faciliate managing pointers to external action functions
with
typedef std::function<void()> func_ptr_t;Im a bit rusty on some of the more modern stuff. Is it worth updating the library and why?
Cheers.
Thanks a lot for your awesome reply! Yes it should be stack size for a task: I will try decrease it. The way I have wired the library, I want async mode in order to not slow down the press detection process, but as soon as I've captured an event, I am setting an action to execute, which will be executed as part of the main loop (so a few ms later), which is ok in my case. What I really want is to not slowdown the capture. Execution can be delayed.
So in this context, I don't need a big stack size. So I will try to decrease it.
For the callback, yes this change is required in order to use non static callbacks, as part of a C++ class. Here, I am scoping the references to [this]
which allows the callback to access the class variables.
Note that I had to wrap your InterruptButton in a class because I am allowing the user to change pins. So I can only create the button once I read the pin from my configuration.
If we look at how your constructor is made, I am not sure you need a constructor at all:
InterruptButton(uint8_t pin, // Class Constructor, pin to monitor
uint8_t pressedState, // State of the pin when pressed (HIGH or LOW)
gpio_mode_t pinMode = GPIO_MODE_INPUT,
uint16_t longKeyPressMS = 750,
uint16_t autoRepeatMS = 250,
uint16_t doubleClickMS = 333,
uint32_t debounceUS = 8000);
could become
void setPinMode(...);
void setLongKeyPressMS(...);
[...]
void init(uint8_t pin, uint8_t pressedState);
This would allow to decouple class instantiation, configuration and initialisation, especially that most of the settings have default values.
from interruptbutton.
Ok so reducing the stack size did not help and crashed when I pressed the button:
Guru Meditation Error: Core 1 panic'ed (Double exception).
Core 1 register dump:
PC : 0x4008e2a6 PS : 0x00040936 A0 : 0x801cf5b8 A1 : 0x3ffd2a60
A2 : 0x4012463c A3 : 0x00000180 A4 : 0x3ffd2cac A5 : 0x00000000
A6 : 0x3ffd2dfc A7 : 0x000000ff A8 : 0x40080080 A9 : 0x3ffd2b80
A10 : 0x00060b36 A11 : 0x00040026 A12 : 0x3ffd2cac A13 : 0x00000020
A14 : 0x00ff0000 A15 : 0xff000000 SAR : 0x00000014 EXCCAUSE: 0x00000002
EXCVADDR: 0xffffffe0 LBEG : 0x4008b981 LEND : 0x4008b992 LCOUNT : 0xfffffffd
Backtrace: 0x4008e2a3:0x3ffd2a60 0x401cf5b5:0x3ffd2a80 0x4008e2a3:0x3ffd2ab0 0x4008e2a3:0x3ffd2ad0 0x4008e2a3:0x3ffd2af0 0x4008e2a3:0x3ffd2b10 0x4008e2a3:0x3ffd2b50 0x4008e2a3:0x3ffd2b80 0x4008007d:0x3ffd2a60 0x40082ab7:0x3ffd2a80 0x4008e2a3:0x3ffd2ab0 0x4008e2a3:0x3ffd2ad0 0x4008e2a3:0x3ffd2af0 0x4008e2a3:0x3ffd2b10 0x4008e2a3:0x3ffd2b50 0x4008e2a3:0x3ffd2b80 0x4008007d:0x3ffd2a60 0x40082ab7:0x3ffd2a80 0x4008e2a3:0x3ffd2ab0 0x4008e2a3:0x3ffd2ad0 0x4008e2a3:0x3ffd2af0 0x4008e2a3:0x3ffd2b10 0x4008e2a3:0x3ffd2b50 0x4008e2a3:0x3ffd2b80 0x4008007d:0x3ffd2a60 0x40082ab7:0x3ffd2a80 0x4008e2a3:0x3ffd2ab0 0x4008e2a3:0x3ffd2ad0 0x4008e2a3:0x3ffd2af0 0x4008e2a3:0x3ffd2b10 0x4008e2a3:0x3ffd2b50 0x4008e2a3:0x3ffd2b80 0x4008007d:0x3ffd2a60 0x40082ab7:0x3ffd2a80 0x4008e2a3:0x3ffd2ab0 0x4008e2a3:0x3ffd2ad0 0x4008e2a3:0x3ffd2af0 0x4008e2a3:0x3ffd2b10 0x4008e2a3:0x3ffd2b50 0x4008e2a3:0x3ffd2b80 0x4008007d:0x3ffd2a60 0x40082ab7:0x3ffd2a80 0x4008e2a3:0x3ffd2ab0 0x4008e2a3:0x3ffd2ad0 0x4008e2a3:0x3ffd2af0 0x4008e2a3:0x3ffd2b10 0x4008e2a3:0x3ffd2b50 0x4008e2a3:0x3ffd2b80 0x4008007d:0x3ffd2a60 0x40082ab7:0x3ffd2a80 0x4008e2a3:0x3ffd2ab0 0x4008e2a3:0x3ffd2ad0 0x4008e2a3:0x3ffd2af0 0x4008e2a3:0x3ffd2b10 0x4008e2a3:0x3ffd2b50 0x4008e2a3:0x3ffd2b80 0x4008007d:0x3ffd2a60 0x40082ab7:0x3ffd2a80 0x4008e2a3:0x3ffd2ab0 0x4008e2a3:0x3ffd2ad0 0x4008e2a3:0x3ffd2af0 0x4008e2a3:0x3ffd2b10 0x4008e2a3:0x3ffd2b50 0x4008e2a3:0x3ffd2b80 0x4008007d:0x3ffd2a60 0x40082ab7:0x3ffd2a80 0x4008e2a3:0x3ffd2ab0 0x4008e2a3:0x3ffd2ad0 0x4008e2a3:0x3ffd2af0 0x4008e2a3:0x3ffd2b10 0x4008e2a3:0x3ffd2b50 0x4008e2a3:0x3ffd2b80 0x4008007d:0x3ffd2a60 0x40082ab7:0x3ffd2a80 0x4008e2a3:0x3ffd2ab0 0x4008e2a3:0x3ffd2ad0 0x4008e2a3:0x3ffd2af0 0x4008e2a3:0x3ffd2b10 0x4008e2a3:0x3ffd2b50 0x4008e2a3:0x3ffd2b80 0x4008007d:0x3ffd2a60 0x40082ab7:0x3ffd2a80 0x4008e2a3:0x3ffd2ab0 0x4008e2a3:0x3ffd2ad0 0x4008e2a3:0x3ffd2af0 0x4008e2a3:0x3ffd2b10 0x4008e2a3:0x3ffd2b50 0x4008e2a3:0x3ffd2b80 0x4008007d:0x3ffd2a60 0x40082ab7:0x3ffd2a80 0x4008e2a3:0x3ffd2ab0 0x4008e2a3:0x3ffd2ad0 0x4008e2a3:0x3ffd2af0 0x4008e2a3:0x3ffd2b10 0x4008e2a3:0x3ffd2b50 0x4008e2a3:0x3ffd2b80 0x4008007d:0x3ffd2a60 0x40082ab7:0x3ffd2a80 0x4008e2a3:0x3ffd2ab0 0x4008e2a3:0x3ffd2ad0 0x4008e2a3:0x3ffd2af0 |<-CONTINUES
#0 0x4008e2a3:0x3ffd2a60 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#1 0x401cf5b5:0x3ffd2a80 in nvs::Page::readEntry(unsigned int, nvs::Item&) const at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/nvs_flash/src/nvs_page.cpp:879
#2 0x4008e2a3:0x3ffd2ab0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#3 0x4008e2a3:0x3ffd2ad0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#4 0x4008e2a3:0x3ffd2af0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#5 0x4008e2a3:0x3ffd2b10 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#6 0x4008e2a3:0x3ffd2b50 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#7 0x4008e2a3:0x3ffd2b80 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#8 0x4008007d:0x3ffd2a60 in _xt_alloca_exc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_vectors.S:1802
#9 0x40082ab7:0x3ffd2a80 in spi_flash_disable_interrupts_caches_and_other_cpu at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/spi_flash/cache_utils.c:139
#10 0x4008e2a3:0x3ffd2ab0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#11 0x4008e2a3:0x3ffd2ad0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#12 0x4008e2a3:0x3ffd2af0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#13 0x4008e2a3:0x3ffd2b10 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#14 0x4008e2a3:0x3ffd2b50 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#15 0x4008e2a3:0x3ffd2b80 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#16 0x4008007d:0x3ffd2a60 in _xt_alloca_exc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_vectors.S:1802
#17 0x40082ab7:0x3ffd2a80 in spi_flash_disable_interrupts_caches_and_other_cpu at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/spi_flash/cache_utils.c:139
#18 0x4008e2a3:0x3ffd2ab0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#19 0x4008e2a3:0x3ffd2ad0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#20 0x4008e2a3:0x3ffd2af0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#21 0x4008e2a3:0x3ffd2b10 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#22 0x4008e2a3:0x3ffd2b50 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#23 0x4008e2a3:0x3ffd2b80 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#24 0x4008007d:0x3ffd2a60 in _xt_alloca_exc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_vectors.S:1802
#25 0x40082ab7:0x3ffd2a80 in spi_flash_disable_interrupts_caches_and_other_cpu at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/spi_flash/cache_utils.c:139
#26 0x4008e2a3:0x3ffd2ab0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#27 0x4008e2a3:0x3ffd2ad0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#28 0x4008e2a3:0x3ffd2af0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#29 0x4008e2a3:0x3ffd2b10 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#30 0x4008e2a3:0x3ffd2b50 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#31 0x4008e2a3:0x3ffd2b80 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#32 0x4008007d:0x3ffd2a60 in _xt_alloca_exc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_vectors.S:1802
#33 0x40082ab7:0x3ffd2a80 in spi_flash_disable_interrupts_caches_and_other_cpu at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/spi_flash/cache_utils.c:139
#34 0x4008e2a3:0x3ffd2ab0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#35 0x4008e2a3:0x3ffd2ad0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#36 0x4008e2a3:0x3ffd2af0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#37 0x4008e2a3:0x3ffd2b10 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#38 0x4008e2a3:0x3ffd2b50 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#39 0x4008e2a3:0x3ffd2b80 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#40 0x4008007d:0x3ffd2a60 in _xt_alloca_exc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_vectors.S:1802
#41 0x40082ab7:0x3ffd2a80 in spi_flash_disable_interrupts_caches_and_other_cpu at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/spi_flash/cache_utils.c:139
#42 0x4008e2a3:0x3ffd2ab0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#43 0x4008e2a3:0x3ffd2ad0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#44 0x4008e2a3:0x3ffd2af0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#45 0x4008e2a3:0x3ffd2b10 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#46 0x4008e2a3:0x3ffd2b50 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#47 0x4008e2a3:0x3ffd2b80 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#48 0x4008007d:0x3ffd2a60 in _xt_alloca_exc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_vectors.S:1802
#49 0x40082ab7:0x3ffd2a80 in spi_flash_disable_interrupts_caches_and_other_cpu at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/spi_flash/cache_utils.c:139
#50 0x4008e2a3:0x3ffd2ab0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#51 0x4008e2a3:0x3ffd2ad0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#52 0x4008e2a3:0x3ffd2af0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#53 0x4008e2a3:0x3ffd2b10 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#54 0x4008e2a3:0x3ffd2b50 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#55 0x4008e2a3:0x3ffd2b80 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#56 0x4008007d:0x3ffd2a60 in _xt_alloca_exc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_vectors.S:1802
#57 0x40082ab7:0x3ffd2a80 in spi_flash_disable_interrupts_caches_and_other_cpu at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/spi_flash/cache_utils.c:139
#58 0x4008e2a3:0x3ffd2ab0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#59 0x4008e2a3:0x3ffd2ad0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#60 0x4008e2a3:0x3ffd2af0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#61 0x4008e2a3:0x3ffd2b10 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#62 0x4008e2a3:0x3ffd2b50 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#63 0x4008e2a3:0x3ffd2b80 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#64 0x4008007d:0x3ffd2a60 in _xt_alloca_exc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_vectors.S:1802
#65 0x40082ab7:0x3ffd2a80 in spi_flash_disable_interrupts_caches_and_other_cpu at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/spi_flash/cache_utils.c:139
#66 0x4008e2a3:0x3ffd2ab0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#67 0x4008e2a3:0x3ffd2ad0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#68 0x4008e2a3:0x3ffd2af0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#69 0x4008e2a3:0x3ffd2b10 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#70 0x4008e2a3:0x3ffd2b50 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#71 0x4008e2a3:0x3ffd2b80 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#72 0x4008007d:0x3ffd2a60 in _xt_alloca_exc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_vectors.S:1802
#73 0x40082ab7:0x3ffd2a80 in spi_flash_disable_interrupts_caches_and_other_cpu at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/spi_flash/cache_utils.c:139
#74 0x4008e2a3:0x3ffd2ab0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#75 0x4008e2a3:0x3ffd2ad0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#76 0x4008e2a3:0x3ffd2af0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#77 0x4008e2a3:0x3ffd2b10 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#78 0x4008e2a3:0x3ffd2b50 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#79 0x4008e2a3:0x3ffd2b80 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#80 0x4008007d:0x3ffd2a60 in _xt_alloca_exc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_vectors.S:1802
#81 0x40082ab7:0x3ffd2a80 in spi_flash_disable_interrupts_caches_and_other_cpu at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/spi_flash/cache_utils.c:139
#82 0x4008e2a3:0x3ffd2ab0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#83 0x4008e2a3:0x3ffd2ad0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#84 0x4008e2a3:0x3ffd2af0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#85 0x4008e2a3:0x3ffd2b10 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#86 0x4008e2a3:0x3ffd2b50 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#87 0x4008e2a3:0x3ffd2b80 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#88 0x4008007d:0x3ffd2a60 in _xt_alloca_exc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_vectors.S:1802
#89 0x40082ab7:0x3ffd2a80 in spi_flash_disable_interrupts_caches_and_other_cpu at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/spi_flash/cache_utils.c:139
#90 0x4008e2a3:0x3ffd2ab0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#91 0x4008e2a3:0x3ffd2ad0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#92 0x4008e2a3:0x3ffd2af0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#93 0x4008e2a3:0x3ffd2b10 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#94 0x4008e2a3:0x3ffd2b50 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#95 0x4008e2a3:0x3ffd2b80 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#96 0x4008007d:0x3ffd2a60 in _xt_alloca_exc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_vectors.S:1802
#97 0x40082ab7:0x3ffd2a80 in spi_flash_disable_interrupts_caches_and_other_cpu at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/spi_flash/cache_utils.c:139
#98 0x4008e2a3:0x3ffd2ab0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#99 0x4008e2a3:0x3ffd2ad0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
#100 0x4008e2a3:0x3ffd2af0 in _xt_context_save at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/port/xtensa/xtensa_context.S:194
Also, the memory usage was similar. So there is something else using about 5000 bytes
from interruptbutton.
from interruptbutton.
because the mode doesn't affect capturing the event which is always done
the same in the interrupt. It's how the actions are executed that
changes.
Oh, nice! So I will definitely try that!
from interruptbutton.
because the mode doesn't affect capturing the event which is always done
the same in the interrupt. It's how the actions are executed that
changes.Oh, nice! So I will definitely try that!
So I've switched to sync mode, calling InterruptButton::processSyncEvents();
in a loop.
- This did not change the heap consumption: I have exactly the same as before. It seems the heap consumption might be caused by the library itself and not the usage of async / sync mode
- With sync, I observe some delays sometimes between the execution of the action and the press action, which is normal and same behaviour as I was doing with async at the end
- It is even better because it solves some random issues: sometimes, a button press was crashing the code in some esp32 code vector.c. I never found the problem, but it's gone. I was suspecting a concurrent issue like some lack of
volatile
keywork somehwere. TheEasyButton
library also seems to have such random issues.
from interruptbutton.
- It is even better because it solves some random issues: sometimes, a button press was crashing the code in some esp32 code vector.c. I never found the problem, but it's gone. I was suspecting a concurrent issue like some lack of
volatile
keywork somehwere. TheEasyButton
library also seems to have such random issues.
Yes, the Sync mode skips using RTOS stuff, so a bit more stable without the concurrent tasks. Comes at a cost of latentcy of course.
from interruptbutton.
Note that I had to wrap your InterruptButton in a class because I am allowing the user to change pins. So I can only create the button once I read the pin from my configuration.
If we look at how your constructor is made, I am not sure you need a constructor at all:
InterruptButton(uint8_t pin, // Class Constructor, pin to monitor uint8_t pressedState, // State of the pin when pressed (HIGH or LOW) gpio_mode_t pinMode = GPIO_MODE_INPUT, uint16_t longKeyPressMS = 750, uint16_t autoRepeatMS = 250, uint16_t doubleClickMS = 333, uint32_t debounceUS = 8000);could become
void setPinMode(...); void setLongKeyPressMS(...); [...] void init(uint8_t pin, uint8_t pressedState);This would allow to decouple class instantiation, configuration and initialisation, especially that most of the settings have default values.
If you want to do a pull request around this one, I am willing to consider adding an alternate path for instantiation and configuration. IE, leave the user the option to do as it is, or alternatively using a overloaded constructor with a different signature and use your method.
from interruptbutton.
@rwmingis : oh, yes definitely if you accept such api I will be glad to do it because I will then be able to just initialize the button once in the class as a private field and either use it or not and change its pin. I'll send a PR soon :-)
from interruptbutton.
Related Issues (11)
- Unable to attach to INPUT-only pins HOT 3
- ESP crashes if using dynamicaly created objects HOT 3
- interruptbutton stops working after some time HOT 2
- Program crashes HOT 2
- RTOS API HOT 2
- Cant disable AutoRepeatPress HOT 15
- CRLF HOT 1
- v2.0.1 does not compile
- Add cpplint check at each push and PR to ensure the code is formatted properly and basic issues are found
- Problem with ArduinoIDE 2.0.0 on Windows11 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from interruptbutton.