]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_lamp/commitdiff
touch: initialize color table correctly
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sat, 6 Jan 2018 19:12:40 +0000 (14:12 -0500)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sat, 6 Jan 2018 20:25:40 +0000 (15:25 -0500)
Failing this, it was possible to call into a drawing without a primary
color assigned, which could lead to any number of crashes.

lamp-touch.lua

index 97bef8336d6fa85d26a0ca6c7d1a97ada396e076..84b66a716cd5eea67039f61cb9fcc560638f4b17 100644 (file)
@@ -10,9 +10,9 @@ local touch_db_blackout = nil
 local touch_db_fn = nil
 local touchfns    = { }
 local touchfnix = 1
-local colors      = { }
 local cccb        = nil
 local ncolors     = 1
+-- colors table initialized below, once we have touchcolorvec in scope
 
 if touchcolor == nil then touchcolor = 40 end
 if touchlastfn == nil then touchlastfn = "fill" end
@@ -80,6 +80,8 @@ local function touchcolorvec(c)
   return g,r,b
 end
 
+local colors      = { string.char(touchcolorvec(touchcolor)) }
+
 local function onblackdebounce() touch_db_blackout = nil end
 local function onfndebounce() touch_db_fn = nil end