找回密码
 立即注册

微信扫码登录

查看: 179|回复: 8

关于添加多个按键

[复制链接]

18

主题

40

回帖

190

积分

荣耀黄金

积分
190
发表于 2024-12-2 18:39:08 | 显示全部楼层 |阅读模式
image.png

image.png
image.png
我添加多个按键如上图,但是打印出的keycode,一直只有1,2,3三个值,而且松开是3这是为啥呢?只有1,2两个按键能用

11

主题

31

回帖

219

积分

华贵铂金

积分
219
发表于 2024-12-3 04:18:28 | 显示全部楼层
本帖最后由 wes58 于 2024-12-3 04:26 编辑

And I assume that you also have this in user_init():
drv_pm_wakeupPinConfig(g_sensorPmCfg, sizeof(g_sensorPmCfg)/sizeof(drv_pm_pinCfg_t));
I have 8 buttons defined this way and it has been working fine.

18

主题

40

回帖

190

积分

荣耀黄金

积分
190
 楼主| 发表于 2024-12-4 08:34:59 | 显示全部楼层
wes58 发表于 2024-12-3 04:18
And I assume that you also have this in user_init():
drv_pm_wakeupPinConfig(g_sensorPmCfg, sizeof(g_ ...

I also drv_pm_wakeupPinConfig(g_sensorPmCfg, sizeof(g_sensorPmCfg)/sizeof(drv_pm_pinCfg_t));
but my button can't used.

18

主题

40

回帖

190

积分

荣耀黄金

积分
190
 楼主| 发表于 2024-12-4 09:08:30 | 显示全部楼层
wes58 发表于 2024-12-3 04:18
And I assume that you also have this in user_init():
drv_pm_wakeupPinConfig(g_sensorPmCfg, sizeof(g_ ...

the keyCode just only printf :1 2 3;
1204.png

11

主题

31

回帖

219

积分

华贵铂金

积分
219
发表于 2024-12-4 12:53:33 | 显示全部楼层
wx_8236422632 发表于 2024-12-4 09:08
the keyCode just only printf :1 2 3;

You could try to disable PM so device doesn't go to sleep in app_cfg.h. This way you can also monitor variables.
/* PM */
#define PM_ENABLE                                                0
and see if it works then.
You could also add Led's to see if pressing the buttons works, or add some variables and check in BDT. You could add the code below (I only show for one button) in app_ui.c and see the variable btnstate when you press and hold a button.

u8 btnstate[8] = {0};
void app_key_handler(void){
        if(0 == drv_gpio_read(GPIO_PB4)){
                btnstate[4] = 1;
                led_on(LED1);
        }
        else{
                btnstate[4] = 1;
                led_off(LED1);
        }
        
'''' add for all buttons        
}

18

主题

40

回帖

190

积分

荣耀黄金

积分
190
 楼主| 发表于 2024-12-4 13:17:20 | 显示全部楼层
wes58 发表于 2024-12-4 12:53
You could try to disable PM so device doesn't go to sleep in app_cfg.h. This way you can also monit ...

Thanks, I will rewrite it according to your method. Here is how it is written in the Demo
120402.png

11

主题

31

回帖

219

积分

华贵铂金

积分
219
发表于 2024-12-4 13:27:30 | 显示全部楼层
wx_8236422632 发表于 2024-12-4 13:17
Thanks, I will rewrite it according to your method. Here is how it is written in the Demo

You don't have to re-write.
Leave existing code as it is. But for your testing just add at the beginning of the function what I posted.This is just for testing. For working app you will need some button debouncing code..

By the way, you should use code tags "<>" when you post the code. This way someone can easily copy your code

18

主题

40

回帖

190

积分

荣耀黄金

积分
190
 楼主| 发表于 2024-12-4 14:17:48 | 显示全部楼层
wes58 发表于 2024-12-4 13:27
You don't have to re-write.
Leave existing code as it is. But for your testing just add at the be ...

OK,thanks
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Telink forum ( 沪ICP备17008231号-1 )

GMT+8, 2024-12-22 02:38 , Processed in 0.109994 second(s), 25 queries .

Powered by Telink 隐私政策

泰凌微电子版权所有 © 。保留所有权利。 2024

快速回复 返回顶部 返回列表