powerKey

powerKey

模块功能:开机键功能配置

powerKey.setup(longPrd, longCb, shortCb)

配置开机键长按弹起和短按弹起的功能.

如何定义长按键和短按键,例如长按键判断时长为3秒:按下大于等于3秒再弹起判定为长按键;按下后,在3秒内弹起,判定为短按键

  • 参数

传入值类型

释义

number

可选参数,默 认为``3000``,longPrd,长按键判断时长,单位毫秒

function

可选参数,默认为``nil``,longCb,长按弹起时 的回调函数,如果为nil,使用默认的处理函数,会自动关机

function

可选参 数,默认为``nil``,shortCb,短按弹起时的回调函数

  • 返回值

nil

  • 例子

powerKey.setup(nil,longCb,shortCb)
powerKey.setup(5000,longCb)
powerKey.setup()
长按powerkey键3秒以上弹起,执行关机操作:powerKey.setup(3000, function() rtos.poweroff() end)