Double press button fade light


#1

1) Give a description of the problem
Just bought a samsung button, I want to code a piston for

  1. open lights on click
  2. close lights on held
  3. fade lights by x% of the current value on double-click

2) What is the expected behaviour?
If the light is at 30%, set value to 20%, if the value is 60%, set value to 50%…

3) What is happening/not happening?
Don’t find a way to set this kind of fading

Any ideas ?
thanks!


#2

maybe something like this,

IF button X double pressed
(now nested if)
        IF the light level is 30%
        Then with light 
        Set level to 20%
        IF the light level is 60%
        Then with light
        Set level to 50%

#3

I would like to encourage you to skip the fade, and instead use “Set level to” current level -10

My logic is, once a fade starts, it cannot be aborted… Often times, you will want to reduce 20 or 30%, and you will be forced to wait for the first fade to complete before you can drop it another 10%.

Alternatively, if you use the “Set level to” command, you can use the button again immediately ª, if desired.

Just my two cents.


Pro Tip:

If you think users will press the button (trigger) multiple times back to back… it is also worth programming this piston to run very swiftly from top to bottom. (which will happen at each press)

Ideally, the piston will be able to run thru the code entirely before the button is pressed again.


ª For clarification,

When I said, “you can use the button again immediately”, that last word, in context, is more like:
(the time it takes for the piston to complete an execution) plus 20ms later
as compared to a fade, which could keep you waiting 10 seconds, or more.


#4

Good to know about the fade. I just replaced a “set level” with “Fade”. I need to reconsider.


#5

There may be cases where a fade fits… but I never use them in any circumstance where they might need to be aborted, or increased/decreased multiple times. I also keep them out of pistons that may trigger back to back.