Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions firmware/clickButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

A positive number denotes the number of (short) clicks after a released button
A negative number denotes the number of "long" clicks
A positive number (100 + number of clicks) denotes when a button was released

NOTE!
This is the OPPOSITE/negative of click codes from the last pre-2013 versions!
Expand Down Expand Up @@ -53,13 +54,15 @@ NOTE!
#include "application.h"

#define CLICKBTN_PULLUP HIGH
#define CLICKBTN_PULLDOWN LOW

class ClickButton
{
public:
ClickButton(uint8_t buttonPin);
ClickButton(uint8_t buttonPin, boolean active);
ClickButton(uint8_t buttonPin, boolean active, boolean internalPullup);
ClickButton(uint8_t buttonPin, boolean active, boolean internalPullup, boolean reportRelease);
void Update();
int clicks; // button click counts to return
boolean depressed; // the currently debounced button (press) state (presumably it is not sad :)
Expand All @@ -69,9 +72,12 @@ class ClickButton
private:
uint8_t _pin; // Arduino pin connected to the button
boolean _activeHigh; // Type of button: Active-low = 0 or active-high = 1
boolean _reportRelease;
boolean _btnState; // Current appearant button state
boolean _lastState; // previous button reading
boolean _clickNHold;
int _clickCount; // Number of button clicks within multiclickTime milliseconds
int _lastClickCount;
long _lastBounceTime; // the last time the button input pin was toggled, due to noise or a press
};

Expand Down