From df7ad8797bc6e2afb457b1c24388ae69d7234951 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Sun, 29 Jan 2017 20:51:28 -0500 Subject: [PATCH] examples/ctfws -- read LCD I2C address from fs --- init2.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/init2.lua b/init2.lua index 52e8d62..5c58372 100644 --- a/init2.lua +++ b/init2.lua @@ -9,10 +9,20 @@ for k,v in pairs(file.list()) do end end +-- Grab some configuration parameters we might need, +-- notably, the LCD address +ctfwshw = {} +if file.open("ctfws-misc.conf","r") then + local conf = cjson.decode(file.read() or "") + if type(conf) == "table" + then ctfwshw = conf + else print("ctfws-misc.conf malformed") + end +end -- Hardware initialization i2c.setup(0,2,1,i2c.SLOW) -- init i2c on GPIO4 and GPIO5 -lcd = dofile("lcd1602.lc")(0x27) +lcd = dofile("lcd1602.lc")(ctfwshw.lcd or 0x27) tq = (dofile "tq.lc")(tmr.create()) -- 2.50.1