Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Feature Request: Multiple buttons/GPIO Inputs #119

Closed
girlpunk opened this issue Apr 4, 2018 · 2 comments
Closed

Feature Request: Multiple buttons/GPIO Inputs #119

girlpunk opened this issue Apr 4, 2018 · 2 comments
Assignees

Comments

@girlpunk
Copy link

girlpunk commented Apr 4, 2018

Multiple buttons (or any form of GPIO input) that would feed back to MQTT, so as to trigger automations.

@toblum
Copy link
Owner

toblum commented Apr 7, 2018

@cyberjacob I added this to the list for possible enhancemants.

@toblum toblum closed this as completed Apr 7, 2018
@toblum toblum self-assigned this Apr 7, 2018
@JPluess
Copy link

JPluess commented Feb 1, 2019

hi i have not much experience programming but i wrote a class for multibutton. would that be appreciated?
it registers fastpress and counts how many there are and returns that, and it counts up if you hold the button down. every 0.5s it adds 1.

#include "Multi_Button.h"

#define BUTTON_PIN D3 // Button Pin on node mcu it is D3
#define TIME_GAP_SHORT 300 // Set the time between fast presses
#define TIME_GAP_LONG 500 // Set the time between long presses
#define BUTTON_STATE 0// Set the button to 1 HIGH on or 0 LOW on

MultiButton Button1(BUTTON_PIN, TIME_GAP_SHORT, TIME_GAP_LONG, BUTTON_STATE);

if(uint8_t counts = Button1.ShortPress())
{
if (counts == 1) your code here;
if(counts == 2) your code here;
if(counts == 3) your code here;
if(counts == 4) your code here;
}

//or the long press
if (uint8_t counts = Button1.LongPress())
{
if (counts == 1) your code here;
if(counts == 2) your code here;
if(counts == 3) your code here;
if(counts == 4) your code here;
}

Button1.fast_press_toggle; // true or false is the debounced toggle of the specified button

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants