I have some code to increase or decrease a 16 bit variable and display it on a LCD (using the terminal for now). IT is working fine but my code may be cumbersome.
But I need a way to increase my step size of my increment based on how long an input pin is depressed. So every 5 seconds increase the step size by a factor of 10 until it is released then set the step size back to 1.
I am not sure how to do this. Is there any feature for this?
Here is my code:
<code><pre><font size=2 face='Courier'>
'Frequency range is limited to 1 to 9999
'Display as frequency / 10,000 on the LCD
Symbol Frequency = W0
Symbol Stepsize = W1
Stepsize = 1
'Stepsize=10
'Stepsize=100
'Stepsize=1000
Main:
If pin2 = 1 then incfreq
if pin3 = 1 then decfreq
goto main
Incfreq:
pause 250
If Frequency>9998 then limitMax:
Frequency = Frequency+Stepsize
Goto LCDOUT
Limitmax:
Frequency = 9999
Goto LCDOUT
Decfreq:
pause 250
If Frequency<2 then limitMin:
Frequency = Frequency-Stepsize
Goto LCDOUT
Limitmin:
Frequency = 1
goto LCDOUT
LCDOUT:
If Frequency <10 then display10
If Frequency <100 then display100
If Frequency <1000 then display1000
If Frequency <10000 then display10000
Display10:
Sertxd("0.000",#Frequency,13,10)
goto main
Display100:
Sertxd("0.00",#Frequency,13,10)
goto main
Display1000:
Sertxd("0.0",#Frequency,13,10)
goto main
Display10000:
Sertxd("0.",#Frequency,13,10)
Goto Main
</font></pre></code>
But I need a way to increase my step size of my increment based on how long an input pin is depressed. So every 5 seconds increase the step size by a factor of 10 until it is released then set the step size back to 1.
I am not sure how to do this. Is there any feature for this?
Here is my code:
<code><pre><font size=2 face='Courier'>
'Frequency range is limited to 1 to 9999
'Display as frequency / 10,000 on the LCD
Symbol Frequency = W0
Symbol Stepsize = W1
Stepsize = 1
'Stepsize=10
'Stepsize=100
'Stepsize=1000
Main:
If pin2 = 1 then incfreq
if pin3 = 1 then decfreq
goto main
Incfreq:
pause 250
If Frequency>9998 then limitMax:
Frequency = Frequency+Stepsize
Goto LCDOUT
Limitmax:
Frequency = 9999
Goto LCDOUT
Decfreq:
pause 250
If Frequency<2 then limitMin:
Frequency = Frequency-Stepsize
Goto LCDOUT
Limitmin:
Frequency = 1
goto LCDOUT
LCDOUT:
If Frequency <10 then display10
If Frequency <100 then display100
If Frequency <1000 then display1000
If Frequency <10000 then display10000
Display10:
Sertxd("0.000",#Frequency,13,10)
goto main
Display100:
Sertxd("0.00",#Frequency,13,10)
goto main
Display1000:
Sertxd("0.0",#Frequency,13,10)
goto main
Display10000:
Sertxd("0.",#Frequency,13,10)
Goto Main
</font></pre></code>