All Projects → LennartHennigs → Button2

LennartHennigs / Button2

Licence: mit
Arduino Library to simplify working with buttons. It allows you to use callback functions to track single, double, triple and long clicks. It also takes care of debouncing.

Projects that are alternatives of or similar to Button2

Guislice
GUIslice drag & drop embedded GUI in C for touchscreen TFT on Arduino, Raspberry Pi, ARM, ESP8266 / ESP32 / M5stack using Adafruit-GFX / TFT_eSPI / UTFT / SDL
Stars: ✭ 534 (+389.91%)
Mutual labels:  arduino, arduino-library, esp8266, embedded
Platformio Atom Ide
PlatformIO IDE for Atom: The next generation integrated development environment for IoT
Stars: ✭ 475 (+335.78%)
Mutual labels:  arduino, hardware, esp8266, embedded
Waterius
Передача показаний воды по Wi-Fi. Watermeter Wi-Fi transmitter.
Stars: ✭ 295 (+170.64%)
Mutual labels:  arduino, hardware, esp8266, embedded
Easyntpclient
Library to read time from Network Time Protocol (NTP) servers.
Stars: ✭ 20 (-81.65%)
Mutual labels:  arduino, arduino-library, esp8266, embedded
Blinker Library
An IoT Solution,Blinker library for embedded hardware. Works with Arduino, ESP8266, ESP32.
Stars: ✭ 1,095 (+904.59%)
Mutual labels:  arduino, hardware, esp8266, embedded
Blynk Library
Blynk library for embedded hardware. Works with Arduino, ESP8266, Raspberry Pi, Intel Edison/Galileo, LinkIt ONE, Particle Core/Photon, Energia, ARM mbed, etc.
Stars: ✭ 3,305 (+2932.11%)
Mutual labels:  arduino, hardware, esp8266, embedded
Arduinojson
📟 JSON library for Arduino and embedded C++. Simple and efficient.
Stars: ✭ 5,456 (+4905.5%)
Mutual labels:  arduino, arduino-library, esp8266, embedded
Heatpump
Arduino library to control Mitsubishi Heat Pumps via connector cn105
Stars: ✭ 327 (+200%)
Mutual labels:  arduino, arduino-library, esp8266
Espui
A simple web user interface library for ESP32 and ESP8266
Stars: ✭ 330 (+202.75%)
Mutual labels:  arduino, arduino-library, esp8266
Platformio Core
PlatformIO is a professional collaborative platform for embedded development 👽 A place where Developers and Teams have true Freedom! No more vendor lock-in!
Stars: ✭ 5,539 (+4981.65%)
Mutual labels:  arduino, esp8266, embedded
Pjon
PJON (Padded Jittering Operative Network) is an experimental, arduino-compatible, multi-master, multi-media network protocol.
Stars: ✭ 2,615 (+2299.08%)
Mutual labels:  arduino, esp8266, embedded
Arduino Homekit Esp8266
Native Apple HomeKit accessory implementation for the ESP8266 Arduino core.
Stars: ✭ 545 (+400%)
Mutual labels:  arduino, arduino-library, esp8266
Esp8266 Weather Station
ESP8266 Weather Station library supporting OpenWeatherMap, Aeris and other sources
Stars: ✭ 822 (+654.13%)
Mutual labels:  arduino, arduino-library, esp8266
Ssd1306
Driver for SSD1306, SSD1331, SSD1351, IL9163, ILI9341, ST7735, PCD8544, Nokia 5110 displays running on Arduino/ESP32/Linux (Rasperry) platforms
Stars: ✭ 303 (+177.98%)
Mutual labels:  arduino, arduino-library, esp8266
Ws2812fx
WS2812 FX Library for Arduino and ESP8266
Stars: ✭ 1,113 (+921.1%)
Mutual labels:  arduino, arduino-library, esp8266
Sming
Sming - Open Source framework for high efficiency native ESP8266 development
Stars: ✭ 1,197 (+998.17%)
Mutual labels:  arduino, esp8266, embedded
Arduinowebsockets
A library for writing modern websockets applications with Arduino (ESP8266 and ESP32)
Stars: ✭ 213 (+95.41%)
Mutual labels:  arduino, arduino-library, esp8266
Helios
The free embedded operating system.
Stars: ✭ 223 (+104.59%)
Mutual labels:  arduino, arduino-library, embedded
Ewma
Exponentially Weighted Moving Average Filter
Stars: ✭ 21 (-80.73%)
Mutual labels:  arduino, arduino-library, esp8266
Aunit
Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test. Used with AUniter or EpoxyDuino for continuous builds.
Stars: ✭ 73 (-33.03%)
Mutual labels:  arduino, arduino-library, esp8266

Button2

Arduino Library to simplify working with buttons.

Description

It allows you to use callback functions to track single, double, triple and long clicks. It also takes care of debouncing. It will reduce and simplify your source code significantly.

Tested with Arduino, ESP8266 and ESP32.

How To Use

Please take a look at the included examples to get an overview over the different callback handlers.

  • The callback function from setTapHandler() will be called when any click (single, double, triple) occurs.

  • The callback function from setLongClickDetectedHandler() will be called as soon as the long click timeout has passed.

  • The callback for setLongClickHandler() will be called after the button has released.

  • You can define your own timeouts by using these setter functions before you include the class:

    void setDebounceTime(unsigned int ms);

    void setLongClickTime(unsigned int ms);

    void setDoubleClickTime(unsigned int ms);

Note: For the class to work, you need to call the loop() member function in your sketch's loop() function. See the example for more details.

These are the constructors and the member functions the library provides:

Button2();
  Button2(byte attachTo, byte buttonMode = INPUT_PULLUP, boolean isCapacitive = false, boolean activeLow = true);

  void begin(byte attachTo, byte buttonMode = INPUT_PULLUP, boolean isCapacitive = false , boolean activeLow  = true);

  void setDebounceTime(unsigned int ms);
  void setLongClickTime(unsigned int ms);
  void setDoubleClickTime(unsigned int ms);
  
  unsigned int getDebounceTime();
  unsigned int getLongClickTime();
  unsigned int getDoubleClickTime();
  byte getAttachPin();

  void setLongClickDetectedRetriggerable(bool retriggerable);

  void reset();

  void setChangedHandler(CallbackFunction f);
  void setPressedHandler(CallbackFunction f);
  void setReleasedHandler(CallbackFunction f);

  void setTapHandler(CallbackFunction f);
  void setClickHandler(CallbackFunction f);
  void setDoubleClickHandler(CallbackFunction f);
  void setTripleClickHandler(CallbackFunction f);

  void setLongClickHandler(CallbackFunction f);
  void setLongClickDetectedHandler(CallbackFunction f);

  unsigned int wasPressedFor() const;
  boolean isPressed() const;
  boolean isPressedRaw() const;

  byte getNumberOfClicks() const;
  byte getClickType() const;

  bool operator==(Button2 &rhs);

  void loop();

And please take a look at the Changelog for the latest changes to the library.

Installation

Open the Arduino IDE choose "Sketch > Include Library" and search for "Button2". Or download the ZIP archive (https://github.com/lennarthennigs/Button2/zipball/master), and choose "Sketch > Include Library > Add .ZIP Library..." and select the downloaded file.

License

MIT License

Copyright (c) 2017-2020 Lennart Hennigs

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].