Skip to content

BTN_STATE_REPEAT 状态疑问 #58

Description

@crazy3min
case BTN_STATE_REPEAT:
		if (handle->button_level != handle->active_level) {
			// Button released
			handle->event = (uint8_t)BTN_PRESS_UP;
			EVENT_CB(BTN_PRESS_UP);
			if (handle->ticks < SHORT_TICKS) {
				handle->ticks = 0;
				handle->state = BTN_STATE_RELEASE;  // Continue waiting for more presses
			} else {
				handle->state = BTN_STATE_IDLE;  // End of sequence
			}
		} else if (handle->ticks > SHORT_TICKS) {
			// Held down too long, treat as normal press
			handle->state = BTN_STATE_PRESS;
		}
		break;

重复按下,状态,按键重新释放,这个条件 if (handle->ticks < SHORT_TICKS) 是否多余?
要么按键持续按下超过 SHORT_TICKS 转换状态。要么在 SHORT_TICKS 内释放按键

请问是什么情况下需要处理这种情况?如果不处理是有异常?
handle->ticks == SHORT_TICKS)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions