heronarts / LX

Core library for 3D LED lighting engines
https://chromatik.co/
Other
41 stars 25 forks source link

LXChannel.transitionTimeSecs has lowest level of 100ms #67

Closed worldveil closed 2 years ago

worldveil commented 2 years ago

As you can see here:

https://github.com/heronarts/LX/blob/8c4f768775199b45271e96e26a34bb871957d8bd/src/main/java/heronarts/lx/mixer/LXChannel.java#L125

I can't set this lower than 100ms. Is there a reason for this?

Occasionally and event happens, and I'd like:

LXPattern newPattern = ...;
currentLXChannel.goPattern(newPattern);
LX.log(curChannel.getActivePattern())  // should return newPattern, but instead still returns old one b/c of 100ms transition time

The transition feature is nice, but sometimes I need to just do it instantly.

Wondering if there's a latency reason to have this (ie: LX can't transition faster than 100ms) or if this is just a simple change from 0.1 -> 0.0 in code.

mcslee commented 2 years ago

If you don't want a transition, flip channel.transitionEnabled.setValue(false) before changing patterns.

Alternatively, you can use curChannel.getTargetPattern() - this will return the next pattern if we're in a transition, or the current pattern if not in a transition.

  public final LXPattern getTargetPattern() {
    return (this.transition != null) ? getNextPattern() : getActivePattern();
  }

If you don't want to mess with the transition on/off switch, if you make two calls to goPattern() back-to-back, the 1st call will initiate the transition and the 2nd one will automatically terminate it and complete the transition. A bit hacky but it works. This is also how the UI behaves... if you hit return on a pattern a 2nd time while it's being transitioned to, it'll complete instantaneously.

The rationale for transition time not going down to 0 is for it to present a sane range of values to the user to select in the UI, alongside the switch to turn transitions on or off entirely.