module(...,package.seeall) require("xap") info = {version="1.0", description="20x4LCDInfo"} lcdcols = 20 -- Specify for LCD Row length fill = " " -- Char used to fill blank LCD colums Line1 = "Waiting for Data - 1"..string.rep(fill, lcdcols - string.len("Waiting for Data - 1")) -- Sets Line Var to contain basic text until overwritten with Catch routines Line2 = "Waiting for Data - 2"..string.rep(fill, lcdcols - string.len("Waiting for Data - 2")) Line3 = "Waiting for Data - 3"..string.rep(fill, lcdcols - string.len("Waiting for Data - 3")) Line4 = "Waiting for Data - 4"..string.rep(fill, lcdcols - string.len("Waiting for Data - 4")) Unit1 = " oC" -- Customisable Units (note the space prefix) Unit2 = " oC" Unit3 = " Watts" function init() -- Sets up 3 filters Filter1 = xap.Filter() Filter1:add("xap-header", "source", "dbzoo.livebox.Controller:1wire.1") Filter1:callback(catch1wire1) -- A temperature change in the filter will trigger the Catch1wire1 routine Filter2 = xap.Filter() Filter2:add("xap-header", "source", "dbzoo.livebox.Controller:1wire.2") Filter2:callback(catch1wire2) Filter3 = xap.Filter() Filter3:add("xap-header", "source", "dbzoo.livebox.CurrentCost:ch.*") Filter3:callback(catchCurrentCost) send2lcd("Waiting for Data") -- Test LCD at applet start xap.Timer(update, 10):start() -- Starts update routine timer with a 10 second interval end function catch1wire1() Value1 = xap.getValue("input.state","displaytext") -- Sets Value1 as 1Wire data Line1 = Value1..Unit1..string.rep(fill, (lcdcols - string.len(Value1) - string.len(Unit1))) -- Sets Line1 Var with 1Wire data (Value1) and appends Unit1, fills remaining Lcd colums with spaces end function catch1wire2() Value2 = xap.getValue("input.state","displaytext") Line2 = Value2..Unit2..string.rep(fill, (lcdcols - string.len(Value2) - string.len(Unit2))) end function catchCurrentCost() Value3 = xap.getValue("input.state","text") Line3 = Value3..Unit3..string.rep(fill, (lcdcols - string.len(Value3) - string.len(unit3))) end function update(self) -- Timer routine Line4 = " "..os.date("%H:%M") -- Sets Line 4 as basic clock lcdstring = Line1..Line2..Line3..Line4 -- Conbines all LCD Lines1-4 into one string ready to send to the LCD every 10 seconds send2lcd(lcdstring) -- Sends to LCD end function send2lcd(lcdstr) -- LCD Routine xap.sendShort(string.format([[xap-header { target=dbzoo.livebox.Controller:lcd class=xAPBSC.cmd } output.state.1 { id=* state=on text=%s }]], lcdstr)) end