Results 1 to 4 of 4
  1. #1
    75+ Posting Member
    Join Date
    Oct 2012
    Location
    London ON, CA
    Posts
    106
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    SIOC simple clock display

    Hi so I made a simple sioc code to display my clock using 7segment displays and Displays2 card from Opencockpits, but I have little problem...

    Here is the code:

    Code:
    // ----------------------  CLOCK ----------------
    
    Var 9014, name Local_Year_Dis, Link IOCARD_DISPLAY, Device 31, Digit 3, Numbers 4
    Var 9006, name Zulu_Day_Hour, Link IOCARD_DISPLAY, Device 31, Digit 9, Numbers 2 
    Var 9007, name Zulu_Day_Min, Link IOCARD_DISPLAY, Device 31, Digit 7, Numbers 2
    Var 9008, name Local_Day_Hour, Link IOCARD_DISPLAY, Device 31, Digit 5, Numbers 2 
    Var 9009, name Local_Day_Min, Link IOCARD_DISPLAY, Device 31, Digit 3, Numbers 2
    
    
    Var 9001, name Zulu_Hour, link FSUIPC_INOUT, offset $023B, length 1 
    {
    CALL &Show_Display
    }
    Var 9002, name Zulu_Minute, link FSUIPC_INOUT, offset $023C, length 1 
    {
    CALL &Show_Display
    }
    Var 9003, name Local_Hour, link FSUIPC_INOUT, offset $0238, length 1 
    {
    CALL &Show_Display
    }
    Var 9004, name Local_Minute, link FSUIPC_INOUT, offset $0239, length 1 
    {
    CALL &Show_Display
    }
    Var 9010, name Local_Month, link FSUIPC_INOUT, offset $0244, length 1 
    {
    CALL &Show_Display
    }
    Var 9011, name Local_Day, link FSUIPC_INOUT, offset $023D, length 1 
    {
    CALL &Show_Display
    }
    Var 9013, name Local_Year, link FSUIPC_INOUT, offset $024A, length 2
    {
    CALL &Show_Display
    }
    
    Var 9012, name TIME, Link IOCARD_SW, Device 31, Input 40
    {
    CALL &Show_Display
    }
    
    Var 9005, name Show_Display, Link SUBRUTINE 
    
    {
    IF &TIME = 0
    {
    &Zulu_Day_Hour = &Zulu_Hour 
    &Zulu_Day_Min  = &Zulu_Minute
    &Local_Day_Hour = &Local_Hour 
    &Local_Day_Min  = &Local_Minute
    }
    IF &TIME = 1
    {
    &Zulu_Day_Hour = &Local_Month
    &Zulu_Day_Min  = &Local_Day
    &Local_Year_Dis  = &Local_Year
    }
    }
    Basically clocks displays in upper display ZULU Time in lower Display it shows LOCAL Time, when I press a Momentary switch Upper display shows Month/Day
    Lower display shows year
    now when i release the button Upper display nicely returns to show ZULU time when lower displays is stuck on showing the year
    when one minute elapses MINUTE digits on lower display will change to show Local minutes
    when hour elapses HOUR digits will change also on lower display to show Local hours
    ... so ... how can i make it speed up so that IDK.. sioc of FSUIPC gets the value updated quicker for the Local Time
    I suspect there is a problem with declaration on top where i declare Var 9014 uses digits from var 9008 and 9009 so somehow i have to force SIOC or FSUIPC to somehow check for updated value for Var 9008 and 9009 quicker ...
    well i hope I'm explaing myself correctly
    Any help is appriciated

    Andy

    https://www.facebook.com/photo.php?f...type=3&theater

  2. #2
    2000+ Poster - Never Leaves the Sim kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    2,200
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: SIOC simple clock display

    Hi Andy,

    The problem lies in the overlap of display digit definitions, but there is no need to let FSUIPC update quicker.
    You bettter do the same as what you already have done for Month and Day: assign (the same) digits different variables depending on the value of variable TIME.

    Try this:
    Code:
    // ----------------------  CLOCK ----------------
    
    
    Var 9006 name Zulu_Day_Hour Link IOCARD_DISPLAY Device 31 Digit 9 Numbers 2 
    Var 9007 name Zulu_Day_Min Link IOCARD_DISPLAY Device 31 Digit 7 Numbers 2
    Var 9008 name Local_Day_Hour Link IOCARD_DISPLAY Device 31 Digit 5 Numbers 2 
    Var 9009 name Local_Day_Min Link IOCARD_DISPLAY Device 31 Digit 3 Numbers 2
    
    
    Var 9001 name Zulu_Hour link FSUIPC_IN offset $023B length 1 
    {
      CALL &Show_Display
    }
    
    
    Var 9002 name Zulu_Minute link FSUIPC_IN offset $023C length 1 
    {
      CALL &Show_Display
    }
    
    
    Var 9003 name Local_Hour link FSUIPC_IN offset $0238 length 1 
    {
      CALL &Show_Display
    }
    
    
    Var 9004 name Local_Minute link FSUIPC_IN offset $0239 length 1 
    {
      CALL &Show_Display
    }
    
    
    Var 9010 name Local_Month link FSUIPC_IN offset $0244 length 1 
    {
      CALL &Show_Display
    }
    
    
    Var 9011 name Local_Day link FSUIPC_IN offset $023D length 1 
    {
      CALL &Show_Display
    }
    
    
    Var 9013 name Local_Year link FSUIPC_IN offset $024A length 2
    {
      CALL &Show_Display
    }
    
    
    Var 9012 name TIME Link IOCARD_SW Device 31 Input 40
    {
      CALL &Show_Display
    }
    
    
    Var 9005 name Show_Display Link SUBRUTINE 
    {
      IF &TIME = 0
      {
        &Zulu_Day_Hour = &Zulu_Hour 
        &Zulu_Day_Min  = &Zulu_Minute
        &Local_Day_Hour = &Local_Hour 
        &Local_Day_Min  = &Local_Minute
      } 
      ELSE 
      {
        &Zulu_Day_Hour = &Local_Month
        &Zulu_Day_Min  = &Local_Day
        &Local_Day_Hour = DIV &Local_Year 100
        &Local_Day_Min  = MOD &Local_Year 100
      }
    }
    Note some "SIOC improvements" I've made:
    I have changed FSUIPC_INOUT into FSUIPC_IN while you are only reading from FSUIPC. FSUIPC_INOUT was not "wrong" but not needed.
    I've also used an IF THEN statement for TIME, because if TIME is not 0 you do not have to test it for value 1, it will be 1 ...
    Comma's are not needed as token separator in a SIOC script, 'whitespace' will do.

    regards,
    Nico Kaan
    Last edited by kiek; 10-12-2015 at 03:39 AM.

  3. Thanks AndyCYXU thanked for this post
    Likes AndyCYXU liked this post
  4. #3
    75+ Posting Member
    Join Date
    Oct 2012
    Location
    London ON, CA
    Posts
    106
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: SIOC simple clock display

    Thank You Nico, works like a "clock" lol
    never though that you can just divide "DIV" 2015 by 100 and it will send 20 makes perfect sense, but i do have a question what does the MOD statement do?

    after looking at your site where you explain
    Suppress (blank) leading zeroes in a display

    I am kind of thinking....
    that this MOD gives you .. well kinda like this:
    say we have Variable YEAR which equals 2015
    so using MOD
    MOD &year 10 would give us 015
    MOD &year 100 would give us 15
    MOD &year 1000 would give us 5

    I'm guessing it can be used for other variable for computing something not just for display. say we have some variable that will be equal 7345 (just an example) but we are only concern about the last say 2 digits of this variable xx45 so we could go and MOD the value of this variable by 100 which gives us 45 only?

    am i understanding it right?

    Thanks
    Andy

  5. #4
    2000+ Poster - Never Leaves the Sim kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    2,200
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: SIOC simple clock display

    Hi Andy,

    MOD stands for Modulo, an arithmetic operation, read more here: https://en.wikipedia.org/wiki/Modulo_operation

    And yes, it can be used in any computation, not just for digits.

    If Year = 2015, then:

    MOD &Year 10 = 5
    MOD &Year 100 = 15
    MOD &Year 1000 = 15

    rgrds,
    Nico
    Last edited by kiek; 10-12-2015 at 01:57 PM.

  6. Thanks AndyCYXU thanked for this post
    Likes AndyCYXU liked this post