Skip to content

Commit bb9f258

Browse files
committed
Added namespace to enum.
1 parent 87f2d62 commit bb9f258

8 files changed

Lines changed: 43 additions & 40 deletions

src/ButtonBase.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void ButtonBase::setDebounceInterval(int debounceInterval)
5555
_debouncer.interval(debounceInterval);
5656
}
5757

58-
BUTTONSTATUS ButtonBase::update()
58+
BUTTONSUITE::BUTTONSTATUS ButtonBase::update()
5959
{
6060
// See ButtonEnums.h for the definitions of the different button states.
6161

@@ -70,7 +70,7 @@ BUTTONSTATUS ButtonBase::update()
7070
#ifdef BUTTONSUITEDEBUG
7171
Serial.println("ButtonBase::update: JUSTPRESSED");
7272
#endif
73-
return JUSTPRESSED;
73+
return BUTTONSUITE::JUSTPRESSED;
7474
}
7575

7676
// Look to see if the button is currently pressed.
@@ -84,14 +84,14 @@ BUTTONSTATUS ButtonBase::update()
8484
#ifdef BUTTONSUITEDEBUG
8585
Serial.println("ButtonBase::update: ISSHORTPRESSED");
8686
#endif
87-
return ISSHORTPRESSED;
87+
return BUTTONSUITE::ISSHORTPRESSED;
8888
}
8989
else
9090
{
9191
#ifdef BUTTONSUITEDEBUG
9292
Serial.println("ButtonBase::update: ISLONGPRESSED");
9393
#endif
94-
return ISLONGPRESSED;
94+
return BUTTONSUITE::ISLONGPRESSED;
9595
}
9696
}
9797

@@ -106,14 +106,14 @@ BUTTONSTATUS ButtonBase::update()
106106
#ifdef BUTTONSUITEDEBUG
107107
Serial.println("ButtonBase::update: WASSHORTPRESSED");
108108
#endif
109-
return WASSHORTPRESSED;
109+
return BUTTONSUITE::WASSHORTPRESSED;
110110
}
111111
else
112112
{
113113
#ifdef BUTTONSUITEDEBUG
114114
Serial.println("ButtonBase::update: WASLONGPRESSED");
115115
#endif
116-
return WASLONGPRESSED;
116+
return BUTTONSUITE::WASLONGPRESSED;
117117
}
118118
}
119119

@@ -122,5 +122,5 @@ BUTTONSTATUS ButtonBase::update()
122122
#ifdef BUTTONSUITEDEBUG
123123
Serial.println("ButtonBase::update: NOTPRESSED");
124124
#endif
125-
return NOTPRESSED;
125+
return BUTTONSUITE::NOTPRESSED;
126126
}

src/ButtonBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class ButtonBase
8787
protected:
8888
// Checks the button and returns the status/state. This does the work of categorizing the state
8989
// of the button. It is up to the derived class to determine behavior based on the returned value.
90-
BUTTONSTATUS update();
90+
BUTTONSUITE::BUTTONSTATUS update();
9191

9292
private:
9393
Bounce _debouncer;

src/ButtonEnums.h

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,29 @@
2828
#ifndef BUTTONENUMS_H
2929
#define BUTTONENUMS_H
3030

31-
// Button status.
32-
enum BUTTONSTATUS
31+
namespace BUTTONSUITE
3332
{
34-
// Was just pressed down (first call to "update" after the button was pressed).
35-
JUSTPRESSED,
36-
37-
// The button is being pressed and has been held lown shorter than the long press duration.
38-
ISSHORTPRESSED,
39-
40-
// The button was just released and the duration held down was considered short (less than long press duration).
41-
WASSHORTPRESSED,
42-
43-
// The button is being pressed and has been held down longer than the long press duration.
44-
ISLONGPRESSED,
45-
46-
// The button was just released and the duration held down was considered long (more than long press duration).
47-
WASLONGPRESSED,
48-
49-
// Button is not pressed/on.
50-
NOTPRESSED
51-
};
33+
// Button status.
34+
enum BUTTONSTATUS
35+
{
36+
// Was just pressed down (first call to "update" after the button was pressed).
37+
JUSTPRESSED,
38+
39+
// The button is being pressed and has been held lown shorter than the long press duration.
40+
ISSHORTPRESSED,
41+
42+
// The button was just released and the duration held down was considered short (less than long press duration).
43+
WASSHORTPRESSED,
44+
45+
// The button is being pressed and has been held down longer than the long press duration.
46+
ISLONGPRESSED,
47+
48+
// The button was just released and the duration held down was considered long (more than long press duration).
49+
WASLONGPRESSED,
50+
51+
// Button is not pressed/on.
52+
NOTPRESSED
53+
};
54+
}
5255

5356
#endif

src/CountingButton.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ int CountingButton::getCount()
4646
// Catch transitions from HIGH to LOW.
4747
switch (update())
4848
{
49-
case WASSHORTPRESSED:
49+
case BUTTONSUITE::WASSHORTPRESSED:
5050
{
5151
// Button was pushed, so increment counter.
5252
_count++;
5353
break;
5454
}
5555

56-
case WASLONGPRESSED:
56+
case BUTTONSUITE::WASLONGPRESSED:
5757
{
5858
// If the reset on long press mode is enabled, we reset, otherwise we treat
5959
// this as a regular buttom push.

src/CycleButton.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ int CycleButton::getValue()
8686
// Catch transitions from HIGH to LOW.
8787
switch (update())
8888
{
89-
case WASSHORTPRESSED:
89+
case BUTTONSUITE::WASSHORTPRESSED:
9090
{
9191
incrementValue();
9292
break;
9393
}
9494

95-
case WASLONGPRESSED:
95+
case BUTTONSUITE::WASLONGPRESSED:
9696
{
9797
// If the reset on long press mode is enabled, we reset, otherwise we treat
9898
// this as a regular buttom push.

src/LatchingButton.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ void LatchingButton::setDefaultState(bool latched)
5151
bool LatchingButton::pushed()
5252
{
5353
// Get the status.
54-
BUTTONSTATUS buttonStatus = update();
54+
BUTTONSUITE::BUTTONSTATUS buttonStatus = update();
5555

5656
switch (buttonStatus)
5757
{
58-
case WASSHORTPRESSED:
59-
case WASLONGPRESSED:
58+
case BUTTONSUITE::WASSHORTPRESSED:
59+
case BUTTONSUITE::WASLONGPRESSED:
6060
{
6161
// Toggle state.
6262
_latched = !_latched;

src/MomentaryButton.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ MomentaryButton::~MomentaryButton()
4141

4242
bool MomentaryButton::pushed()
4343
{
44-
BUTTONSTATUS buttonStatus = update();
44+
BUTTONSUITE::BUTTONSTATUS buttonStatus = update();
4545

46-
return buttonStatus == ISSHORTPRESSED || buttonStatus == ISLONGPRESSED;
46+
return buttonStatus == BUTTONSUITE::ISSHORTPRESSED || buttonStatus == BUTTONSUITE::ISLONGPRESSED;
4747
}

src/PushEventButton.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ void PushEventButton::setCaptureType(CAPTURETYPE captureType)
5353

5454
bool PushEventButton::pushed()
5555
{
56-
BUTTONSTATUS status = update();
56+
BUTTONSUITE::BUTTONSTATUS status = update();
5757

5858
switch (_captureType)
5959
{
6060
case CAPTUREPUSH:
6161
{
62-
if (status == JUSTPRESSED)
62+
if (status == BUTTONSUITE::JUSTPRESSED)
6363
{
6464
return true;
6565
}
@@ -71,7 +71,7 @@ bool PushEventButton::pushed()
7171

7272
case CAPTURERELEASE:
7373
{
74-
if (status == BUTTONSTATUS::WASSHORTPRESSED || status == BUTTONSTATUS::WASLONGPRESSED)
74+
if (status == BUTTONSUITE::BUTTONSTATUS::WASSHORTPRESSED || status == BUTTONSUITE::BUTTONSTATUS::WASLONGPRESSED)
7575
{
7676
return true;
7777
}

0 commit comments

Comments
 (0)