Jump to content
Sign in to follow this  
Guest zip

TICK18, ELAPSED_SECONDS max value?

Recommended Posts

Guest christian

I'd like to program a blinking string (I searched and found a good post, but I pretty much know how to do this anyway), and I have one small question.If I record a time_start and measure the time elapsed since time_start was set (eg elapsed_seconds - time_start > 0.5 ), I could get a problem when elapsed seconds overflows and restarts at 0. Does anyone know what the maximum value ELAPSED_SECONDS can reach (it's a float in the panel, so the max should be so high that I don't have to worry about it, but that does not mean that it's float in FS itself, it could just be UINT16, which isn't very large at all). I think TICK18 is a UINT16, so one really has to check here, but is this the case with ELASPED_SECONDS also? And does anyone know if ELAPSED_SECONDS is a true float in that it measures second fractions (not hard to find out myself, just asking if anyone knows).Reading the other post on blinking strings, I can get away with just a 'elapsed_time % 0.5' of course, but there are other cases where I actually want to measure a time difference (eg is button pressed for 3 sec), where this is quite important, to avoid a possible buffer overfow when a flight is several hours long...Cheers, Christian

Share this post


Link to post
Share on other sites

Christian,ELAPSED_SECONDS is indeed a float. It resets to zero at midnight (Z, I believe, although it may be local time - I don't remember for sure.)TICK18 will also reset when it reaches a maximum value.Given the potential goofy results, I always liked to be sure:time_then = time_now;time_now = TICK18;time_increase = time_now - time_then;if (time_increase < 0) {time_increase = 0;)accumulated_time = accumulated_time + time_increase;Also, TICK18 increments even when the sim is paused. ELAPSED_SECONDS does not.Regards,Doug Dawson

Share this post


Link to post
Share on other sites
Guest christian

Brilliant. Thanks, Doug. That's exactly what I was after.Cheers, Christian

Share this post


Link to post
Share on other sites
Guest zip

Or, use a windows timer, it's asynchronous and calls a callback routine in your gauge when you want.You can have several timers, and they will only fire on a set interval specified in miliseconds, and you don't have to worry about overflow, timezones, or whatever.Lookup SetTimer() and KillTimer() in the Win32 API (msdn.microsoft.com).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...