Coder Social home page Coder Social logo

bug 注意!!!!!!按钮多次抖动导致无法进入 长按回调函数解决方法!!!!!!!!! about multibutton HOT 7 CLOSED

liu2guang avatar liu2guang commented on July 24, 2024
bug 注意!!!!!!按钮多次抖动导致无法进入 长按回调函数解决方法!!!!!!!!!

from multibutton.

Comments (7)

Jackistang avatar Jackistang commented on July 24, 2024 1
  • 直接切换成状态5会丢失一个 LONG_PRESS_START 事件。
  • 切换成状态 0 或状态 1 则不会,不过需要再过 LONG_TICKS 才能检测到长按事件。这是可以理解的,因为在连击之后突然长按按键,也是需要 LONG_TICKS 个时间之后才能触发长按事件。

from multibutton.

SSEHX avatar SSEHX commented on July 24, 2024

else if(handle->ticks > SHORT_TICKS){
handle->state = 0;
}

添加成这个

from multibutton.

idfulin avatar idfulin commented on July 24, 2024

image
此处应该还有一个状态切换,对应代码应该修改下面部分
image

下面是我的建议,供参考
case 3:
if(handle->button_level != handle->active_level)
{
handle->event = (uint8_t)PRESS_UP;
EVENT_CB(PRESS_UP);

        if(handle->ticks < SHORT_TICKS)
        {
            handle->ticks = 0;
            handle->state = 2;
        }
        else
        {
            handle->state = 0;
        }
    }
    else if (handle->ticks > LONG_TICKS)
    {
        handle->state = 5;
    }
    break;

from multibutton.

mysterywolf avatar mysterywolf commented on July 24, 2024

@idfulin 你好 这里还有一个和你差不多的代码,他建议是回到0,你觉得回到哪个比较好呢?
0x1abin/MultiButton#15 (comment)

from multibutton.

mysterywolf avatar mysterywolf commented on July 24, 2024

@Jackistang 明白了 handle->ticks > LONG_TICKS 还是 handle->ticks > SHORT_TICKS比较好?

from multibutton.

mysterywolf avatar mysterywolf commented on July 24, 2024

@Jackistang #5 我提了一个pr, 要不你来提也行。

from multibutton.

Jackistang avatar Jackistang commented on July 24, 2024

如果切换成状态0或者1的话,建议是 SHORT_TICKS,因为状态 3 经过 SHORT_TICKS 后仍检测到按键按下,这时已有的两个扇出就失效了,可以直接转换状态了。
你可以改改你的 pr,

from multibutton.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.