nodemcu-firmware: tmr:start() does not restart started timer
Expected behavior
https://nodemcu.readthedocs.io/en/master/modules/tmr/#tobjstart
says that tmr:start()
restarts timer. It’s not true:
Actual behavior
tmr:start()
will restart timer (start it count from zero)
Test code
> t = tmr.create()
> t:register( 3000, tmr.ALARM_SEMI, function( t ) print( 'alarm' ) end)
> t:start()
> -- wait 2 seconds
> t:start()
> -- alarm message will be printed 3 seconds after the first t:start() call, not the second one as expected.
Workaround
t:stop()
t:start()
NodeMCU startup banner
NodeMCU 3.0.1.0, build type: integer modules: file,gpio,net,node,rtctime,sntp,tmr,uart,wifi build 2020-01-27 17:39 powered by Lua 5.1.4 on SDK 3.0.2(824dc80)
Hardware
ESP8266 wemos D1 (not mini)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (13 by maintainers)
Commits related to this issue
- Implementing optional parameter `restart` to tmr:start() (issue #3020) - tmr:start([restart]) - removal of unecessary check of lua_newuserdata result in ads1115 module — committed to vsky279/nodemcu-firmware by deleted user 4 years ago
- Implementing optional parameter `restart` to tmr:start() (issue #3020) - tmr:start([restart]) - removal of unecessary check of lua_newuserdata result in ads1115 module — committed to vsky279/nodemcu-firmware by deleted user 4 years ago
- Implementing optional parameter `restart` to tmr:start() (issue #3020) - tmr:start([restart]) - removal of unecessary check of lua_newuserdata result in ads1115 module — committed to vsky279/nodemcu-firmware by deleted user 4 years ago
- Implementing optional parameter `restart` to tmr:start() (issue #3020) - tmr:start([restart]) - removal of unecessary check of lua_newuserdata result in ads1115 module — committed to vsky279/nodemcu-firmware by deleted user 4 years ago
- Implementing optional parameter `restart` to tmr:start() (issue #3020) — committed to vsky279/nodemcu-firmware by deleted user 4 years ago
- Implementing optional parameter `restart` to tmr:start() (issue #3020) — committed to vsky279/nodemcu-firmware by deleted user 4 years ago
- Implementing optional parameter `restart` to tmr:start() (issue #3020) — committed to vsky279/nodemcu-firmware by deleted user 4 years ago
- Implementing optional parameter `restart` to tmr:start() (issue #3020) — committed to vsky279/nodemcu-firmware by deleted user 4 years ago
you mean tmr.start, right?