Chris--A / Keypad

A version of the keypad library found in Wiring. This is just a copy made compatible with the Arduino IDE library manager.
GNU General Public License v3.0
248 stars 150 forks source link

Don't #define OPEN and CLOSED #39

Open tig opened 3 years ago

tig commented 3 years ago

In Keypad.h the following macros are defined

#define OPEN LOW
#define CLOSED HIGH

Because of this, any code that includes Keypad.h can't use OPEN or CLOSE for enum names. E.g.

  enum ActuatorStatus
  {
    CLOSED,
    OPEN,
    CLOSING,
    OPENING,
    TIMEOUT,
    ERROR = -1
  };

image

In addition, these #defines are duplicated in Key.h.

Super annoying.

One way to fix this is to delete the #defines from Keypad.h and replace the ones in Key.h with:

#define __OPEN LOW
#define __CLOSED HIGH

or, even better:

enum ButtonState {
   OPEN = LOW,
   CLOSED = HIGH
};

Or something similar.