View Full Version : Timer Function?

August 3rd, 2006, 02:54 AM

I am trying to create a timer that I start on the first of many events, then on subsequnt occurences of that event, reset the time, and then finally after the timer expires, trigger yet another event.

Does this make sense?

Is it possible?

Bascially what I have is a device that when you change the volume, is replys with "OK" instead of just giving me the current volume setting. If I want the curretn volume setting, then I have to quesry it.

I tried querying it after each volume setting, but if you pound on volume up or down for any significant time, it will overload the transmit side of the device, and keep Girder busyt for a long time until the queue clears. So what I would like to do instead is this:

set volume on device
set variable that says volume is what I changed
when I receive an "OK" from the device, set a timer for 2 seconds.
If another "OK" string comes in before timer expires, reset the timer to 2 seconds.
else if the timer expires, trigger an event to query the device

I don't have any clue how to implement this or if it is even possible under G33

Any ideas would be appreciated.


Mark F
August 3rd, 2006, 09:59 AM
There are timers available in the WinLUAEx plugin. The interface for these timers is described in the included readme.html document.

Basically, you will create a timer and define the routines that get called when the timer is armed, triggered and canceled. You will then arm the timer for a wait of 2 seconds (2000 ms). You can re-arm the timer (call the arm routine again) any time you would like. Before it expires or after.

When the timer finally expires, the routine you defined will execute and can initiate the query or emit an event to cause a different command to initiate the query.

Does this make sense?

EDIT: There is an example .lua file included in the plugin distribution that may help as well.