Giter Site home page Giter Site logo

Comments (4)

murphyzhao avatar murphyzhao commented on September 25, 2024

@orange2348 设计上,通过多次扫描才判断出一个按键事件,扫描间隙已经相当于消抖了,您可以测试下,谢谢

from flexiblebutton.

orange2348 avatar orange2348 commented on September 25, 2024

FLEX_BTN_PRESS_DOWN是BTN_IS_PRESSED(i)判断为真后就发出的事件,

case FLEX_BTN_STAGE_DEFAULT: /* stage: default(button up) */
            if (BTN_IS_PRESSED(i)) /* is pressed */
            {
                target->scan_cnt = 0;
                target->click_cnt = 0;

                EVENT_SET_AND_EXEC_CB(target, FLEX_BTN_PRESS_DOWN);

BTN_IS_PRESSED的宏定义如下:

#define BTN_IS_PRESSED(i) (g_btn_status_reg & (1 << i))

也就是g_btn_status_reg对应的按键位为真后,其就立即发出按键按下事件。
再向前推,g_btn_status_reg在调用flex_button_read后更新

    for(target = btn_head, i = button_cnt - 1;
        (target != NULL) && (target->usr_button_read != NULL);
        target = target->next, i--)
    {
        raw_data = raw_data | ((target->usr_button_read)(target) << i);
    }

    g_btn_status_reg = (~raw_data) ^ g_logic_level;

如果usr_button_read读取到误触发按键,g_btn_status_reg对应的位会被置位,从而导致触发事件。

其他的事件是多次扫描得出,但是这个FLEX_BTN_PRESS_DOWN比较特殊,应该是只需要扫描一次就可以得到,请确认下呢?

from flexiblebutton.

murphyzhao avatar murphyzhao commented on September 25, 2024

可以加一个自定义时间的按键消抖配置,方便在出现这样问题的时候进行适配。

后面我项目忙完了才有充足的时间考虑这个,如果您有好的改进策略,欢迎提交代码 😊 。

from flexiblebutton.

orange2348 avatar orange2348 commented on September 25, 2024

原有的代码里面已经有debounce_tick,但是功能没有实现,目前我是使用这个在检测按下事件前进行查询判断。

from flexiblebutton.

Related Issues (20)

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.