cyborg5 / IRLib2

Library for receiving, decoding, and sending infrared signals using Arduino
GNU General Public License v3.0
384 stars 138 forks source link

IR Protocol Suggestion #87

Open AndruePeters opened 4 years ago

AndruePeters commented 4 years ago

I'm not creating a pull request because it's such a small thing to do, but I thought it was worth suggesting. I first saw this used while doing some TI development.

Currently you have

`#define UNKNOWN 0
#define NEC 1
...
#define LAST_PROTOCOL 12 // Be sure to update this`

What you can do instead is

enum {
UNKNOWN = 0,
NEC, 
SONY,
...
LAST_PROTOCOL
}

This will automatically update the value for LAST_PROTOCOL as well as provide a bit more structure. Since you're already using OOP paradigms with C++, then I'd also suggest enum classes. However, that would require rewriting some code. What I suggested shouldn't break anything and also make it less error prone.

AndruePeters commented 4 years ago

By keeping the enum anonymous, it shouldn't interfere with any of your existing code. I'd also request changing the names of the protocols or namespace because they've interfered with other projects.