nodemcu gpio 中断不正常工作

我的 nodemcu 使用 Lua 固件。最近,当使用 gpio.trig() 获取脉冲信号时,我发现回调函数无法完全触发,总是会遗漏一些脉冲。有人能帮我吗?

测试程序:

sendPin=1
receivePin=2
gpio.mode(sendPin,gpio.OUTPUT)
gpio.mode(receivePin,gpio.INT,gpio.PULLUP)
gpio.trig(receivePin,"down",function(level,when,eventcount)
    print("level:"..level.." when:"..when.." eventcount:"..eventcount)
end)
gpio.serout(sendPin,0,{900,450},20,1)

程序输出:

level:0 when:177186 eventcount:5
level:0 when:184051 eventcount:3
level:0 when:188169 eventcount:3
level:0 when:192288 eventcount:4
level:0 when:197779 eventcount:3
level:0 when:201897 eventcount:1

输出应该有 20 行,但只有 5 行(可能多或少)!

点赞