Skip to content

maxrangner/GawiButtons

Repository files navigation

GawiButtons

GawiButtons is a lightweight Arduino library with debounced button handling. It provides a central manager for multiple buttons.

Features

  • Debounce handling with configurable timing.
  • Press and hold detection.
  • ButtonManager for centralized updates.
  • Optional pull-up support.

Installation

Library Manager (recommended)

  • Coming soon.

Manual installation

  1. Download the .zip from GitHub.
  2. In the Arduino IDE -> Sketch -> Include Library -> Add .zip library or add GawiButtons to Documents/Arduino/libraries
  3. Include in project: #include <GawiButtons.h>

Setup

  1. Create manager object to control the buttons:
ButtonManager buttonManager;
  1. Create Button object. addButton() dynamically creates a button within the ButtonManager object. The function returns a pointer to the new Button object.
Button* buttonBuiltIn;
buttonBuiltIn = buttonManager.addButton(9);

Usage

  1. Manager updates all registered buttons:
buttonManager.updateAll();
  1. Button states logic:
if (buttonBuiltIn->wasPressed()) {
    Serial.println("Button was pressed.");
}

if (buttonBuiltIn->wasHeld()) {
    Serial.println("Button was held.");
}

Additional functions

  • Get number of added buttons:
buttonManager.getNumButtons(); // Returns a uint8_t

About

Lightweight debouncing, hold detection, pull-up configuration and unified update handling.

Resources

License

Stars

Watchers

Forks

Packages

No packages published