button.c 驱动程序中的代码看起来很奇怪。
"默认"情况之前没有休息时间。 因此、看起来状态 button_LONGPRESSING 始终是使用 button_pressed 写入的。
此外,obj->buttonStateVariables.state = button_LONGPRESSING 使用两次,但无论如何它是 writeren。
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;