# ILEDControl with switch

**URL:** <https://iplug2.discourse.group/t/iledcontrol-with-switch/353>\
**Category:** Uncategorized\
**Created:** [18 March 2021 23:44 UTC](https://iplug2.discourse.group/t/iledcontrol-with-switch/353 "2021-03-18T23:44:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rramirez](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/rramirez/32/128_2.png) [@rramirez](https://iplug2.discourse.group/u/rramirez)\
**Post date:** [18 March 2021 23:44 UTC](https://iplug2.discourse.group/t/iledcontrol-with-switch/353/1 "2021-03-18T23:44:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kay](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/kay/32/8_2.png) [@Kay](https://iplug2.discourse.group/u/Kay)\
**Post date:** [19 March 2021 07:49 UTC](https://iplug2.discourse.group/t/iledcontrol-with-switch/353/2 "2021-03-19T07:49:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rramirez](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/rramirez/32/128_2.png) [@rramirez](https://iplug2.discourse.group/u/rramirez)\
**Post date:** [19 March 2021 19:30 UTC](https://iplug2.discourse.group/t/iledcontrol-with-switch/353/3 "2021-03-19T19:30:31Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![AlexHarker](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@AlexHarker](https://iplug2.discourse.group/u/AlexHarker)\
**Post date:** [20 March 2021 12:28 UTC](https://iplug2.discourse.group/t/iledcontrol-with-switch/353/4 "2021-03-20T12:28:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![olilarkin](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/olilarkin/32/2_2.png) [@olilarkin](https://iplug2.discourse.group/u/olilarkin)\
**Post date:** [20 March 2021 12:42 UTC](https://iplug2.discourse.group/t/iledcontrol-with-switch/353/5 "2021-03-20T12:42:58Z")

</div>

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

```auto
    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();
    }));

```

---

<div class="post-metadata">

**Author:** ![AlexHarker](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@AlexHarker](https://iplug2.discourse.group/u/AlexHarker)\
**Post date:** [20 March 2021 12:57 UTC](https://iplug2.discourse.group/t/iledcontrol-with-switch/353/6 "2021-03-20T12:57:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rramirez](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/rramirez/32/128_2.png) [@rramirez](https://iplug2.discourse.group/u/rramirez)\
**Post date:** [21 March 2021 03:16 UTC](https://iplug2.discourse.group/t/iledcontrol-with-switch/353/7 "2021-03-21T03:16:20Z")

</div>

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