Skip to content

Commit 37166d5

Browse files
committed
Update VirtButton.h
1 parent 7c37835 commit 37166d5

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,6 +1765,7 @@ void loop() {
17651765
- Исправлена ошибка компиляции при использовании библиотеки в нескольких .cpp файлах
17661766
- v3.5.3
17671767
- Добавлено количество кликов в опрос press/release/click/pressing
1768+
- v3.5.5 - коллбэк на базе std::function для ESP
17681769
17691770
<a id="feedback"></a>
17701771
## Баги и обратная связь

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=EncButton
2-
version=3.5.4
2+
version=3.5.5
33
author=AlexGyver <[email protected]>
44
maintainer=AlexGyver <[email protected]>
55
sentence=Light and powerful library for button and encoder operation for Arduino

src/core/VirtButton.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
#define EB_STEP_T (EB_STEP_TIME)
4040
#endif
4141

42-
#define EB_FOR_SCALE 6
43-
4442
// =================== PACK FLAGS ===================
4543
#define EB_CLKS_R (1 << 0)
4644
#define EB_PRS_R (1 << 1)
@@ -64,6 +62,12 @@
6462

6563
// базовый класс кнопки
6664
class VirtButton {
65+
#ifdef __AVR__
66+
typedef void (*ActionHandler)();
67+
#else
68+
typedef std::function<void()> ActionHandler;
69+
#endif
70+
6771
public:
6872
// ====================== SET ======================
6973
// установить таймаут удержания, умолч. 600 (макс. 4000 мс)
@@ -120,9 +124,9 @@ class VirtButton {
120124
}
121125

122126
// подключить функцию-обработчик событий (вида void f())
123-
void attach(void (*handler)()) {
127+
void attach(ActionHandler handler) {
124128
#ifndef EB_NO_CALLBACK
125-
cb = *handler;
129+
cb = handler;
126130
#endif
127131
}
128132

@@ -484,7 +488,7 @@ class VirtButton {
484488
#endif
485489

486490
#ifndef EB_NO_CALLBACK
487-
void (*cb)() = nullptr;
491+
ActionHandler cb = nullptr;
488492
#endif
489493

490494
#ifndef EB_DEB_TIME

0 commit comments

Comments
 (0)