]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_lamp/commitdiff
Tidy emulation code
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Wed, 3 Jan 2018 01:15:51 +0000 (20:15 -0500)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Wed, 3 Jan 2018 01:15:51 +0000 (20:15 -0500)
Several changes to catch up to past changes for consistency.
Add tmr.interval function for increased coverage of API, will be
used in upcoming commits.

linux-draw-morse.lua
linux-draw-xpm.lua
linux-draw.lua

index 62a7981724857cd9742a3a1d45a8386a7b7194b5..f23fb1d8810fa6317319d8907e03840bef3b8c0d 100644 (file)
@@ -30,5 +30,3 @@ function loaddrawfn(name)
      end)
   end
 end
-
-function doremotedraw() end
index 96ed161a65e0f17e76450bc3750badaf0d89783b..7a0bce32a70cdec9de1e1b312e93ce22edb74c2f 100644 (file)
@@ -52,12 +52,12 @@ function remotefb.shift(self,n,m,i,j)
   end
 end
 
-local function drawfailsafe(t,fb,g,r,b) fb:fill(0,0,0) end
+local function drawfailsafe(t,fb,p) fb:fill(0,0,0) end
 function loaddrawfn(name)
   local f = loadfile (string.format("draw-%s.lua",name))
   local fn = f and f()
   if fn
-   then return function(t,fb,g,r,b) fn(t,fb,g,r,b) end
+   then return function(t,fb,p) return fn(t,fb,p) end
    else return drawfailsafe
   end
 end
@@ -108,4 +108,3 @@ function dodraw()
   io.write("\n\n") -- XXX? WTF?
   io.flush()
 end
-doremotedraw = function() remotetmr:start(); dodraw() end
index f5463c8a12fc501b1aee02de4401f36a2db1f0eb..7e926e097ea8e09b9ed7cab62224fc435149b95f 100644 (file)
@@ -70,6 +70,11 @@ function tmr.alarm(self,period,mode,fn)
   tmr.register(self,period,mode,fn)
   tmr.start(self)
 end
+function tmr.interval(self, period)
+  self.period = period
+  if self.tqe == nil then return end -- just update interval
+  self:start() -- otherwise, re-schedule
+end
 tmr_mt = { __index = tmr }
 function tmr.create()
   return setmetatable({}, tmr_mt)