Best way to SWITCH:CASE from a get_last
shr00m-dew
Posts: 394
The more system's I do the more I'm trying to be more efficient with my code.
I've moved to less buttons, SWITCH:CASE'ing the room's source to deterine what to do. IE, transport is the same 7 buttons for every source.
Now I want to group all of the devices that have these buttons togther. IE, buttons 1-7 will be transport for every device on every source.
What's the best way to use GET.LAST to SWITCH:CASE a variable based on what the last input was?
I guess I could send the get_last to a function that returns which source variable to SWITCH:CASE. Something like:
Sound good?
Kevin D.
I've moved to less buttons, SWITCH:CASE'ing the room's source to deterine what to do. IE, transport is the same 7 buttons for every source.
Now I want to group all of the devices that have these buttons togther. IE, buttons 1-7 will be transport for every device on every source.
What's the best way to use GET.LAST to SWITCH:CASE a variable based on what the last input was?
I guess I could send the get_last to a function that returns which source variable to SWITCH:CASE. Something like:
define_function integer current_room (integer last_device) { SWITCH (last_device) { case ir_living: { return source_audio_living } } } SWITCH (current_room (get_last(button.input.device.number))) { case output_audio_sat1: {} }
Sound good?
Kevin D.
0
Comments
For IR remote mapping, I go even simpler. I'll make a generic channel array that has the values 29-100 in it (I treat transports, volume, channel up/down seperately for feedback purposes, besides the fact some devices tap for forward/reverse, others need you to hold the button - it's easier to break it away from this bigger grouping). When my source is selected, I store it's device number in a variable, generally dvDeck. When I get a button press on my panel within that 29-100 range, all the PUSH handler (or RELEASE, as it may be) has is SEND_COMMAND dvDeck, "'SP', BUTTON.INPUT.CHANNEL", which queues the IR of the same channel to that device. Then it's just a matter of making sure my generic control pages for each device have channel numbers that agree with the IR file (like the menu IR channel being 29, and the button for menu also having channel 29). If the device changes, I only have to edit the panel file, and no underlying code changes are needed - really handy for G3 panels you can edit right on the panel.