Skip to content
Open
Show file tree
Hide file tree
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
12 changes: 11 additions & 1 deletion src/clickButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,22 @@ ClickButton::ClickButton(uint8_t buttonPin, boolean activeType, boolean internal
multiclickTime = 250; // Time limit for multi clicks
longClickTime = 1000; // time until "long" click register

// Particle devices
#if defined PLATFORM_ID
// Turn on internal pullup resistor if applicable
if (_activeHigh == LOW && internalPullup == CLICKBTN_PULLUP)
pinMode(_pin, INPUT_PULLUP);
else
pinMode(_pin, INPUT_PULLDOWN);
// Raspberry Pi
#else
pinMode(_pin, INPUT);
// Turn on internal pullup resistor if applicable
if (_activeHigh == LOW && internalPullup == CLICKBTN_PULLUP)
pullUpDnControl(_pin, PUD_UP);
else
pullUpDnControl(_pin, PUD_DOWN);
#endif
}


Expand Down Expand Up @@ -144,4 +155,3 @@ void ClickButton::Update()

_lastState = _btnState;
}

14 changes: 13 additions & 1 deletion src/clickButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,19 @@ NOTE!
*/

// -------- clickButton.h --------
#include "Particle.h"

// Particle devices
#if defined PLATFORM_ID
#include "Particle.h"
// Raspberry Pi
#else
// for uint8_t
#include "stdint.h"
// for GPIO functionality
#include <wiringPi.h>

typedef uint8_t boolean;
#endif

#define CLICKBTN_PULLUP HIGH

Expand Down