Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aliases OPEN and CLOSED are causing compatibility issues with another libraries #45

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions src/Key.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@

#include <Arduino.h>

#define OPEN LOW
#define CLOSED HIGH
#define KEYPAD_OPEN LOW
#define KEYPAD_CLOSED HIGH

typedef unsigned int uint;
typedef enum{ IDLE, PRESSED, HOLD, RELEASED } KeyState;
Expand Down
6 changes: 3 additions & 3 deletions src/Keypad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,18 @@ void Keypad::nextKeyState(byte idx, boolean button) {

switch (key[idx].kstate) {
case IDLE:
if (button==CLOSED) {
if (button==KEYPAD_CLOSED) {
transitionTo (idx, PRESSED);
holdTimer = millis(); } // Get ready for next HOLD state.
break;
case PRESSED:
if ((millis()-holdTimer)>holdTime) // Waiting for a key HOLD...
transitionTo (idx, HOLD);
else if (button==OPEN) // or for a key to be RELEASED.
else if (button==KEYPAD_OPEN) // or for a key to be RELEASED.
transitionTo (idx, RELEASED);
break;
case HOLD:
if (button==OPEN)
if (button==KEYPAD_OPEN)
transitionTo (idx, RELEASED);
break;
case RELEASED:
Expand Down
4 changes: 2 additions & 2 deletions src/Keypad.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ do { \
#endif


#define OPEN LOW
#define CLOSED HIGH
#define KEYPAD_OPEN LOW // Many libraries use this alias OPEN , and this cause issues
#define KEYPAD_CLOSED HIGH // Many libraries use this alias CLOSED , and this cause issues

typedef char KeypadEvent;
typedef unsigned int uint;
Expand Down