Single Button Multiple Functions

Hello forum,
I have write a program in which a tactical switch is used for device ON and OFF.
On long pressed (300uSec) device will get ON from deep Sleep and goes into the deep sleep same button for (1.5Sec). In this case my device get immediately gets on/OFF means its toggle continuously .So,I want it should work like mobile phone(when on long pressed mobile get turned on and to turn off we need to press it again after releasing it.)

I want a second functionality with same button is to be in a mode where i can select the other functionality available in device like it should go in configuration mode where it have different function call like connect to WiFi, connect to Bluetooth etc. using that single button it moves forward like we have it in some digital watch where we can select multiple functions using single button.

BUTTON

LONG PRESS 35 MILLISEC___> DEVICE GET ON

LONG PRESS 1.5SEC___> DEVICE GET OFF

ON DOUBLE TAP >>> IT ENTERS IN CONFIGUIRATION MODE

{
1> SCAN WIFI
2>CONNECT TO WIFI
3>SCAN BLUETOOTH DEVICE
4>CONNECT TO BLE DEVICE
}

AFTER DOUBLE TAP IT SHOULD MOVE TO 4 FUNCTIONALITY BUT BY PRESSING BUTTON IT SHOULD MOVES OR INCREMENT ONE AFTER ONE

Please check my code in attachment, and please guide me accordingly.
Please understand my mistakes.

MAIN_2click_wakeup.ino (5.44 KB)

This library does the work for you. You can configure it like this:

  // If your button is connected such that pressing it generates a high signal on the pin, you need to
  // specify that it is "active high"
  myButton.activeHigh();

  // If your button is connected such that pressing it generates a low signal on the pin, you can specify
  // that it is "active low", or don't bother, since this is the default setting anyway.
  myButton.activeLow();

  // By default, the raw signal on the input pin has a 35ms debounce applied to it.  You can change the
  // debounce time if necessary.
  myButton.debounceTime(15); //apply 15ms debounce

  // The double-tap detection window is set to 150ms by default.  Decreasing this value will result in
  // more responsive single-tap events, but requires really fast tapping to trigger a double-tap event.
  // Increasing this value will allow slower taps to still trigger a double-tap event, but will make
  // single-tap events more laggy, and can cause taps that were meant to be separate to be treated as
  // double-taps.  The necessary timing really depends on your use case, but I have found 150ms to be a
  // reasonable starting point.  If you need to change the double-tap detection window, you can do so
  // as follows:
  myButton.doubleTapTime(250); // set double-tap detection window to 250ms
  
  // The hold duration can be increased to require longer holds before an event is triggered, or reduced to
  // have hold events trigger more quickly.
  myButton.holdTime(2000); // require button to be held for 2000ms before triggering a hold event

Then the detection is made like this:

    // The event() method returns tap, doubleTap, hold or none depending on which event was detected
    // the last time the update() method was called.  The following code accomplishes the same thing
    // we did in the 'Basic' example, but I personally prefer this arrangement.
    switch(myButton.event()) {
      
      // things to do if the button was tapped (single tap)
      case (tap) : {
        Serial.println("TAP event detected");          
        break;
      }

      // things to do if the button was double-tapped
      case (doubleTap) : {
        Serial.println("DOUBLE-TAP event detected");
        break;
      }
   
      // things to do if the button was held
      case (hold) : {
        Serial.println("HOLD event detected");
        break;
      }