Dimmer macro - memory toggle variant

Discussion in 'C-Bus Wired Hardware' started by Barry24, Jun 20, 2020.

  1. Barry24

    Barry24

    Joined:
    Mar 3, 2012
    Messages:
    14
    Likes Received:
    0
    Location:
    Auckland, NZ
    I would like to use a single button to toggle a group level on/off but always recall a set value (e.g. 30%), and also have the ability to ramp the group up or down once the group is active.
    The 'dimmer' macro comes close with the toggle micro function, but this always sets the on level at 100%
    The 'memory toggle 2' also comes close as that can be configured with an on value in the blocks, but if a ramp occurs, this new value is updated, and therefore the next toggle recalls the old ramped level rather than the desired set value (30%).

    Is there a way to change the toggle value from 100%, or prevent the memory toggle from storing the value after ramping?
    Essentially, I think I am after a macro that does the following:
    Short Press - idle
    Short Release - Toggle recall 1
    Long Press - Downcycle
    Long Release End Ramp

    However there is no 'toggle recall 1' that I can find. Any pointers would be much appreciated.
     
    Barry24, Jun 20, 2020
    #1
  2. Barry24

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    You're not the first to ask for this behavior :)

    Unfortunately it can't be done solely in a switch with a single button.

    You need a logic device for this kind of functionality, or just use 2 buttons.
     
    Ashley, Jun 20, 2020
    #2
    Barry24 likes this.
  3. Barry24

    Barry24

    Joined:
    Mar 3, 2012
    Messages:
    14
    Likes Received:
    0
    Location:
    Auckland, NZ
    Thanks for the reply Ashley. I'm using a 2 gang key input unit and I do have a PAC, so would like to explore the logic option so that I still have the other key for another function.

    Does the logic approach mean that the short release, long press and long release are assigned set recall values for a trigger group, and then the following pseudo logic applied?
    I'm assuming that since only 2 recall values can be assigned, that one of these needs to be re-used.
    e.g,
    <Shortpress> = idle
    <Shortrelease> = recall 1 (20)
    <Longpress> = recall 2 (40)
    <Longrelease> = recall 1 (20)

    once <triggergroup> = 20 {shortrelease or longrelease}
    if <var_longpress> = 0 {no longpress has been detected so this must be a shortrelease}
    if getlightinglevel(<group>) = 0
    setlightinglevel (<group>, 30%, 4)
    set <triggergroup> = 1 {for indicator to stay lit}​
    else
    setlightinglevel (<group>, 0, 4)
    set <triggergroup> = 0 {for indicator to go off}​
    endif​
    else {longpress has been detected so this must be a longrelease}
    set <var_longpress> = 0
    setlightinglevel (<group>, getlightinglevel(<group>), 0)
    set <triggergroup> = 1 {for indicator to stay lit}​
    endif​

    once <triggergroup> = 40 {longpress}
    set <var_longpress> = 1
    if <rampdirection> = "up"
    setlightinglevel (<group>, 255, 4)
    set <var_rampdirection> = "down"​
    else {default rampdirection is down first time through}
    setlightinglevel (<group>, 1, 4)
    set <var_rampdirection> = "up"​
    endif​

    Have I over complicated something that could be done in a simpler way?
     
    Last edited: Jun 26, 2020
    Barry24, Jun 26, 2020
    #3
  4. Barry24

    Barry24

    Joined:
    Mar 3, 2012
    Messages:
    14
    Likes Received:
    0
    Location:
    Auckland, NZ
    Further update...
    I tried to simplify the logic for the short-release by using toggle micro action. My theory was that this would set the TriggerGroup value to either 0% or 100% and remove the need to check whether it was a short-release or long-release that had been used.
    However, looking at the toolkit Applications page and monitoring the values (TriggerGroup level), the short-release (assigned to toggle) was always returning 132. Interestingly, this is the same value as the keypad unit address (see image). I'm not sure if this is an "undocumented feature" or a bug.

    Trigger.JPG

    Even so, I tried to use this value in the logic as below, but this was never detected by the logic. The ramping worked fine however. Is this perhaps due to the 132 value not converting to 52% exactly?


    Code:
    once (GetTriggerLevel("B5_Trigger") = 52% {"Short_Release"} ) then {short release detected}
    begin
      SetTriggerLevel("B5_Trigger", 0);
      if (GetLightingState("Barrys Office") = OFF) then
        SetLightingLevel("Barrys Office", 80%, "4s")
      else
        SetLightingLevel("Barrys Office", 0%, "4s");
    end;
    
    once (GetTriggerLevel("B5_Trigger") = 20% {"Long_Press"} ) then {long press detected}
    begin
      if B5_RampDirection = 1 then  {up}
      begin
        SetLightingLevel("Barrys Office", 100%, "4s");
        B5_RampDirection:= 0
      end
      else    {ramp direction is down or first time triggered}
      begin
        SetLightingLevel("Barrys Office", 0%, "4s");
        B5_RampDirection:= 1
      end
    end;
    
    once (GetTriggerLevel("B5_Trigger") = 40% {"Long_Release"} ) then {long release detected}
    begin
      SetTriggerLevel("B5_Trigger", 0);
      SetLightingLevel("Barrys Office", GetLightingLevel("Barrys Office"), "0s");     {set lighting level to the current value to stop ramp}
    end;
     
    Barry24, Jun 27, 2020
    #4
  5. Barry24

    Barry24

    Joined:
    Mar 3, 2012
    Messages:
    14
    Likes Received:
    0
    Location:
    Auckland, NZ
    Final code based on original design in order to get around the 'toggle' not appearing to work correctly for the trigger group.
    Hopefully this is useful to others.

    Code:
    once (GetTriggerLevel("B5_Trigger") = 20% {"Long_Press"} ) then {long press detected}
    begin
      B5_longpress:=1;
      if B5_RampDirection = 1 then  {up}
      begin
        SetLightingLevel("Barrys Office", 100%, "4s");
        B5_RampDirection:= 0
      end
      else    {ramp direction is down or first time triggered}
      begin
        SetLightingLevel("Barrys Office", 0%, "4s");
        B5_RampDirection:= 1
      end
    end;
    
    once (GetTriggerLevel("B5_Trigger") = 40% {"Release"} ) then {long release or short release detected}
    begin
      if B5_longpress = 1 then     {longpress preceeded, so this must be a long release}
      begin
        SetLightingLevel("Barrys Office", GetLightingLevel("Barrys Office"), "0s");     {set lighting level to the current value to stop ramp}
        B5_longpress:= 0;
      end
      else    {longpress not preceeded, so this must be a short release}
      if (GetLightingState("Barrys Office") = OFF) then
        SetLightingLevel("Barrys Office", 80%, "4s")
      else
        SetLightingLevel("Barrys Office", 0%, "4s");
    
      SetTriggerLevel("B5_Trigger", 0);
    end;
     
    Barry24, Jun 27, 2020
    #5
  6. Barry24

    Wonkey

    Joined:
    Aug 3, 2004
    Messages:
    395
    Likes Received:
    37
    Location:
    Adelaide
    Do you want to make it really simple. 2 very short logic modules and use MIN logic in a dimmer.
    Use a toggle dimmer on the Key input
    read GA 22 as your light and GA 12 as the Min logic group in the dimmer.
    1st module
    {when light goes off set GA 12 to 30%}

    once (GetLightingState("Group 22") = Off) then
    begin
    SetLightingLevel("Group 12", 30%, "0s");
    end;
    once (GetLightingLevel("Group 22") > 1%) then
    begin
    SetLightingLevel("Group 22", 30%, "0s");
    EnableModule("track");
    end;

    2nd Module (Track)
    TrackGroup("Local", "Lighting", "Group 22", "Group 12");
    once (GetLightingState("Group 22") = OFF) then
    begin
    DisableModule("track");
    end;
     
    Wonkey, Jun 27, 2020
    #6
  7. Barry24

    Wonkey

    Joined:
    Aug 3, 2004
    Messages:
    395
    Likes Received:
    37
    Location:
    Adelaide
    Maybe I should mention that in the intiallation you should disable the track module
     
    Wonkey, Jun 27, 2020
    #7
  8. Barry24

    Barry24

    Joined:
    Mar 3, 2012
    Messages:
    14
    Likes Received:
    0
    Location:
    Auckland, NZ
    Thanks for the extra option Wonkey, Based on that approach, I don't see the need to even track the GA (making the code even simpler). Just having the code below seems to result in the same outcome. Was there any other reason for tracking?

    Code:
    once (GetLightingLevel("Barrys Office") > 1%) then
    begin
    SetLightingLevel("Barrys Office", 30%, "0s");
    end;
    
    The one downside, is the initial subsecond flash when the GA turns on at 100% and is then reduced to 30%.
     
    Barry24, Jun 28, 2020
    #8
  9. Barry24

    Wonkey

    Joined:
    Aug 3, 2004
    Messages:
    395
    Likes Received:
    37
    Location:
    Adelaide
    Reason was to prevent that flash using the min logic in the output unit. Then the 2 GAs track at the same level once turned on.
     
    Wonkey, Jun 28, 2020
    #9
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.