UI slider behavior bug?

Edit: I got this slightly wrong. Seems like all the slider functions are called when you move any slider.

If you call a user defined function from inside a slider function, all of the slider functions get called - not just the one for the slider you touched. Inline code in the functions seems fine. If you just want to change variables
or calculate inside slider functions it works as expected.

Here’s a short pattern that illustrates the behavior (on firmware 2.23). ~Move Control1, and only value1 changes. Now, uncomment the call to ChangeValue2 in sliderControl2. Moving either control will change both value1 and value2.

If this is the way it’s supposed to work, or if it’s a real pain to fix, I’m totally good with it now that I know what’s going on. That leads to my next question though: How do I update a pattern I uploaded to the library? I used function calls in sliders in some code I uploaded last night, and I’d like to fix them to get rid of the icky unnecessary blinkiness when moving controls.


export var value2 = 0;

export function changeValue2() {
  value2 += 1;

export function sliderControl1(v) {
  value1 += 1;

export function sliderControl2(v) {
  value2 += 1;
  // changeValue2();

export function beforeRender(delta) {
  t1 = time(.1);

export function render(index) {
  h = t1 + index/pixelCount ; s=1 ; v=1;
  hsv(h, s, v);

All controls are set anytime anything changes (or in a few other cases as well), and the idea is that they would be idempotent. In other words, sending the same values to the controls wouldn’t cause bad things to happen. If you set a value, and it could be a calculated value, then it won’t cause problems. But these examples increment for every change instead of using the slider value to arrive at a value.

I haven’t looked at the uploads yet, but when I do I’ll give some more specific advice :slight_smile:

If you want to update one, shoot me an email with the epe file and I’ll get it updated when I get a chance. I hope to improve on that system, but for now it’s manual in my part.

That’s kind of what I’d figured. That example was just to illustrate the unexpected side effect. It’s not actual code. The valueX variables don’t do anything but increment when the slider is moved.

No big deal – I’d put code into a couple of slider functions to set a flag that would trigger new heightmap generation if a relevant parameter changed. It was triggering on any control movement, causing a bit of flicker, and a map change where I didn’t necessarily want one. I’ll just take it out, and the user can wait a few seconds for the next automatic new map.


1 Like

Ahhh - good to know! I did the same on Perlin and noticed FPS degraded for all UI changes, but didn’t dig in like you did. Thanks!