Skip to content

tmr:start() does not restart started timer #3020

@532910

Description

@532910

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)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions