首页 > 解决方案 > Sense Hat - 检查时间操纵杆持有

问题描述

我对 python 并不陌生,但我不是 Sense Hat 的专业人士。

我想制作一个程序,如果我保持中间一段时间,就会发生一个动作。我知道我可以这样做:

if event.direction=="middle" and event.action=='held':
    time.sleep(5)
    if event.direction=="middle" and event.action=='held':
        # do action here

但这会使程序休眠。有没有更好(更清洁)的方法来做到这一点?

标签: pythonraspberry-pi

解决方案


推荐阅读