## restoring of button state

Scope and XITE Development

Original topic on PlanetZ: https://forums.scopeusers.com/viewtopic.php?t=28307

#### restoring of button state

Posted: Tue Nov 10, 2009 7:08 am
by winger
OK, I haven't have much response on the last couple questions, hoepfully someone can help here because this is a show stopper problem right now.
I have a couple of buttons and check boxes used to swich the audio path. The simplest one (big button) on the surface surface is connected to a switch to turn the signal off (like a mute button). I have the value of the button in the paramaters and in thepreset list. All seems to work great, except....
If the button is on when I save the project, when I load it again, the button is still set but does not work. If press the button turning off, then again to turn it back on, it works. If I load the preset it also works, but not when loaded from the project.
If I load the project via the sdk, I find that on load, the button val is some large randon number like 3342523. But the button values limit is 0 and 1. Once I click the button it sets to 0 or 1 and all is fine.
The paramater list does have restore on project set so it seems like it should load the value. It acts like the displayed state of the button is saved and restored but not the val var on load. THe switches require 0 for off, 1 for on and anything else is off.
A second issue (which is the same) is i use a check box to select either 1 or 5 from a 1-6 selector. The button is set to min 1. max 5, step 5 (I forget the exact values) and all works fine except when the project loads the val is random again so nothing is selected until I click the button.
Seems like this should be a simple problem but I have yet to figure out how to correct this problem.
Anyone know why this is happening?

#### Re: restoring of button state

Posted: Tue Nov 10, 2009 7:47 am
by voidar
Are the buttons referencing the circuit directly or are they connected to val-fields? I think it is good practice to use val-fields and store these in the preset list. Be carefull with the val-range on these though.
A thing I have noticed is that some things work different in SDK versus SFP.

#### Re: restoring of button state

Posted: Tue Nov 10, 2009 9:14 am
by winger
I connect the button val to the switch control input (select the button on surface, click on val in pad list, click save, go to curcuit view, click on the switch, select the switch control in pad list, then click connect) .
The vals are stored in parameters list and preset list.

#### Re: restoring of button state

Posted: Tue Nov 10, 2009 9:41 am
by voidar
You should create an identical non-surface (circuit button) which interfaces with the rest of the circuit (switch).
Then connect the surface button val to the circuit button val. The circuit button val should be stored in the preset list, not the other way around.
I think this is important because GUI is loaded last and you will thus have a broken circuit.
The circuit button could be a val-field too; though that is not so interactive when designing.

#### Re: restoring of button state

Posted: Wed Nov 11, 2009 1:37 am
by roy thinnes
hi winger,
there are always some mysterious parts in your posts - like this:

> If I load the project via the sdk, I find that on load, the button val is some large randon number like 3342523

mpf. if you load eg the onOff button, default values are 0 and 1; no random values and such.
I think first thing to do should be to get things running the way it should be. meaning an onOff button should output values 0 for off, 1 for on (except you had defined different values).
after your circuit is running ok, you can take care of presets.

> The button is set to min 1. max 5, step 5 (I forget the exact values)

step 4 in this case, otherwise it will not work.

#### Re: restoring of button state

Posted: Wed Nov 11, 2009 8:33 am
by winger
Right, it was set as you said. I found the problem. I also found the problem with the crashing of spf if I remove the outout nodes from my device(desribed in another thread).
I found that there was a pot pad connected to the switch, but there is no pot. In the other thread I said I started with an empty synth and deleted the synth outputs, but the pads remained. The exported pads showed connect to the syth output which no longer existed. This button connection to a pot existed but there was not pot.
I suspect there is some sort of cleanup problem in the sdk and if you delete a device (like a pot or the synth output) it could have some connections that do not get deleted properly. That is the only explanation I can come up with right now. Seems to have resolved the problems by deleting the phantom pads.