Keypad icon indicating copy to clipboard operation
Keypad copied to clipboard

Don't #define OPEN and CLOSED

Open tig opened this issue 4 years ago • 0 comments

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.

tig avatar Jun 29 '21 23:06 tig