To learn Purebasic I'm busy to rewrite my old freebasic routines to Purebasic
For my beerbrewing proces I need a simple timer to control the mash- and boiling process.
Thats the reason its only in minutes.
Later I have the intention to make a more universal timer "hours minutes seconds milliseconds).
Can you offer an improvement/correction... then I'll read it
Rudy M
Code: Select all
Define.l Time_desired, Time_start, rest
;=======================================================================
Procedure.l Timer_min (Minutes.l)
;Most little value of variable 'minutes' is 1
;Other timers in the same listing can be: Timer_sec Timer_millisec ...
;You can easely extend this timer to a universal procedure
;p.e: Timer (hours - minutes - seconds - milliseconds)
Define.l Time_difference, Time_start ;or should it be better Protected...???
Define.s key , key2, dummy
Time_start = ElapsedMilliseconds ()
Time_end = Time_start + Minutes * 60000 ; 1 Minute = 60sec * 1000ms
;If You do not need this info delete following 2 lines
Debug "Starttime:" + Str(Time_start)
Debug "Endtime..:" + Str(Time_end)
Repeat
;-------------------------START ACTION---------------------
;Possible place for actions:
;P.E.: Read T-sensor(s)
; Print on screen Temperatures
; Decisions on temperatures: Heaterelement(s) ON - OFF
;Pratical ex.: Controlling a mash proces for beerbrewing.
;----------------------------------------------------------
;Calling other procedures:
;but NEVER procedures who takes longtime during actions!!!
;P.E. In a beerbrewing process:
;Play a short Alarmsound + Debug "Add + hop name + quantity"
;--------------------------END AKTION----------------------
Time_difference = Time_end - ElapsedMilliseconds()
If Time_difference <= 0
;Possible place to play an alarm sound
;I made mp3 files;
;A mix of Alarmsound and my own voice: "End Maish period one... two... three...").
;Here for safety You could call a procedure to put all heaterelements OFF
;Etc...
;Added for controlling purposes:
ProcedureReturn Time_difference /60000 ; 0 devided by 60000 stays nul...
Break
EndIf
ForEver
;Added for controlling purposes:
ProcedureReturn Time_difference /60000 ; 0 devided by 60000 stays nul...
EndProcedure
Time_desired = 1 ;In Minutes
Debug "Desired time: " + Str (Time_desired) + " Minutes"
rest = Timer_min (Time_desired)
Debug "Rest_time :" + Str(rest/60) + " minutes."