I am trying to create a display where I have to make it conform to existing logic. In my case I have several groups of three buttons.
ON OFF AUTO
The way the current system is setup is that when ON is pressed a value of 1 is sent to the host controller, If AUTO is pressed a value of 2 is sent and if OFF is pressed 0 is sent. As a confirmation, the host controller will echo back the same value after it has initiated the logic to do what it was supposed to do. For example if ON was pressed for WATER, the controller would echo back 1 once the water was energized and the 1 would then be used to change the ON button from gray to green.
Being new to this software I don’t know which approach is best to solve this problem, State Machine, CE, UE or script. I could probably make one of these work but I would prefer to handle it correctly from the start and not create a bad habit.
I welcome any comments.
Multiple push buttons with feedback. What's the best approach
- shouldbeonmyboat
- Posts: 7
- Joined: Tue Jan 05, 2016 12:21 pm
- vtaylor
- Posts: 13
- Joined: Fri Jul 27, 2012 7:33 am
Re: Multiple push buttons with feedback. What's the best approach
I think my approach would go like this:
If broadcasting over CAN, you can directly reference your variable in the Free Form CAN message and your state machine just needs to broadcast the the FFCAN message. I've done similar things where I have a periodic broadcast of the CAN message (handled by it's own user even with a recurring timer and a list of broadcast events for each FFCAN message I need to send), and my button press event just change the value of the variable that is referenced in the CAN message.
There are many ways to approach this problem, and it really depends on what else you have going on and how the button presses affect other things as to how you go about it. I always try to keep things as modular as possible so that I can add intermediate steps as necessary when things get more complicated (as they tend to do).
- Create a variable that holds the value to be sent (with a calculation event for each value that can be set)
- Create a state machine that handles the broadcast (by whatever means)
- Create a user even for each button and tie it the button press
If broadcasting over CAN, you can directly reference your variable in the Free Form CAN message and your state machine just needs to broadcast the the FFCAN message. I've done similar things where I have a periodic broadcast of the CAN message (handled by it's own user even with a recurring timer and a list of broadcast events for each FFCAN message I need to send), and my button press event just change the value of the variable that is referenced in the CAN message.
There are many ways to approach this problem, and it really depends on what else you have going on and how the button presses affect other things as to how you go about it. I always try to keep things as modular as possible so that I can add intermediate steps as necessary when things get more complicated (as they tend to do).
- shouldbeonmyboat
- Posts: 7
- Joined: Tue Jan 05, 2016 12:21 pm
Re: Multiple push buttons with feedback. What's the best approach
Thanks much. That's what I needed.