¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Slowing Down For Loop In SImpl+ #simpl


 

I am using a For loop in simpl+? to increase and decrease and analog value and its working, But i also need to slow down the rate at which it steps through. does anyone know a way to make that step to happen in a like 1 sec rate ??


 

It¡¯s crude, but you can use Delay(100) to halt for 1sec
my S+ is a bit rusty though! ;)


 
Edited

Use a function instead of a for loop. Create a function with a wait inside it. After the wait, call your function again. Use necessary logic before your wait.


 
Edited

While I haven't confirm this will work for volume volume ramps, you might try using the SIMPL+ CreateRamp function.? It's mainly used to ramp lighting load.? CreateRamp uses Ramp Control Blocks (RCBs).? You can specified the ramp rate, upper and lower bounds, and the target value after ramping is complete.? To stop the ramp in progress, you use the StopRamp function. So use the CreateRamp to start your ramp and StopRamp to stop it.? While designed to ramp lighting loads,? I see no reason off hand why it wouldn't work for volume control.? Just be careful what is downstream as not all SIMPL symbol will pass RCBs.

Steve


 

I did this for a countdown timer (like an egg timer), and it has a cancel button, so needed an easy stop. I did it with a function, and a delay.
?
Integer_Function countdown(integer _countdown_seconds)
{
? ? integer i;
? ?
for(i = 0 to (_countdown_seconds * 2)) // Time number format = 1s is integer value 100
{
if(!countdown_cancel_flag)
{
Delay(50); //this equals 1/2 second
current_time = countdownSecondsInteger - (i/2);
}
else
{
? ? ? ? countdown_cancel_flag = 0;
return(0);
}
}
return(1);
}


 

FUNCTION GetStrings(integer presetNum)
{
Integer i;
? ? For (i = 0 TO ArraySize-1)
{
StringData[i+1] = PresetListsObj.GetStringData(presetNum-1, i);
delay (100);
}
}
?


 

Had no idea that existed, Actually Dimming a videowall so the context it perfect. works great thanks !


 
Edited

Why do you need SIMPL+ for this though? :/ There's a variable oscillator in SIMPL. Although if you use a for loop to change a delay then you're also tying up a thread that could be used to do other things in the system indefinitely until the for loop exits as well. (Wait / RetimeWait / CancelWait / PauseWait / ResumeWait / etc.)

--
?
Crestron Service Provider - TBD Enterprises Inc.


 

¿ªÔÆÌåÓý

Can simpl+ support async for this for loop with a delay??

On Sep 13, 2022, at 1:41 PM, Troy Garner <troy_garner@...> wrote:

Why do you need SIMPL+ for this though? :/ There's a variable oscillator in SIMPL. Although if you use a for loop to change a delay then you're also tying up a thread that could be used to do other things in the system indefinitely until the for loop exits as well.

--
?
Crestron Service Provider - TBD Enterprises Inc.



 

Guys/gals, please don't put a wait or delay in a for loop. It's just bad from my experience. I'm on my phone, so this may not be perfect, but you'll get the idea.?

Integer x;

Function fnLoop()
{
? If(x<10)
? {
? ? ? X=x+1;
? ? ? // do needed code here with x
? ? ? wait(10) fnLoop();
? }
? Else
? ? ? X=0;
}


 
Edited

Doing loops with delays over complicates things. You need to think about doing a different method. No loops at all are required if you use the CreateRamp and StopRamp functions.?

For example, assume you have a raise button.? When you press the raise button, you execute a SIMPL+ CreateRamp function and then return.? When you release the button, you call the StopRamp function and return.? Very simple and no loops or delays are required.? If you just need to ramp to a particular level, just call the CreateRamp function with the appropriate target value and you are done.


 

Agree with Steve,

I've used the CreateRamp & StopRamp functions and they work well.
Read the help file - it's helpful :)