This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

"Button.c" driver Button_LONGPRESSING state

The code in the button.c driver seems strange.

There is not a break before the "default" case. So it looks like state Button_LONGPRESSING  is always owerwriten with Button_PRESSED.

Also the obj->buttonStateVariables.state = Button_LONGPRESSING is used twice, but anyway it is owerwriten.

            case Button_RELEASING:
            case Button_RELEASING_LONG:
            case Button_RELEASING_DBLPRESSED:
            /*
            * We're releasing, but isn't released after debounce.
            * Start count down again if interest in long-press
            */
            if(obj->buttonEventMask &
               (Button_EV_LONGPRESSED | Button_EV_LONGCLICKED))
            {
                obj->buttonStateVariables.state = Button_LONGPRESSING;
                ClockP_setTimeout(obj->clockHandle, obj->longPressDuration - obj->debounceDuration);
                ClockP_start(obj->clockHandle);
                obj->buttonStateVariables.state = Button_LONGPRESSING;
            }
            else
            {
                obj->buttonStateVariables.state = Button_PRESSED;
            }

            /*
             * Any other case, mark the button as pressed.
             * Typically we should not come here
             */
            default:
                 obj->buttonStateVariables.state = Button_PRESSED;
                 break;