Comments (4)
@orange2348 设计上,通过多次扫描才判断出一个按键事件,扫描间隙已经相当于消抖了,您可以测试下,谢谢
from flexiblebutton.
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.
可以加一个自定义时间的按键消抖配置,方便在出现这样问题的时候进行适配。
后面我项目忙完了才有充足的时间考虑这个,如果您有好的改进策略,欢迎提交代码 😊 。
from flexiblebutton.
原有的代码里面已经有debounce_tick,但是功能没有实现,目前我是使用这个在检测按下事件前进行查询判断。
from flexiblebutton.
Related Issues (20)
- 能否支持3连击 按键? HOT 6
- 触摸按键 HOT 12
- 中断方式检测按键 HOT 2
- 关于按键ID HOT 4
- 有计划加入滑式按键吗? HOT 1
- 可不可自定义某个按键是否需要:长按,双击等功能? HOT 1
- 注册按键数量问题 HOT 1
- 有考虑过 flex_button_register 和 button_scan 线程安全 HOT 3
- 长按事件的组合按键问题 HOT 4
- 同时按住四个按键出现卡顿并无法正常回调?
- 请问一下按键事件回调函数和用户注册时的ID是相反的是什么原因,我有4个按键,注册时是按0、1、2、3分配的ID,但是在事件回调中是相反的顺序,比如说我注册的时候ID是0,但是在事件回调函数里面打印的按键ID是3 HOT 2
- 非常不合理的设计:短按事件和长按事件相关联 HOT 2
- flexible_button.h中的值是否需要与flex_button_scan()轮询调用的时间间隔保持一致? HOT 1
- flexible_button.c中的全局变量g_logic_level和g_btn_status_reg为何不用static修饰?
- 这里超过16个按键这个左移不就溢出了吗
- 按键处理数量限制 HOT 1
- 建议把状态用枚举值来代替,方便理解
- 关于按键连续触发事件 HOT 4
- 有没有在没有os的51单片机使用这个函数库的例子 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flexiblebutton.