iPlug2 Forum

ILEDControl with switch

Hi, Can somebody point me in the right direction to create an ILEDControl that turns on when a switch parameter is pressed?

Have a look at the IPlugControls project. There is a IBSwitchControl which probably does what you need. There’s also an ILEDControl.

So, I have an SVG control that’s a switch and an ILEDControl. I guess my question is better rephrased as how can I link the switch to the ILEDControl so that it lights up when the switch is pressed, how would I make that happen?

Link both controls to the same parameter and the LED should follow the state of the parameter, whether set by automation or the GUI switch.

ILEDControl doesn’t have a constructor that takes a paramIdx. Simplest thing todo would be to create a subclass that does and do what @AlexHarker says. Here is how you can do it without that

    constexpr int ctrlTag = 0;
    
    pGraphics->AttachControl(new ILEDControl(b.GetCentredInside(50)), ctrlTag);
    pGraphics->AttachControl(new IVToggleControl(b.GetCentredInside(50).GetTranslated(50, 0), [](IControl* pCaller){
      SplashClickActionFunc(pCaller);
      IControl* pLEDControl = pCaller->GetUI()->GetControlWithTag(ctrlTag)->As<ILEDControl>();
//      pLEDControl->TriggerWithDecay(100); // trigger momentarily
      pLEDControl->SetValue(pCaller->GetValue());
      pLEDControl->SetDirty();
    }));

My bad - I’m not so familiar with that control - should have checked the source.

Thank you all for your input, I decided to create a subclass of ILEDControl with parameter linking.