Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

问题反馈 & 优化建议 #1

Open
murphyzhao opened this issue Oct 23, 2018 · 9 comments
Open

问题反馈 & 优化建议 #1

murphyzhao opened this issue Oct 23, 2018 · 9 comments

Comments

@murphyzhao
Copy link
Owner

No description provided.

@Linjieqiang
Copy link

低功耗按键的思路应该如何呢?是不是需要设置中断模式

@murphyzhao
Copy link
Owner Author

这个按键库主要是实现按键扫描和按键事件产生的底层代码,定时扫描的工作放到了应用层去完成,因此应用层有完全的设计灵活度。因此,低功耗处理不在这个按键代码中做处理,而是交给应用层。

可行的处理方式,可以如您所说的,增加中断模式,但并不是将该模式放到这个按键库的实现里,而是放到应用层。

我的想法是应用层可以在进入低功耗前,挂起按键扫描;按键唤醒或者其他机制唤醒系统后,再启动按键扫描。目前我也是这么处理的,使用方式略 low。:sweat_smile:

@Linjieqiang
Copy link

明白了,谢谢。你的库我刚在用,感觉不错。

@murphyzhao
Copy link
Owner Author

感谢支持(●'◡'●)

@rockjg0917
Copy link

能否支持组合按键?

@murphyzhao
Copy link
Owner Author

能否支持组合按键?

@rockjg0917 这个库仅做底层的按键扫描处理,如果需要支持组合按键,请再封一层,根据按键库返回的事件分装需要的组合按键,希望可以帮到您,谢谢。

@rockjg0917
Copy link

@zhaojuntao 明白,谢谢!

@leida3669
Copy link

有个问题,我有4个按键,使用1个按键,不会出错,要是大于1个,那么只会最大标号一个有效,不知道这是不是一个Bug,硬件应该没有问题,有问题的话,1个按键也不行吧。
for (i = 0; i < 4; i ++)
{
user_button[i].id = i;
user_button[i].usr_button_read = common_btn_read;
user_button[i].cb = common_btn0_evt_cb;
user_button[i].pressed_logic_level = 0;
user_button[i].short_press_start_tick = FLEX_MS_TO_SCAN_CNT(1500);
user_button[i].long_press_start_tick = FLEX_MS_TO_SCAN_CNT(3000);
user_button[i].long_hold_start_tick = FLEX_MS_TO_SCAN_CNT(4500);
flex_button_register(&user_button[i]);
}
串口打印信息:
id: [1 - USER_BUTTON_1] event: [0 - FLEX_BTN_PRESS_DOWN] repeat: 0
id: [1 - USER_BUTTON_1] event: [4 - FLEX_BTN_PRESS_SHORT_START] repeat: 0
id: [1 - USER_BUTTON_1] event: [6 - FLEX_BTN_PRESS_LONG_START] repeat: 0
id: [1 - USER_BUTTON_1] event: [8 - FLEX_BTN_PRESS_LONG_HOLD] repeat: 0
后续这个按键就没有反应了。

@murphyzhao
Copy link
Owner Author

有个问题,我有4个按键,使用1个按键,不会出错,要是大于1个,那么只会最大标号一个有效,不知道这是不是一个Bug,硬件应该没有问题,有问题的话,1个按键也不行吧。
for (i = 0; i < 4; i ++)
{
user_button[i].id = i;
user_button[i].usr_button_read = common_btn_read;
user_button[i].cb = common_btn0_evt_cb;
user_button[i].pressed_logic_level = 0;
user_button[i].short_press_start_tick = FLEX_MS_TO_SCAN_CNT(1500);
user_button[i].long_press_start_tick = FLEX_MS_TO_SCAN_CNT(3000);
user_button[i].long_hold_start_tick = FLEX_MS_TO_SCAN_CNT(4500);
flex_button_register(&user_button[i]);
}
串口打印信息:
id: [1 - USER_BUTTON_1] event: [0 - FLEX_BTN_PRESS_DOWN] repeat: 0
id: [1 - USER_BUTTON_1] event: [4 - FLEX_BTN_PRESS_SHORT_START] repeat: 0
id: [1 - USER_BUTTON_1] event: [6 - FLEX_BTN_PRESS_LONG_START] repeat: 0
id: [1 - USER_BUTTON_1] event: [8 - FLEX_BTN_PRESS_LONG_HOLD] repeat: 0
后续这个按键就没有反应了。

建议找个 IoT Board 板子,跑跑提供的示例程序。代码总共没几行,参数也没有多少,相信你可以搞定。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@Linjieqiang @murphyzhao @leida3669 @rockjg0917 and others