Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Single button, Multiple images & commands?
#1
Me again!:oops:

So, My question for the day. Is it possible to have a button to have button that will change image depending on a variable and also change commands depending on a variable?
Let me explain...

I have a button on the top of my screen. It's unpressed image is just a play icon I made. What I need this button to do is change commands depending on the selected zone (GVar:Zone) and also change image depending on the current MediaState (GVar:MediaState).

Example:
If System::Equals(%(GVar:Zone), MathewPB, Case)
Devices::FieldRead(SonPBMathew.MTRANS#MediaState, GVar:MediaState, True)
If System::Equals(%(GVar:MediaState), Play, Case)
Devices::FieldWrite(SonPBMathew.MTRANS#Transport, Pause, True)
MediaState_bt::SetNamedImage(Unpressed, \\User\\CQC\\Icons\\Sonos_nex...)
End
End

The end result (hopefully) would be a button that send a play or pause command to the selected zone but also show the zones current status by showing the user a play or pause image.

Am I barking up the wrong tree or am I going about this the wrong way?

Cheers
Mat
Reply
#2
For the current status, make it a check box instead of a command button. Then it can display a pause or play image depending on the state of the player. You can always do a LinkToField command on a widget that has a field association, to change the field it works in terms of. So you can switch the check box to look at another field. However, it cannot do that based on a variable. It can only do it upon loading of the template it is in, or some other widget has to send it a command to make that happen.

So, as long as you only need it to adjust to a given player when the template that contains the check box loads, then in the OnPreload, just look at your variable and associate the check box with the appropriate field. One of the variables of course can be the moniker of the current player, so it becomes a simple matter of passing the value of the variable in the LinkToField command.


In terms of doing different things, you can do basically what you indicated. As long as there aren't a lot of them, that would work. Another option, again by setting a variable to the name of the current player, would be:

Device::FieldRead(%(GVar:CurPlayer).MTRANS#MediaState, .....)

and

Device::FieldWrite(%(GVar:CurPlayer).MTRANS#Transport, ....)


So again it just becomes a simple expansion of the variable to invoke the command on the right device. This is one of the reasons that standardization helps simplify things a lot, because that sort of simple scheme will work when all devices of a particular device class will work the same and have the same fields.
Dean Roddey
Explorans limites defectum
Reply
#3
Back on this now

Thanks Dean. What Im trying to do is make a bottom bar that controls the sonos device in the chosen room.
At the top of the main screen I have a "select room" popup and you choose the room you want to control. This then sets the global variable's using a fieldread command to the variables like GVar:CurAlbum, GVar:CurArtist etc.

Then on the bottom bar in the main screen I have the variable text that displays those values. It works but only when you choose the room, They do not automatically update like if you were to link a text field to a driver field. I guess that's what you were tying to tell me.

Is there a better way to do this? I want to be able to have each controller use a stand(ish) set of templates and they can control any user chosen room.

Cheers
Mat
Reply
#4
Don't put the values into variables and then display those. Just use the fields directly. In the OnPreload of that template, do LinkToField commands on the relevant display widgets to associate them with the correct player's fields.

For outgoing commands, you can of course set a variable (also in the OnPreload) to the moniker of the selected player, and use that to build up the names of any fields you are going to write to.
Dean Roddey
Explorans limites defectum
Reply
#5
So I have put a check box in and it's nearly working. However as you say it wont update it's state on its own (Only on the preload).
Is there a way to make it auto update? I cannot seem to be able use a linktofield command on this widget, That's how I have done it for all the other items on the overlay.

Cheers
Mat
Reply
#6
If you use a field based check box it will support the link to field command and auto-update. I assume you must be using a variable or static check box?
Dean Roddey
Explorans limites defectum
Reply
#7
God Damn, I didn't even see field based check box in the list!

Sorry Dean:oops:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to have a button go through three options? Such as changing floors? ghurty 6 1,523 04-28-2020, 04:21 PM
Last Post: Dean Roddey
  Is there a Way to Export Multiple Templates Together? kblagron 1 704 04-23-2020, 08:01 AM
Last Post: Dean Roddey
  Button Click changes button image? gReatAutomation 6 2,272 08-05-2019, 03:53 PM
Last Post: Dean Roddey
  Missing how to tell CQC to read a Lutron keypad button pressed ghurty 7 2,844 01-08-2019, 09:55 PM
Last Post: Dean Roddey
  Can't Find a Couple of Documented Action Commands kblagron 7 3,908 10-02-2018, 05:47 PM
Last Post: kblagron
  Triggered event w/ multiple triggers lleo 16 6,881 06-06-2018, 06:21 PM
Last Post: lleo
  Russound V2 Driver - no install button bpaetzold 1 1,789 12-24-2017, 07:13 PM
Last Post: Dean Roddey
  LoadOverlay helper button error dlmorgan999 9 4,987 09-10-2017, 01:22 PM
Last Post: dlmorgan999
  Additional HTTP REST commands requested greymatter 3 2,881 08-25-2017, 09:17 AM
Last Post: Dean Roddey
  SOLVED -- Button States agarden 6 4,303 05-28-2017, 10:02 AM
Last Post: agarden

Forum Jump:


Users browsing this thread: 1 Guest(s)