完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
Hai
我尝试使用CasSyp在每个触摸上增加一个变量(Cy8CKIT-1001)。对于每个触摸,S必须递增一个。我只是修改并使用了示例程序“CasnSexCCS-I设计”。 Car S;if(CopShansCddCaseWistGeActuple(CopsSeNeScDyButOn0xBTN)){CyTele:(2000);S++;LCDX位置(0U,5U);LCDA Primtin 16(s);}我注意到对于每个触摸,IF环***作TWISE,它增加变量S TWISE。我希望每个触摸只执行一次“IF”循环。你能告诉我怎么做吗?凯文 以上来自于百度翻译 以下为原文 Hai, I am tring to use capsense to increment a variable (s) (CY8CKIT-001) on each touch. For each touch the s has to incremented one. I just altered and used the example program "Capsense_CSD _Design". char s; if (CapSense_CSD_CheckIsWidgetActive(CapSense_CSD_BUTTON0__BTN)) { CyDelay(2000); s++; LCD_Position(0u, 5u); LCD_PrintInt16(s); } I noticed that the if loop is operated twise for for each touch which increments the variable s twise. I want the 'if 'loop to be executed only once for each touch. can you sugguest me how? reagrds kavin |
|
相关推荐
10个回答
|
|
只需记住前一个状态的CAPSENSE按钮,并只增加您的计数器时,它从“未按下”到“按下”。
以上来自于百度翻译 以下为原文 Just remember the previous state of the CapSense button, and only increase your counter when it changes from 'not pressed' to pressed'. |
|
|
|
要添加到HLI的建议中,如果您基本上检测到按钮,
然后,您还需要检测其释放,然后更新显示,以及S. You。 试图通过拖延长时间来做到这一点,这是浪费CPU MIPS和 约束程序的其余部分用于其他处理。 所以检测下来,然后释放,然后Inc S,更新显示。或者如果你想要 按住按钮的按钮持续保持按钮,或按钮结束后执行。 被压缩了一些时间。这种方法用于增加更新。 速率越长按钮越低,使按钮多功能。 问候,Dana。 以上来自于百度翻译 以下为原文 To add to Hli's recommendation, if you basically detect a button down, then you also need to detect its release, then update display, and S. You tried to do this by intoducing long delay, which is a waste of CPU MIPs and constrains the rest of the program for other processing. So detect down, then release, then inc S, update display. Or if you want a button that is held down continuously keep incing S, or do so after button has been pressed for some minimum time. This approach used to increase update rate the longer a button down, makes button multi functional. Regards, Dana. |
|
|
|
|
|
|
|
谁是“老板”?
添加我的2个CT: 我通常喜欢一个简单的状态机来跟踪所需的不同状态。 -没有按钮按下 按钮按压 -按钮按-500毫秒(或任何其他时间) 按钮释放 以及每个状态内的事件将转到另一个状态。 为了使事情变得更复杂,你可以设置一个定时器,以中等速率中断(10~50Hz),检查定时器在定时器到期时释放大量MIPS,但仍然保持系统的反应性,另外还有机会测量按下按钮的时间(或者没有什么)。发生) 鲍勃 以上来自于百度翻译 以下为原文 Who is the "Boss" ? To add my 2 ct: I usually prefer a (simple) state-machine that keeps track of the required different states -no button pressed -button pressed -button pressed for > 500ms (or any other time) -button released and the event(s) within each state that will go to another state. To make things more complicate, you can setup a timer that interrupts at a medium rate (10 - 50Hz) and check the button when Timer expires only Frees a lot of MIPS but still maintains reactivity of the system and additionally has the opportunity to measure the time a button is pressed (or nothing did happen) Bob |
|
|
|
我想在“按钮释放”状态下,你真正的意思是“按钮释放事件”,在“按下按钮”和“没有按钮按下”状态之间。至少这就是我将如何实现它…
以上来自于百度翻译 以下为原文 I guess with the 'button released' state you really mean the 'butten released event', which is between the 'button pressed' and the 'no button pressed' states? At least thats how I would implement it... |
|
|
|
可能是语言问题:
按钮释放状态是按钮按下状态和无按钮按下状态之间的状态,用于具有类似阿德弹跳的东西。 鲍勃 以上来自于百度翻译 以下为原文 Probably a language problem: The button released state is a state between the button pressed state and the no button pressed state and is used to have something like a de-bouncing. Bob |
|
|
|
哦,我没想到用它来打鼓(但是你需要一些类似的按钮,对吧?)但我认为这不是卡彭斯需要的,它不应该有弹跳…
HLI 以上来自于百度翻译 以下为原文 Oh, I didn't think of using it for debouncing (but then you would need something similar for pressing the button, right?). But I think this isn't needed for CapSense, it should not have bouncing... hli |
|
|
|
实际上,我需要为每个按键增加变量's'。现在我把递增业务转移到其他括号,即按键后释放的按钮。
Car S,S1; LCDI位置(1U,0U); 如果(CopShansCddCaseWistGeActuple(CopsSeNeCSdButoNo0xBTN)) {s=1;/按钮按下 } 否则{ 如果(s=1){s1++;//按钮释放 LCDI位置(1U,1U); LCDApReltIt16(S1);} S=0; 可以吗? 今天猪哥 以上来自于百度翻译 以下为原文 Actually I need to increment the variable ‘s’ for each key press. Now I shifted the incrementing business to else braces, ie button released after a key press. char s,s1; LCD_Position(1u, 0u); if (CapSense_CSD_CheckIsWidgetActive(CapSense_CSD_BUTTON0__BTN)) {s=1; // button pressed } else{ if(s==1){s1++; // button released LCD_Position(1u, 1u); LCD_PrintInt16(s1);} s=0;} is it OK. Kavin |
|
|
|
是的,凯文,看起来不错。但是你应该初始化S1。
顺便说一下,使用反映变量含义的变量的名称总是明智的。所以我称之为“S1”“预设计数器”和“S”按钮,或者类似的东西。这提高了可读性,并可以帮助其他人(我们)了解正在发生什么甚至检测到bug。 鲍勃 以上来自于百度翻译 以下为原文 Yes Kevin, that looks good. But you ought to initialize s1. By the way: It is ALWAYS advisable to use names for variables that reflect the meaning. So I would call "s1" "PressedCounter" and "s" "ButtonWasPressed" or something similar. This improves readability and can help others (us) to understand what is going on or even detect a bug. Bob |
|
|
|
哦,我只看到:
你把S1定义为一个固定的字符,但是它在LCD上显示一个需要16位整数的例程。我建议使用S1一个无符号int。 鲍勃 以上来自于百度翻译 以下为原文 Oh, I just see: You defined s1 as a aigned char, but display it on LCD with a routine that requires a 16-bit integerr. I would suggest to use for s1 an unsigned int. Bob |
|
|
|
只有小组成员才能发言,加入小组>>
752个成员聚集在这个小组
加入小组2071 浏览 1 评论
1827 浏览 1 评论
3642 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1762 浏览 6 评论
1513 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
511浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
362浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
410浏览 2评论
357浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
860浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 05:18 , Processed in 1.237663 second(s), Total 97, Slave 80 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号