From: Nathaniel Wesley Filardo Date: Sun, 8 Apr 2018 09:59:17 +0000 (+0100) Subject: linux-draw-morse: catch up X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=222792f280e10b50f6fb50e26fe71ad50bf65ece;p=acmetensortoys-esp-lua_lamp linux-draw-morse: catch up --- diff --git a/linux-draw-morse.lua b/linux-draw-morse.lua index f23fb1d..d1d5438 100644 --- a/linux-draw-morse.lua +++ b/linux-draw-morse.lua @@ -1,32 +1,38 @@ -package.loaded["morse"] = dofile("morse/morse") +package.loaded["morse"] = dofile("../core/morse/morse.lua") local dit = 500 -- milliseconds +function dodraw() end + function loaddrawfn(name) local m = (require"morse")(name) printerr(name) - return function (t,_,g,r,b) + return function (t,_,p) + local g = p[1]:byte(1) + local r = p[1]:byte(2) + local b = p[1]:byte(3) local function onf() - print(string.format("%x %x %x",r,g,b)) + print(string.format("%x %x %x",r,g,b)) end local function offf() print("0 0 0") end local function morsecb(dur,on) if on then onf() else offf() end - t:register(dur*250,tmr.ALARM_SINGLE,function() + t:alarm(dur*250,tmr.ALARM_SINGLE,function() local did = m(morsecb) if not did then offf() -- off at end - -- t:register(1000,tmr.ALARM_SINGLE,function() (require"morse")(name)(morsecb) end) -- cyclic behavior - t:register(dit,tmr.ALARM_SINGLE,function() onf() end) -- solid at end + -- t:alarm(1000,tmr.ALARM_SINGLE,function() (require"morse")(name)(morsecb) end) -- cyclic behavior + t:alarm(dit,tmr.ALARM_SINGLE,function() onf() end) -- solid at end end end) end -- begin by being solid on for 10 dit times, then off for 4, then run -- morse sequence onf() - t:register(10*dit,tmr.ALARM_SINGLE, function() - offf() ; t:register(4*dit,tmr.ALARM_SINGLE,function() m(morsecb) end) + t:alarm(10*dit,tmr.ALARM_SINGLE, function() + offf() ; t:alarm(4*dit,tmr.ALARM_SINGLE,function() m(morsecb) end) end) end end +