Button state question
I draw in the TP4 two general buttons (button up, button down) and a multi-state general button with 5 states.
I want that when I press the up button the multi-state button will rise in 1 state level and when I press down it will Decreased in 1 state level.
How can I attach the general buttons to the state button? Can I do it on the TP4 or I need to write a code, if so does anyone have an idea how to do that?
thanks for any help
I want that when I press the up button the multi-state button will rise in 1 state level and when I press down it will Decreased in 1 state level.
How can I attach the general buttons to the state button? Can I do it on the TP4 or I need to write a code, if so does anyone have an idea how to do that?
thanks for any help
Comments
Essentially, the only way you can change button states from within the panel is to use the "Command Output" section of button properties to send the ^ANI command to a specific button to change its state. Unfortunately, the ^ANI command only allows you to do a button animation and end on a specific state. There is no "increment up" or "increment down" command, so while you could create 5 buttons to correspond to the 5 different states of your multistate button, you can't really create 2 buttons to scroll through them.
If, on the other hand, your multi state button were a level, you COULD create 2 buttons to cause it to scroll through its level values. However, that depends on exactly what you're trying to make your multi-state button do.
J
PROGRAM_NAME='test' DEFINE_DEVICE tp = 10001:1:0; define_constant button_increment = 1; button_decrement = 2; button_animated = 3; define_variable integer buttons[2]={ button_increment, button_decrement }; integer current_state; define_event button_event[tp,buttons]{ push:{ change_button_state(get_last(buttons)); } } define_start current_state = 0; define_function change_button_state(integer in_or_de){ /* Set the button state depending on the current state * Command format: ^ANI-<button_number>,<startstate>,<endstate>,<time> * Things of Note: if you put in 0 as startstate it will mean the current * one it is on. */ stack_var temp; temp = current_state; switch(in_or_de){ case button_increment: temp++; case button_decrement: temp--; } send_command tp,"'^ANI-',itoa(button_animated),',0,',itoa(temp),',1'"; current_state = temp; }This should do the trick, haven't tested it. (don't have a TP handy).
I wouldn't bother with the ^ani command.
To do this completely on the panel, make the center button a multi-state bargraph, as suggested above, and then for the up/down buttons, set them to the same level code as the bargraph. Then set the "level control type" to "relative", and the value to either 1 or -1.
--D
Yea, that's the best route
J