1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

FSXA Need help writing a custom digital clock

Discussion in 'Gauges' started by delivery guy, 12 Aug 2017.

  1. delivery guy

    delivery guy

    Joined:
    31 Jan 2010
    Messages:
    1,526
    Country:
    unitedstates
    Writing a code for the Davtron 811 clock!

    I know how to write a standard digital clock and a elapsed timer. But i need a custom clock.
    So far i have the system time converted to my LVAR on aircraft load. Maybe the elapsed timer plus the system load time is the trick. I just now realized this as i am writing this post.

    But now i want to be able to zero the seconds and add minutes and hours.
    I have done this with analog but for the digital i am having issues.

    And i do not want to use the default events that can change the system time. I only want to add or subtract time from the system time using LVARS.

    I tried using E:absolute time, seconds and LVAR ++ LVAR for seconds but when it got to 60 seconds it just kept increasing.

    Can someone shed some light or post some examples please.

    [​IMG]
     
    Last edited: 12 Aug 2017
  2. Luka

    Luka Resource contributor

    Joined:
    21 Jan 2011
    Messages:
    180
    Country:
    yugoslavia
    Maybe something like this...
    Code:
    <Update>
        (L:M111_delta,seconds) d 0 %lt; if{ 86400 + } (E:ZULU TIME,Seconds) + 86400 %
        d 3600 / flr (>L:M111_H,number)
        d 60 / flr 60 % (>L:M111_M,number)
        flr 60 %  (>L:M111_S,number)
    </Update>

    hour inc.
    Code:
    <Click>
        (L:M111_H,number) ++ 24 % (>L:M111_H,number)
        (L:M111_H,number) 3600 * (L:M111_M,number) 60 * + (L:M111_S,number) + (E:ZULU TIME,Seconds) - (>L:M111_delta,seconds)
    </Click>

    minute inc.
    Code:
    <Click>
        (L:M111_M,number) ++ 60 % (>L:M111_M,number)
        (L:M111_H,number) 3600 * (L:M111_M,number) 60 * + (L:M111_S,number) + (E:ZULU TIME,Seconds) - (>L:M111_delta,seconds)
    </Click>

    sec. reset
    Code:
    <Click>
        0 (>L:M111_S,number)
        (L:M111_H,number) 3600 * (L:M111_M,number) 60 * + (L:M111_S,number) + (E:ZULU TIME,Seconds) - (>L:M111_delta,seconds)
    </Click>
    L:M111_H/M/S - "L" vars for hours, minutes and seconds,
    L:M111_delta - difference (offset) from FS time.
     
    antaris likes this.
  3. delivery guy

    delivery guy

    Joined:
    31 Jan 2010
    Messages:
    1,526
    Country:
    unitedstates
    First thing is thank you very much for helping me with this formula to create a custom clock.

    Working great!:)

    Oh and what does the 86400 value for?
     
    Last edited: 13 Aug 2017
  4. Luka

    Luka Resource contributor

    Joined:
    21 Jan 2011
    Messages:
    180
    Country:
    yugoslavia
    86400 is the number of seconds per day. It's here because the calculated "LVar" time can be negative or greather than 24 hours, and must be normalized to a value between 0 and 23:59:59.

    I'm glad to help you :)
     
  5. delivery guy

    delivery guy

    Joined:
    31 Jan 2010
    Messages:
    1,526
    Country:
    unitedstates
    That makes sense. I finished the entire gauge yesterday and the gauge now works exactly like the real clock. So thanks again!
     

Share This Page