]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_ctfws/commitdiff
examples/ctfws -- read LCD I2C address from fs
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Mon, 30 Jan 2017 01:51:28 +0000 (20:51 -0500)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Mon, 30 Jan 2017 20:09:01 +0000 (15:09 -0500)
init2.lua

index 52e8d6235620f15635f98811822fd075875dd1eb..5c58372c79ec189715d56cd0db3e21356c3e8833 100644 (file)
--- 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())