Git Product home page Git Product logo

ripred / buttongestures Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 1.0 59 KB

Use a single push button for up to 6 different functions! Button gesture combinations of single, double, and triple-tap along with a long or short hold on the last press make it easy! Functions can also be pre-registered for callback for the gesture that you want. Even easier!

Home Page: https://github.com/ripred/ButtonGestures

License: Other

C++ 100.00%
arduino arduino-library button-control ergonomics gesture-recognition gestures push-button

buttongestures's Introduction

Hi there I'm Trent. ๐Ÿ‘‹ Welcome to my repositories!

My interests include Generative AI, Language Design, FPGA's, Writing Chess Engines, Compiler Design and Implementation, Kernel Development, High Speed Networking for MMO's and Live Teleconferencing, Robotics, Embedded Systems, Industrial Automation, Paleontology, Drumming, Math, and Skydiving.

Top Langs

buttongestures's People

Contributors

ripred avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

fyrus7

buttongestures's Issues

serial speeds

I noticed that in the basic use example, you used Serial.begin(2000000), while in the register example, you used Serial.begin(115200).

I was just wondering what the reason was, and if there is a suggested speed you think is best to use with this library?

This isn't really an Issue I just wasn't sure how else to ask

registering a function for callback is not working

/*\ Example use of the ButtonGestures library
|*|
|*| This example shows how to register different functions to be
|*| called for different gestures.
|*|
|*| If a function has been registered to a gesture then the function
|*| will automatically be called for that gesture.
\*/

#include <ButtonGestures.h>

// NOTE: change/define the following pin(s) based on your project/connections
#define   BUTTON_PIN    2

ButtonGestures  button(BUTTON_PIN);

//
// These functions will be registered and called for the various gestures:
//

void function1(const uint8_t /*pin*/, const uint8_t /*state*/) {
    Serial.println("function 1 has been called");
}

void function2(const uint8_t /*pin*/, const uint8_t /*state*/) {
    Serial.println("function 2 has been called");
}

void function3(const uint8_t /*pin*/, const uint8_t /*state*/) {
    Serial.println("function 3 has been called");
}

void function4(const uint8_t /*pin*/, const uint8_t /*state*/) {
    Serial.println("function 4 has been called");
}

void function5(const uint8_t /*pin*/, const uint8_t /*state*/) {
    Serial.println("function 5 has been called");
}

void function6(const uint8_t /*pin*/, const uint8_t /*state*/) {
    Serial.println("function 6 has been called");
}


void setup(void) {
    Serial.begin(2000000);
    uint32_t timer = millis() + 2000;
    while (!Serial && millis() < timer);
    Serial.flush();
    Serial.println(F("\n\nArduino Core Library - ButtonGestures Library Test"));

    if (!button.set_callback(SHORT1, function1))
        Serial.println("Error registering callback for SHORT1");
    if (!button.set_callback(LONG1, function2))
        Serial.println("Error registering callback for LONG1");
    if (!button.set_callback(SHORT2, function3))
        Serial.println("Error registering callback for SHORT2");
    if (!button.set_callback(LONG2, function4))
        Serial.println("Error registering callback for LONG2");
    if (!button.set_callback(SHORT3, function5))
        Serial.println("Error registering callback for SHORT3");
    if (!button.set_callback(LONG3, function6))
        Serial.println("Error registering callback for LONG3");
}

void loop(void) {
    button.check_button();
}

This example should display the appropriate debug output when each registered function is invoked by making the associated gesture with the push button.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.