diff --git a/Joystick.cpp b/Joystick.cpp index 2335471..e27492c 100644 --- a/Joystick.cpp +++ b/Joystick.cpp @@ -163,7 +163,7 @@ void Joystick::_UpdateButton(Button& button, uint8_t index) { if (button.pullup) value = _InvertSignal(value); switch (button.type) { - case BUTTON_MAINTAINED: + case BUTTON_LATCHED: if (value == HIGH) PressButton(index); else ReleaseButton(index); break; diff --git a/Joystick.h b/Joystick.h index 11b1cb4..e7ccb92 100644 --- a/Joystick.h +++ b/Joystick.h @@ -15,7 +15,7 @@ #define JOYSTICK_NUM_BYTES (JOYSTICK_NUM_BUTTONS+7)/8 enum ButtonType { - BUTTON_MAINTAINED = 0x1, + BUTTON_LATCHED = 0x1, BUTTON_PULSED = 0x2, BUTTON_PULSED_DOUBLE_ACTION = 0x4 }; diff --git a/examples/complex_switch_panel.ino b/examples/complex_switch_panel.ino new file mode 100644 index 0000000..74acc96 --- /dev/null +++ b/examples/complex_switch_panel.ino @@ -0,0 +1,23 @@ +// A button box example using all of the button types. +// This is the code used in the Black Box project. +// TODO: add link to blog post, once it exists. + +#include + +Joystick joystick; + +void setup() { + pinMode(13, OUTPUT); + digitalWrite(13, LOW); + + joystick.Init(); + joystick.AddButton(2, BUTTON_PULSED_DOUBLE_ACTION); + joystick.AddButton(3, BUTTON_PULSED_DOUBLE_ACTION); + joystick.AddButton(4, BUTTON_PULSED_DOUBLE_ACTION); + joystick.AddButton(5, BUTTON_MAINTAINED); + joystick.AddButton(6, BUTTON_PULSED); +} + +void loop () { + joystick.Update(); +}