Corona gets it own container

3 replies [Last post]
brett
Offline
Providence, United States
Joined: 9 Jan 2010

Lets all talk about corona based development over here....

Brett

magill
Offline
Joined: 27 Apr 2012
Fantastic work Brett

I'm trying to create a button that monitors relay1 ie changes colour when active, but I don't want it to be 'pressable'

Also just for info I have an endpoint that returns a countdown timer eg 00:49

The system throws a wobbler trying to process this.

John

brett
Offline
Providence, United States
Joined: 9 Jan 2010
John,I made some assumption

John,

I made some assumption in the bsc.lua manager and that f its an OUTPUT endpoint you want to handle TOUCH event on your buttons to control them.   What you want is to monitor an OUTPUT endpoint.  In this case you need to do a little more work.     OUTPUT endpoints are things like RELAY, RF -- INPUT endpoints are things like LOBAT on the JeeNode or PIR both are boolean in nature but one does not accept BSC command events.

First we create a helper function to help us out

function newRelayMonitor( param )   
    -- We are not  going to define an onEvent method to handle a button press.
    -- so this MUST be readOnly.
    param.readOnly = true
    local btn = toggle.newToggle(param)
    local f = xap.Filter()
    f:add("xap-header","source",param.xapSource)   
    f:callback(function(frame)
                    btn:setState(frame:isValue("output.state","state","on"))
                end       
                )               
    xap_server:addFilter(f)
end

Now we can create a row of buttons that will not respond to TOUCH event but will correctly update when a XAP event occurs for them.

-- Create a row of buttons using our newRelayMonitor function()   
xpos=40
for i=1,4 do
    newRelayMonitor{
        text = "Relay "..i, size=16,
        default="glossy_button_red.png",
        on = "glossy_button_green.png",
        x = xpos,
        y = display.contentCenterY,
        xapSource="dbzoo.livebox.Controller:relay."..i
    }
    xpos = xpos + 80
end

Hope that helps.

Can you explain a little more about the counter endpoint?  What sort of xap is being sent out for this that you want to display.

Update: added these code fragments in a working demo (see attachment)

Brett

AttachmentSize
relayMonitor.zip 176.13 KB
magill
Offline
Joined: 27 Apr 2012
The green buttons send alias

       

 

The green buttons send alias eg "bedroom boost 1" which HAH interprets, triggers the appropriate relay and starts a countdown timer. This updates an endpoint "bedboostcounter" which I want to monitor eg 00:49 ie 49 minutes remaining. I would also like to monitor the relay state with maybe this run back timer as the text in the button. Thanks for all your help. I'll have a look at the code in your previous post.

John

Hardware Info