Multiple push buttons with feedback. What's the best approach

Discuss issues and ideas you have to configuring displays with PowerVision
shouldbeonmyboat
Posts: 7
Joined: Tue Jan 05, 2016 12:21 pm

Multiple push buttons with feedback. What's the best approach

Post by shouldbeonmyboat » Mon Mar 14, 2016 10:39 am

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.
vtaylor
Posts: 13
Joined: Fri Jul 27, 2012 7:33 am

Re: Multiple push buttons with feedback. What's the best approach

Post by vtaylor » Tue Apr 05, 2016 9:36 am

I think my approach would go like this:
  1. Create a variable that holds the value to be sent (with a calculation event for each value that can be set)
  2. Create a state machine that handles the broadcast (by whatever means)
  3. Create a user even for each button and tie it the button press
The user event for the button press can then set the value of the variable (via the calculation event) and actuate the state machine that handles the broadcast.

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

Post by shouldbeonmyboat » Thu Apr 13, 2017 1:01 pm

Thanks much. That's what I needed.