variable ramping
Could someone explain bit by bit how to ramp a variable. I did a search but did not find any info to answer my question.
I am wanting to understand this line of code. I know what it does but don't understand how it does.
volume := ++volume <# 32
in the program the line slowly raises the volume variable on my wav player.
I am also interested in how to decrease the variable as well.
thanks,
stilgar
I am wanting to understand this line of code. I know what it does but don't understand how it does.
volume := ++volume <# 32
in the program the line slowly raises the volume variable on my wav player.
I am also interested in how to decrease the variable as well.
thanks,
stilgar

Comments
http://www.parallax.com/Portals/0/Downloads/docs/prod/prop/Web-PropellerManual-v1.2.pdf
volume := volume + 1
volume := volume <# 32
If you write volume++ in an expression, that's called a post increment. So, first the value of volume is read and used in the rest of the expression and then it is increased. This of course would not make sense in this expression.
stilgar
volume := --volume #> 0
Every time this line is executed 1 is added to the 'volume' variable up to a maximum of 32. I think it helps to learn to state a line of code in plain english.
As in the following example.
LED Throb - steps up and down by 2.
{ Throb.Spin } CON _CLKMODE=XTAL2 _XINFREQ =5_000_000 MSec = _XINFREQ / 1_000 USec = _XINFREQ / 1_000_000 T500U = Usec * 500 T300M = Msec * 300 Tsteps= 50 VAR Byte X, LED PUB Throb LED := 23 dira [LED] :=1 Repeat ' going up Repeat X from 1 to Tsteps step 2 outa[LED] := 1 waitCNT ((X*T500U) +cnt) outa[LED] := 0 waitCNT ((Tsteps-X+1)*T500U+cnt) outa[LED] := 1 waitcnt(T300M +cnt) 'going down Repeat X from 1 to Tsteps step 2 outa[LED] := 1 waitCNT ((Tsteps-X+1)*T500U+cnt) outa[LED] := 0 waitCNT ((X*T500U) +cnt) waitcnt (T300M*2 +cnt)I always think of the "> <" symbols as hungry mouths. They're always open to the larger item, and when used as a limit they also get to eat a number sign.