SetBPM with widget

Having trouble with most simplest script: I would like to make a button in rackspace, that will change the tempo to say, 150 bpm. I dragged a button to rackspace and GPScript Named it to TempoSet. The script is

Var
TempoSet : widget

//Set tempo to 150
On WidgetValueChanged(newValue : double) from TempoSet
SetBPM(150)
end

What happens is that everytime I go to that rackspace it sets the tempo to 150. Without pushing the button. What am I missing? :sweat_smile: How should I do this?

You should check the newValue
If it is equal to 1.0 then set the bpm and set the widget value back to 0.0
The callback is automatically executed when the rackspace/variation is switched.

Thanks, didn’t realize the callback behaviour. This seems to work when widget’s “initial value on load” is set to 0 and “Also on rackspace activation” is checked, if other newbies are wondering.

Var
    TempoSet : widget

//Set tempo to 150
On WidgetValueChanged(newValue : double) from TempoSet
    If newValue == 1 
  Then
    SetBPM(150)
    newValue = 0
  Else
    newValue = 0
  end
end

I would do this;

On WidgetValueChanged(newValue : double) from TempoSet
    If newValue == 1.0 
  Then
    SetBPM(150)
    TempoSet.SetWidgetValue(0.0)
  end
end
3 Likes

Thanks! Makes more sense and I was wondering how I could get button to “bounce back” after pressing :grinning: