Home NetLinx Studio

The method of syncing buttons state

f0ghuaf0ghua Junior MemberPosts: 16
I am wondering what's the best method to keep a button state sync with the actual state. I did as the following:
...
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.

Comments

  • ericmedleyericmedley Senior Member - 4000+ posts Posts: 4,177
    Where are you starting the timeline?
  • f0ghuaf0ghua Junior Member Posts: 16
    ericmedley wrote: »
    Where are you starting the timeline?

    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.
  • ericmedleyericmedley Senior Member - 4000+ posts Posts: 4,177

    [FONT=Arial, Helvetica, Verdana, sans-serif]try putting parens around the last part. [/FONT]LIGHT_ROOM] = (lightState[CHAN_LIGHT_ROOM])
  • a_riot42a_riot42 AMX Wizard Posts: 1,619
    Not sure if I understand, but channel feedback won't activate unless the state has actually changed. So if the master sets a channel to ON, the only way it will do it again is if the channel goes OFF first. It won't bother trying to turn a channel on that it thinks is already on. It won't update channels on a touch panel automagically, you have to do it in programming.
    Paul
  • TonyAngeloTonyAngelo Code Monkey Posts: 315
    a_riot42 wrote: »
    Not sure if I understand, but channel feedback won't activate unless the state has actually changed. So if the master sets a channel to ON, the only way it will do it again is if the channel goes OFF first. It won't bother trying to turn a channel on that it thinks is already on. It won't update channels on a touch panel automagically, you have to do it in programming.
    Paul

    In other words, you need to do it in the online data_event of the touch panel.
Sign In or Register to comment.