Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 07:20 18 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Timer Help

Author Message
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 09:54pm 02 Jan 2013
Copy link to clipboard 
Print this post

To all the wonderfull people on the TBS
A little help please

Does anybody have a timer routine (not pause)
Example input changes state (Timer goes here) then action
It will need to know the timer is already running as to not restart it
I have a few different scenario's that all need to use a timer so it will need to have values passed to it

My first attempt is as follows

TimerSub 1000, Set ' Check Set = 2 for time complete
' Set = 0 to restart timer
' Set = 1 timer in progress

Sub TimerSub Period, Set
If Set >= 1 Then Exit Sub
SetTick period, PTimer
Set = 1
End Sub

PTimer:
Set = 2 ' This would become UserTimer_Name
SetTick 0, 0
IReturn

This works but is a problem when in the main program loop

If I could figuer out a way to create (UserTimer_Name) when using
TimerSub 1000, Set, UserTimer_Name) then all would be solved

If (UserTimer_Name) = 2 Then GoSub BlahBlah
If (UserTime_Name) = 1 Then Return


Many Thanks

John
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 11:12pm 02 Jan 2013
Copy link to clipboard 
Print this post

Why not have the PTimer routine handle the different (UserTimer_Name).

PTimer:
Set = Set + 1
On Set gosub SubRoutine1,Subroutine2, .... etc
IReturn

Microblocks. Build with logic.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025