/
singlwolf
/
Radiola-2S3
Обзор
Документация
Войти
/
singlwolf
/
Radiola-2S3
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
lib/OneButton/examples/FunctionalButton/FunctionalButton.ino
48 строк
991 B
SinglWolf
Public access
27 мар 2026, 07:00
27 мар 2026, 07:00
642fcfc
Код
Авторство
О чём код?
/** * FunctionalButton.ino - Example for the OneButtonLibrary library. * This is a sample sketch to show how to use OneClick library functionally on ESP32,ESP8266... * */ #include <Arduino.h> #include <OneButton.h> class Button{ private: OneButton button; int value; public: explicit Button(uint8_t pin):button(pin) { button.attachClick([](void *scope) { ((Button *) scope)->Clicked();}, this); button.attachDoubleClick([](void *scope) { ((Button *) scope)->DoubleClicked();}, this); button.attachLongPressStart([](void *scope) { ((Button *) scope)->LongPressed();}, this); } void Clicked(){ Serial.println("Click then value++"); value++; } void DoubleClicked(){ Serial.println("DoubleClick"); } void LongPressed(){ Serial.println("LongPress and the value is"); Serial.println(value); } void handle(){ button.tick(); } }; Button button(0); void setup() { Serial.begin(115200); } void loop() { button.handle(); }