]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_core/commitdiff
Begin deprecation of tq in favor of dyn. tmr API
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sat, 5 Aug 2017 08:29:01 +0000 (04:29 -0400)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sat, 5 Aug 2017 08:29:01 +0000 (04:29 -0400)
README.rst
net/nwfmqtt.lua
net/nwfnet-sntp.lua
util/ow-ds18b20.lua

index 08d09531ca811bc1101d183df6b7617fbf5e85e9..19619d5112d58c8243ba6f524b58ab92a9a36799 100644 (file)
@@ -34,19 +34,6 @@ Generic Utilities
   <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
 --------------------
@@ -95,9 +82,30 @@ cap1188 driver
   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.
index 1eeec9526171345e86c17d810f48ae5ebde2b288..7e67859cfa359066089e734f2a976a9e46a0fb33 100644 (file)
@@ -40,7 +40,7 @@ end
 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
index a3373015ed890be97eb668bc54ccb38aa995e2c3..ee5b0c700593163eab7e3daa2409f821cf10f95d 100644 (file)
@@ -19,13 +19,6 @@ local function dosntp(server)
   )
 end
 
--- XXX deprecated in favor of new cron upstream module
-local function loopsntp(tq,period,server)
-  local function f() dosntp(server); tq:queue(period,f) end
-  tq:queue(period,f)
-end
-
 local self = {}
 self.dosntp = dosntp
-self.loopsntp = loopsntp
 return self
index 85b16138abbec9b5aaf203b783b15ef40da7504c..d4def6b151bcaf85df896b3fa9bba1ac39b1a2e4 100644 (file)
@@ -1,4 +1,4 @@
-return function(tq, pin, addr, power, k)
+return function(pin, addr, power, k)
  local function doread()
   ow.reset(pin)
   ow.select(pin, addr)
@@ -16,5 +16,5 @@ return function(tq, pin, addr, power, k)
  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