The method of syncing buttons state
f0ghua
Posts: 16
I am wondering what's the best method to keep a button state sync with the actual state. I did as the following:
As you see, the lightState array collects all the status of the lights in a DATA_EVENT block. It works, but still have problem. If the AP which links with TPcontrol and central controller powers off and on, all button states lost. even I push the button again to change state, no feedback on tpcontrol.
I think the problem maybe relate to the lightState gather code, but I still want to make sure whether my method is right. Please give me your advice.
... DEFINE_CONSTANT CHAN_LIGHT_ROOM = 1 MAX_LIGHT_NUM = 4 DEFINE_VARIABLE volatile dev gDvTps[TP_MAX_PANELS] = {dvTP1, dvTP2} long TL_TP = 1 // the global timeline, used to sync the panel button state and so on long gTLTPSpacing[1] = {250} integer lightState[MAX_LIGHT_NUM] DEFINE_START TIMELINE_CREATE(TL_TP, gTLTPSpacing, 1, TIMELINE_RELATIVE, TIMELINE_REPEAT) TIMELINE_EVENT[TL_TP] { [gDvTps, CHAN_LIGHT_ROOM] = lightState[CHAN_LIGHT_ROOM] }
As you see, the lightState array collects all the status of the lights in a DATA_EVENT block. It works, but still have problem. If the AP which links with TPcontrol and central controller powers off and on, all button states lost. even I push the button again to change state, no feedback on tpcontrol.
I think the problem maybe relate to the lightState gather code, but I still want to make sure whether my method is right. Please give me your advice.
0
Comments
Sorry, I missed the DEFINE_EVENT line before the TIMELINE_EVENT. The timeline start at DEFINE_START section, it keeps looping as executing in DEFINE_PROGRAM.
[FONT=Arial, Helvetica, Verdana, sans-serif]try putting parens around the last part. [/FONT]LIGHT_ROOM] = (lightState[CHAN_LIGHT_ROOM])
Paul
In other words, you need to do it in the online data_event of the touch panel.