|
@@ -1,4 +1,11 @@
|
|
|
|
|
|
+const unsigned int buttonMaxClickTime = 500;
|
|
|
+const unsigned int buttonMaxClickTime_2 = 350; // actual max time a button may be pressed to get detected as short press/click
|
|
|
+const unsigned int buttonDebounceTime = 50;
|
|
|
+const unsigned int buttonRepeatTime = 50;
|
|
|
+const unsigned int buttonHoldTime = 50;
|
|
|
+const unsigned int buttonRepeatTime_menuButton = 1000;
|
|
|
+
|
|
|
// Use this function to configure the internal Bounce object to suit you. See the documentation at: https://github.com/thomasfredericks/Bounce2/wiki
|
|
|
// This function can be left out if the defaults are acceptable - just don't call configureButton
|
|
|
void configurePushButton(Bounce &bouncedButton)
|
|
@@ -12,19 +19,19 @@ void setupInputsButtons()
|
|
|
//pinMode(PIN_PIRSENSOR, INPUT);
|
|
|
buttonPlus.configureButton(configurePushButton);
|
|
|
//buttonPlus.onPress(onButtonPressed); // When the button is first pressed, call the function onButtonPressed (further down the page)
|
|
|
- buttonPlus.onHoldRepeat(1000, 350, onButtonHeld); // Once the button has been held for 1 second (1000ms) call onButtonHeld. Call it again every 350ms until it is let go
|
|
|
- buttonPlus.onRelease(50, 500, onButtonReleased); // When the button is held >50ms and released after <500ms, call onButtonReleased
|
|
|
+ buttonPlus.onHoldRepeat(buttonHoldTime, buttonRepeatTime, onButtonHeld); // Once the button has been held for 1 second (1000ms) call onButtonHeld. Call it again every 350ms until it is let go
|
|
|
+ buttonPlus.onRelease(buttonDebounceTime, buttonMaxClickTime, onButtonReleased); // When the button is held >50ms and released after <500ms, call onButtonReleased
|
|
|
|
|
|
buttonMinus.configureButton(configurePushButton);
|
|
|
//buttonMinus.onPress(onButtonPressed); // When the button is first pressed, call the function onButtonPressed (further down the page)
|
|
|
- buttonMinus.onHoldRepeat(1000, 350, onButtonHeld); // Once the button has been held for 1 second (1000ms) call onButtonHeld. Call it again every 350ms until it is let go
|
|
|
- buttonMinus.onRelease(50, 500, onButtonReleased); // When the button is held >50ms and released after <500ms, call onButtonReleased
|
|
|
+ buttonMinus.onHoldRepeat(buttonHoldTime, buttonRepeatTime, onButtonHeld); // Once the button has been held for 1 second (1000ms) call onButtonHeld. Call it again every 350ms until it is let go
|
|
|
+ buttonMinus.onRelease(buttonDebounceTime, buttonMaxClickTime, onButtonReleased); // When the button is held >50ms and released after <500ms, call onButtonReleased
|
|
|
|
|
|
buttonMode.configureButton(configurePushButton);
|
|
|
//buttonMode.onPress(onButtonPressed); // When the button is first pressed, call the function onButtonPressed (further down the page)
|
|
|
//buttonMode.onHold(1000, onButtonHeldNoRepeat); // Once the button has been held for 1 second (1000ms) call onButtonHeld
|
|
|
- buttonMode.onHoldRepeat(1000, 1000, onButtonHeld); // Once the button has been held for 1 second (1000ms) call onButtonHeld
|
|
|
- buttonMode.onRelease(50, 500, onButtonReleased); // When the button is held >50ms and released after <500ms, call onButtonReleased
|
|
|
+ buttonMode.onHoldRepeat(buttonHoldTime, buttonRepeatTime_menuButton, onButtonHeld); // Once the button has been held for 1 second (1000ms) call onButtonHeld
|
|
|
+ buttonMode.onRelease(buttonDebounceTime, buttonMaxClickTime, onButtonReleased); // When the button is held >50ms and released after <500ms, call onButtonReleased
|
|
|
|
|
|
pirSensor.configureButton(configurePushButton);
|
|
|
//pirSensor.onPress(onButtonPressed); // When the button is first pressed, call the function onButtonPressed (further down the page)
|
|
@@ -80,15 +87,15 @@ void onButtonHeldNoRepeat(Button &btn, uint16_t duration)
|
|
|
// duration reports back the total time that the button was held down
|
|
|
void onButtonReleased(Button &btn, uint16_t duration)
|
|
|
{
|
|
|
- if (btn.is(buttonPlus) && duration < 200)
|
|
|
+ if (btn.is(buttonPlus) && duration < buttonMaxClickTime_2)
|
|
|
{
|
|
|
plusButtonAction();
|
|
|
}
|
|
|
- else if (btn.is(buttonMinus) && duration < 200)
|
|
|
+ else if (btn.is(buttonMinus) && duration < buttonMaxClickTime_2)
|
|
|
{
|
|
|
minusButtonAction();
|
|
|
}
|
|
|
- else if (btn.is(buttonMode) && duration < 200)
|
|
|
+ else if (btn.is(buttonMode) && duration < buttonMaxClickTime_2)
|
|
|
{
|
|
|
modeButtonAction();
|
|
|
}
|