<https://github.com/4refr0nt/luatool>`_ or via an existing telnet server
with file overlay (see below). See the readme in ``host/`` for more.
-Timer Queue
------------
-
-* ``tq/tq.lua`` -- a tickless event queue wrapping around a single nodemcu
- timer. Useful for managing complex lifecycles and/or many infrequent events.
- Enqueue events with ``:queue(time,function,args...)``; ``:queue`` returns
- a handle suitable for use with ``:dequeue()`` to unregister a pending
- future event. All ESP-specific behavior is overridable by replacing
- ``:now`` and ``:arm``. Use as ``tq = dofile("tq.lc")(timer)``.
-
-* ``tq/tq-diag.lua`` -- knows how to traverse a ``tq`` for diagnostic
- utility. Use as ``dofile("tq-diag.lc")(tq,print,print)``, e.g.
-
Networking Utilities
--------------------
chip through a reset cycle. See ``examples/lamp/init2.lua`` and
``examples/lamp/lamp-touch.lua`` for usage example.
-Completed Projects
-------------------
+Deprecated
+##########
+
+Timer Queue
+-----------
+
+.. warning::
+
+ Now that nodemcu supports dynamic timers, this is much less interesting
+ unless you imagine having periods of very large numbers of events
+ pending, as each referenced dynamic timer holds a slot in the lua
+ registry, which never shrinks from its maximum occupancy.
+
+ This module is still used within several modules here, however, for the
+ moment. Its removal and deprecation is being staged.
+
+* ``tq/tq.lua`` -- a tickless event queue wrapping around a single nodemcu
+ timer. Useful for managing complex lifecycles and/or many infrequent events.
+ Enqueue events with ``:queue(time,function,args...)``; ``:queue`` returns
+ a handle suitable for use with ``:dequeue()`` to unregister a pending
+ future event. All ESP-specific behavior is overridable by replacing
+ ``:now`` and ``:arm``. Use as ``tq = dofile("tq.lc")(timer)``.
+
+* ``tq/tq-diag.lua`` -- knows how to traverse a ``tq`` for diagnostic
+ utility. Use as ``dofile("tq-diag.lc")(tq,print,print)``, e.g.
+
-* ``examples/lamp`` -- a reimplementation of ``http://filimin.com/`` which
- speaks MQTT and uses the CAP1188 chip above and Adafruit's WS2812 RGB
- LEDs.
function self.heartbeat(m,topic,tq,period) -- set up lw&t and periodically heartbeat using tq until cancelled
m:lwt(topic,"dead",1,1)
local handle
- local function beat() mqc:publish(topic,"beat",1,1); handle = tq:queue(period, beat) end
+ local function beat() m:publish(topic,"beat",1,1); handle = tq:queue(period, beat) end
handle = tq:queue(period,beat)
return function() tq:dequeue(handle) end
end
-return function(tq, pin, addr, power, k)
+return function(pin, addr, power, k)
local function doread()
ow.reset(pin)
ow.select(pin, addr)
ow.reset(pin)
ow.select(pin, addr)
ow.write(pin, 0x44, power)
- tq:queue(1000,doread)
+ tmr.create():alarm(1000,tmr.ALARM_SINGLE,doread)
end