From: Nathaniel Wesley Filardo Date: Sat, 6 Jan 2018 19:12:40 +0000 (-0500) Subject: touch: initialize color table correctly X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=fae433d5386b14397cd614867d0a723c0fef9099;p=acmetensortoys-esp-lua_lamp touch: initialize color table correctly Failing this, it was possible to call into a drawing without a primary color assigned, which could lead to any number of crashes. --- diff --git a/lamp-touch.lua b/lamp-touch.lua index 97bef83..84b66a7 100644 --- a/lamp-touch.lua +++ b/lamp-touch.lua @@ -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