Home AMX User Forum AMX General Discussion

Combining Channels..

OK the help section in studio says you can combine dev_chans.. here is their example:

DEVCHAN dcMSP1 =
{{MSP1,PRESET1},{MSP1,PRESET2},{MSP1,PRESET3},{MSP1,PRESET4},{MSP1,PRESET5}}

DEVCHAN dcMSP2 =
{{MSP2,PRESET1},{MSP2,PRESET2},{MSP2,PRESET3},{MSP2,PRESET4},{MSP2,PRESET5}}

DEVCHAN dcMSP3 =
{{MSP3,PRESET1},{MSP3,PRESET2},{MSP3,PRESET3},{MSP3,PRESET4},{MSP3,PRESET5}}

DEVCHAN dcVDEV =
{{VDEV,PRESET1},{VDEV,PRESET2},{VDEV,PRESET3},{VDEV,PRESET4},{VDEV,PRESET5}}

COMBINE_CHANNELS (dcVDEV, dcMSP1, dcMSP2, dcMSP3)

I am trying to combine multiple dev_chan sets and am doing it the same way as above in my program, however it doesn't seem to work. I am basically trying to take an R2 (which has a different set of channel numbers for all of the buttons depending on which source button you press or page you are on) and combine them all to one virtual dev_chan group to make all of the buttons output the same channel number no matter which source button you press or what page you are on.

Comments

  • NMarkRobertsNMarkRoberts Posts: 455
    I've struggled with combine_everything and have chosen not to bother and do it all programmatically, which isn't at all difficult.
  • ericmedleyericmedley Posts: 4,177
    It can be done if you abandon the DEVCHAN and do it with an old fashioned Button_Event.
    DEFINE_DEVICE
    MIO_R2= whatever
    vMIO_R2=33001:01:0
    
    DEFINE_VARIBABLE
    INTEGER MIO_BUTTON_PUSHED
    INTEGER RESULT_BUTTON_PUSH
    
    BUTTONS_1_thru_255[]=
    {
    01,02,03,04,05,06,07,08,09,10
    11,12,13,14,15,16,17,18,19,20,
    ETC...
    
    ,245,255
    }
    
    DEFINE_EVENT
    
    BUTTON_EVENT[MIO_R2,BUTTONS_1_thru_255]
    {
    PUSH:
      {
      MIO_BUTTON_PUSHED=button.input.channel
      current_zone=(MIO_BUTTON_PUSHED/40)
      RESULT_BUTTON_PUSH=MIO_BUTTON_PUSHED-(current_zone*40)
      do_push(vMIO_R2,RESULT_BUTTON_PUSH)
      }
    }
    

    Since the buttons are separated by a factor of 40 from one page to the next, it's simple algebra to get the number. I've put in the example from the R2 manual below.
    Button Label       Mode 1 Mode 2 Mode 3 Mode 4 Mode 5 Mode 6
    1 Power Symbol   9        49        89       129       169      209
    

    So a push on any one of these Power Buttons will yield a push on channel 9 on the virtual device.
  • cmacma Posts: 94
    The /40 thing looks pretty clean, I ended up with something very similar to that.. I would like to get the combine channel thing going though, it would be nice to be able to combine a group of buttons on a panel rather than the whole thing.
  • ericmedleyericmedley Posts: 4,177
    cma wrote:
    The /40 thing looks pretty clean, I ended up with something very similar to that.. I would like to get the combine channel thing going though, it would be nice to be able to combine a group of buttons on a panel rather than the whole thing.

    You can do that as well with this example. Just put whatever button numbers you wish to address in the button array. You don't have to go from 1-255 consecutively.
  • jjamesjjames Posts: 2,908
    cma wrote:
    I am basically trying to take an R2 (which has a different set of channel numbers for all of the buttons depending on which source button you press or page you are on) and combine them all to one virtual dev_chan group to make all of the buttons output the same channel number no matter which source button you press or what page you are on.

    Perhaps I'm not understanding. Just out of curiosity - why would you have a different set of buttons for different sources? You could do a simple SWITCH/CASE or SELECT/ACTIVE on the source variable and then do whatever you need to do. Something like this might help.
    BUTTON_EVENT[dvR2,nCTRL_BTNS]
    {
      PUSH:
      {
        SWITCH(nSOURCE)
        {
          CASE nSRC_CABLE:
          {
            // do something
          }
          // etc.
        }
      }
    }
    
  • cmacma Posts: 94
    jjames wrote:
    Perhaps I'm not understanding. Just out of curiosity - why would you have a different set of buttons for different sources? You could do a simple SWITCH/CASE or SELECT/ACTIVE on the source variable and then do whatever you need to do. Something like this might help.
    BUTTON_EVENT[dvR2,nCTRL_BTNS]
    {
      PUSH:
      {
        SWITCH(nSOURCE)
        {
          CASE nSRC_CABLE:
          {
            // do something
          }
          // etc.
        }
      }
    }
    

    The R2 buttons are hard numbered so depending on what Source button you push at the top of the remote all of the button channel numbers change. I am trying to get the remote to act just like a touchpanel where you would use the same channel numbers for multiple devices.
  • jjamesjjames Posts: 2,908
    Okay, I gotcha now. I've never dealt with an R2 before, just an R4. Thanks for explaining. ;)
  • cmacma Posts: 94
    jjames wrote:
    Okay, I gotcha now. I've never dealt with an R2 before, just an R4. Thanks for explaining. ;)

    The R2 would be great if you could just pick a range of channels just like the older RF remotes but you are stuck with the page by page set of channel numbers they give you.
  • ericmedley wrote:
    BUTTONS_1_thru_255[]=
    {
    01,02,03,04,05,06,07,08,09,10
    11,12,13,14,15,16,17,18,19,20,
    ETC...
    
    ,245,255
    }
    
    DEFINE_EVENT
    
    BUTTON_EVENT[MIO_R2,BUTTONS_1_thru_255]
    {
    PUSH:
      {
      MIO_BUTTON_PUSHED=button.input.channel
      current_zone=(MIO_BUTTON_PUSHED/40)
      RESULT_BUTTON_PUSH=MIO_BUTTON_PUSHED-(current_zone*40)
      do_push(vMIO_R2,RESULT_BUTTON_PUSH)
      }
    }
    

    may I ask you, if there is a reason not to do just BUTTON_EVENT[MIO_R2,0] ?
  • viningvining Posts: 4,368
    REBUILD_EVENT wrote:
    BUTTON_EVENT[MIO_R2,0] ?
    I've never tried to use a [dvDEV,0] before and can only assume based on your post that any button channel numbers for that device port will trigger the button_event. If this is the case it offers many possibilties like eliminating the use of button arrays which really only simplify the changing of TP button channels w/o changing the code. Since most devices are placed on their own port there ususally isn't a need to ever make those channel number changes which sort of makes the button array unnecassary. Although it did eliminate the need use button_event for each channel number which made for long code. So if this indeed does work this way we can shorten the code and eliminate button arrays in most cases.
  • ericmedleyericmedley Posts: 4,177
    may I ask you, if there is a reason not to do just BUTTON_EVENT[MIO_R2,0] ?

    No, you may ask :) No, zero is a great way to do it. The only reason not to do it is if he intends to leave some of the buttons out of the equation. But what you suggest works fine and takes fewer lines of code.
  • DHawthorneDHawthorne Posts: 4,584
    ericmedley wrote:
    No, you may ask :) No, zero is a great way to do it. The only reason not to do it is if he intends to leave some of the buttons out of the equation. But what you suggest works fine and takes fewer lines of code.
    It works, but I disagree that it's a "great" way to do it. You've now got code running for every button in the device, whether anything will happen on a particular press or not. Admittedly, it's not enough overhead to matter in most cases, but my sense of cleanness in coding just won't let me do it. I also worry that I will forget to trap something critical out, or will have a slip up in my panel or code that will cause mysterious, unexpected events to occur because I was using a wild-card channel.
  • NMarkRobertsNMarkRoberts Posts: 455
    DHawthorne wrote:
    my sense of cleanness in coding just won't let me do it

    I see it the other way round. Do everything in one place, the ButtonPushHandler routine, using a switch / case, and that seems cleaner to me. When adding a button you need only add the definition of the constant holding its number and a case in your routine. The traditional approach requires adding it to the array as well. That's very easy to miss, and I got it wrong so often that I now avoid doing it that way.

    Let's also put to rest this idea that we need to worry about performance issues.

    (a) The code is only run when a button is pushed. That's never going to overload the system.

    (b) Any additional processor load is miniscule*, and need not be considered.

    (c) The traditional approach filters buttons too - the same process occurs - although perhaps in a more efficient manner.

    Performance is the last thing we should worry about - clarity and simplicity is almost always more important.

    *or minuscule if you like
  • DHawthorneDHawthorne Posts: 4,584
    I'm not trying to fault the method ; it's clearly one of those cases that boils down to individual style. Just trying to explain my rationale, and offer an alternative. But your point (a) is only half right. The code has to run when every button is pushed, at least to the extent that the event block test if the channel is something it has to act on. Does it matter? Probably not.
  • mkipemkipe Posts: 10
    Wildcard in Button Event

    I've just implemented the ,0 in a button event and it is generating some odd information regarding the HOLD: portion of my button event.

    BUTTON_EVENT[dvRemote, 0]
    {
    PUSH:
    {
    STACK_VAR char mCmd[10]
    mCmd = FindFireballCmd(BUTTON.INPUT.CHANNEL, FALSE);
    IF (mCmd != '') SEND_FB_CMD(mCmd);
    }
    HOLD[4, REPEAT]:
    {
    STACK_VAR char mCmd[10]
    mCmd = FindFireballCmd(BUTTON.INPUT.CHANNEL, TRUE);
    IF (mCmd != '') SEND_FB_CMD(mCmd);
    }
    }

    The processor shows: "CIpHold:AddHold - Duplicate" and my code within my FindFireballCmd seems to be executing non-stop event though I only pressed the button once.

    Any thoughts on this behavior?

    I'm working with a MIO R-2 and was originally trying to pass in the mode offset and create a generic module that would allow the device to be assigned to different mode buttons on a job by job basis. My button event looked like

    BUTTON_EVENT [dvRemote, RemoteOffset+ButtonConstantPlay] where RemoteOffset is a variable passed in during the module declaration. The system ignored this event which led me to changing to the 0 as suggested above.

    Thanks for any advice that may come along.
  • viningvining Posts: 4,368
    mkipe wrote:
    I've just implemented the ,0 in a button event and it is generating some odd information regarding the HOLD: portion of my button event.
    That's sort of explained here:
    http://amxforums.com/showthread.php?t=2590
    But basically any time you don't have a push or release of some channel number you have a hold of 0. If tyou think about it long enough it makes sense.

    Go back the begining of the thread as it went off on another tangent.
Sign In or Register to comment.