Results 1 to 6 of 6
  1. #1
    25+ Posting Member
    Join Date
    Nov 2005
    Location
    Derby, UK
    Posts
    44
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Code help for ColdandDark and TestOvhd for Latitude and Longitude script

    Hi Nico,

    I have just finished making a Longitude and Latitude panel using the code that was in a thread on your forum (can't seem to find it now but would like to thank the poster). It works very well but is on all the time due to the lack of ColdandDark code as well as no code for the TestOvhd. I have tried various code but the difficulty for me is that the code uses two fsuipc offsets for each part. If you have the time would you please have a look at it for me.

    The code is as follows:

    Regards
    Mick

    Code:
    Var 2114 Link FSUIPC_IN Offset $0564 Length 4 // HI of LAT 
    
    Var 2115 Link FSUIPC_IN Offset $0560 Length 4 // LO of LAT 
    {  
      &O_DP = 1
      &O_DP1 = 1 
      L1 = V2114 
      L0 = V2115 
      IF L0 < 0 // convert to unsigned 
    { 
      L0 = L0 + 4294967296 
    } 
      L0 = L0 / 4294967296 
      IF L1 > 0 // Now, if negative is S, positive is North 
    { 
      L2 = L1 + L0 
      &O_North = 1 
      &O_South = 0 
    } 
      ELSE 
    { 
      L2 = L1 - L0 
      &O_South = 1 
      &O_North = 0 
    } 
      L2 = L2 * 90 
      L2 = L2 / 10001750 
      IF L2 < 0 
    { 
      L2 = L2 * -1 
    } 
      &Lat_Deg = TRUNC L2 // Convert to Degrees 
      L2 = L2 - &Lat_Deg 
      L2 = L2 * 10000 
      L2 = L2 * 0.6 // 60/100 for mins. 
      &Lat_Min = DIV L2 ,100 // Mins 
      L0 = &Lat_Min * 100 
      L2 = L2 - L0 // Secs 
      L2 = L2 / 10 
      &Lat_Sec = TRUNC L2 
    }
    
    Var 2116 name Lat_Deg Link IOCARD_DISPLAY Digit 131 Numbers 2 // LAT degrees 
    Var 2117 name Lat_Min Link IOCARD_DISPLAY Digit 129 Numbers 2 // LAT min 
    Var 2118 name Lat_Sec Link IOCARD_DISPLAY Digit 128 Numbers 1 // LAT sec 
    
    var 2119 name O_North Link IOCARD_OUT Device 4 Output 59   
    var 2120 name O_South Link IOCARD_OUT DEVICE 4 Output 60  
    var 2121 name O_DP Link IOCARD_OUT Output 87
    var 2122 name O_DP1 Link IOCARD_OUT Output 89
    
    Var 2123 Link FSUIPC_IN Offset $056C Length 4 // HI of Lon 
    
    Var 2124 Link FSUIPC_IN Offset $0568 Length 4 // LO of Lon 
    {
      &O_DP2 = 1
      &O_DP3 = 1 
      L1 = V2123 
      L0 = V2124 
      IF L0 < 0 // convert to unsigned 
    { 
      L0 = L0 + 4294967296 
    } 
      L0 = L0 / 4294967296 
      IF L1 > 0 // Now, if negative is West, positive is East 
    { 
      L2 = L1 + L0 
      &O_East = 1 
      &O_West = 0 
    } 
      ELSE 
    { 
      L2 = L1 - L0 
      &O_West = 1 
      &O_East = 0 
    } 
      IF L2 < 0 
    { 
      L2 = L2 * -1 
    } 
      L2 = L2 * 360 
      L2 = L2 / 4294967296 
      &Lon_Deg = TRUNC L2 // Convert to Degrees 
      L2 = L2 - &Lon_Deg 
      L2 = L2 * 10000 
      L2 = L2 * 0.6 // 60/100 for mins. 
      &Lon_Min = DIV L2 ,100 // Mins 
      L0 = &Lon_Min * 100 
      L2 = L2 - L0 // Secs 
      L2 = L2 / 10 
      &Lon_Sec = TRUNC L2 
    } 
    
    Var 2125 name Lon_Deg Link IOCARD_DISPLAY Digit 136 Numbers 3 // Lon degrees 
    Var 2126 name Lon_Min Link IOCARD_DISPLAY Digit 134 Numbers 2 // Lon min 
    Var 2127 name Lon_Sec Link IOCARD_DISPLAY Digit 133 Numbers 1 // Lon sec 
    
    var 2128 name O_West Link IOCARD_OUT DEVICE 4 Output 57
    var 2129 name O_East Link IOCARD_OUT DEVICE 4 Output 58
    var 2130 name O_DP2 Link IOCARD_OUT Output 91
    var 2131 name O_DP3 Link IOCARD_OUT Output 93

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

    Re: Code help for ColdandDark and TestOvhd for Latitude and Longitude script

    Hi Mick,

    Here you are:
    Code:
    Var 2114 Link FSUIPC_IN Offset $0564 Length 4 // HI of LAT 
    
    Var 2115 Link FSUIPC_IN Offset $0560 Length 4 // LO of LAT 
    {  
      L1 = V2114 
      L0 = V2115 
      IF L0 < 0 // convert to unsigned 
      { 
        L0 = L0 + 4294967296 
      } 
      L0 = L0 / 4294967296 
      IF L1 > 0 // Now, if negative is S, positive is North 
      { 
        L2 = L1 + L0 
        &North = 1 
        &South = 0 
      } 
      ELSE 
      { 
        L2 = L1 - L0 
        &South = 1 
        &North = 0 
      } 
      L2 = L2 * 90 
      L2 = L2 / 10001750 
      IF L2 < 0 
      { 
        L2 = L2 * -1 
      } 
      &LatDeg = TRUNC L2 // Convert to Degrees 
      CALL &OutLatDeg
      L2 = L2 - &LatDeg
      L2 = L2 * 10000 
      L2 = L2 * 0.6 // 60/100 for mins. 
      &LatMin = DIV L2 ,100 // Mins 
      CALL &OutLatMin
      L0 = &LatMin * 100 
      L2 = L2 - L0 // Secs 
      L2 = L2 / 10 
      &LatSec = TRUNC L2 
      CALL &OutLatSec
    }
    
    Var 2140 name LatDeg
    Var 2141 name LatMin
    Var 2142 name LatSec
    Var 2143 name North
    Var 2144 name South
    
    Var 2150 name OutLatDeg Link SUBRUTINE
    {
      IF &ColdAndDark = 1
      {
        &Lat_Deg = -999999
      }
      ELSE
      {
        IF &TestOvhd = 1
        {
          &Lat_Deg = 88
        }
        ELSE
        {
          &Lat_Deg = &LatDeg
        }
      }
    }
    
    Var 2151 name OutLatMin Link SUBRUTINE
    {
      IF &ColdAndDark = 1
      {
        &Lat_Min = -999999
      }
      ELSE
      {
        IF &TestOvhd = 1
        {
          &Lat_Min = 88
        }
        ELSE
        {
          &Lat_Min = &LatMin
        }
      }
    }
    
    Var 2152 name OutLatSec Link SUBRUTINE
    {
      IF &ColdAndDark = 1
      {
        &Lat_Sec = -999999
        &O_DP = 0
        &O_DP1 = 0
        &O_North = 0
        &O_South = 0
      }
      ELSE
      {
        &O_DP = 1
        &O_DP1 = 1
        IF &TestOvhd = 1
        {
          &Lat_Sec = 8
          &O_North = 1
          &O_South = 1
        }
        ELSE
        {
          &Lat_Sec = &LatSec
          &O_North = &North
          &O_South = &South
        }
      }
    }
    
    Var 2116 name Lat_Deg Link IOCARD_DISPLAY Digit 131 Numbers 2 // LAT degrees 
    Var 2117 name Lat_Min Link IOCARD_DISPLAY Digit 129 Numbers 2 // LAT min 
    Var 2118 name Lat_Sec Link IOCARD_DISPLAY Digit 128 Numbers 1 // LAT sec 
    
    var 2119 name O_North Link IOCARD_OUT Device 4 Output 59   
    var 2120 name O_South Link IOCARD_OUT DEVICE 4 Output 60  
    var 2121 name O_DP Link IOCARD_OUT Output 87
    var 2122 name O_DP1 Link IOCARD_OUT Output 89
    
    Var 2123 Link FSUIPC_IN Offset $056C Length 4 // HI of Lon 
    
    Var 2124 Link FSUIPC_IN Offset $0568 Length 4 // LO of Lon 
    {
      L1 = V2123 
      L0 = V2124 
      IF L0 < 0 // convert to unsigned 
      { 
        L0 = L0 + 4294967296 
      } 
      L0 = L0 / 4294967296 
      IF L1 > 0 // Now, if negative is West, positive is East 
      { 
        L2 = L1 + L0 
        &East = 1 
        &West = 0 
      } 
      ELSE 
      { 
        L2 = L1 - L0 
        &West = 1 
        &East = 0 
      } 
      IF L2 < 0 
      { 
        L2 = L2 * -1 
      } 
      L2 = L2 * 360 
      L2 = L2 / 4294967296 
      &LonDeg = TRUNC L2 // Convert to Degrees 
      CALL &OutLonDeg
      L2 = L2 - &LonDeg 
      L2 = L2 * 10000 
      L2 = L2 * 0.6 // 60/100 for mins. 
      &LonMin = DIV L2 ,100 // Mins
      CALL &OutLonMin 
      L0 = &LonMin * 100 
      L2 = L2 - L0 // Secs 
      L2 = L2 / 10 
      &LonSec = TRUNC L2 
      CALL &OutLonSec
    } 
    
    Var 2160 name LonDeg
    Var 2161 name LonMin
    Var 2162 name LonSec
    Var 2163 name West
    Var 2164 name East
    
    Var 2170 name OutLonDeg Link SUBRUTINE
    {
      IF &ColdAndDark = 1
      {
        &Lon_Deg = -999999
      }
      ELSE
      {
        IF &TestOvhd = 1
        {
          &Lon_Deg = 888
        }
        ELSE
        {
          &Lon_Deg = &LonDeg
        }
      }
    }
    
    Var 2171 name OutLonMin Link SUBRUTINE
    {
      IF &ColdAndDark = 1
      {
        &Lon_Min = -999999
      }
      ELSE
      {
        IF &TestOvhd = 1
        {
          &Lon_Min = 88
        }
        ELSE
        {
          &Lon_Min = &LonMin
        }
      }
    }
    
    Var 2172 name OutLonSec Link SUBRUTINE
    {
      IF &ColdAndDark = 1
      {
        &Lon_Sec = -999999
        &O_DP2 = 0
        &O_DP3 = 0
        &O_West = 0
        &O_East = 0
      }
      ELSE
      {
        &O_DP2 = 1
        &O_DP3 = 1
        IF &TestOvhd = 1
        {
          &Lon_Sec = 8
          &O_West = 1
          &O_East = 1
        }
        ELSE
        {
          &Lon_Sec = &LonSec
          &O_West = &West
          &O_East = &East
        }
      }
    }
    
    Var 2125 name Lon_Deg Link IOCARD_DISPLAY Digit 136 Numbers 3 // Lon degrees 
    Var 2126 name Lon_Min Link IOCARD_DISPLAY Digit 134 Numbers 2 // Lon min 
    Var 2127 name Lon_Sec Link IOCARD_DISPLAY Digit 133 Numbers 1 // Lon sec 
    
    var 2128 name O_West Link IOCARD_OUT DEVICE 4 Output 57
    var 2129 name O_East Link IOCARD_OUT DEVICE 4 Output 58
    var 2130 name O_DP2 Link IOCARD_OUT Output 91
    var 2131 name O_DP3 Link IOCARD_OUT Output 93
    
    Var 999  // or any other free refresh variable number
    {
      &CALL &OutLatDeg
      &CALL &OutLatMin
      &CALL &OutLatSec
      &CALL &OutLonDeg
      &CALL &OutLonMin
      &CALL &OutLonSec
    }
    Notes:
    I have not compiled it , so there may be syntactical errors, but this is the basic schema that should work.
    You have to combine/integrate it with your SIOC code defining ColdAndDark and TestOvhd. Don't know if you are using one single SIOC file or not... If you are using 1 single file you should copy the 6 CALL's from Var 999 into your Refresh routine (and delete var 999).

    kind regards,
    Nico

  3. #3
    25+ Posting Member
    Join Date
    Nov 2005
    Location
    Derby, UK
    Posts
    44
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Code help for ColdandDark and TestOvhd for Latitude and Longitude script

    Hi Nico,

    Thank you very much.

    I tried and knew it was by using a subrutine approach but have to admit was totaly lost.
    I am at work at present, will try it out when I get home.

    Regards
    Mick

  4. #4
    25+ Posting Member
    Join Date
    Nov 2005
    Location
    Derby, UK
    Posts
    44
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Code help for ColdandDark and TestOvhd for Latitude and Longitude script

    Hi Nico,

    I have just tried the code, the ColdandDark and TestOvhd work great but I now have the following:

    When the battery is switched on the digits show zero's and the relevant led's are still off which I think is what should be happening.
    After aligning the IRU's there is no change, the digits are still showing zero's and the relevant led's are still off.
    Below is my amended code.

    Regards
    Mick

    Code:
    Var 1912 Link FSUIPC_IN Offset $0564 Length 4 // HI of LAT 
    
    Var 1913 Link FSUIPC_IN Offset $0560 Length 4 // LO of LAT 
    {  
      &O_DP = 1
      &O_DP1 = 1 
      L1 = V1912 
      L0 = V1913 
      IF L0 < 0 // convert to unsigned 
    { 
      L0 = L0 + 4294967296 
    } 
      L0 = L0 / 4294967296 
      IF L1 > 0 // Now, if negative is S, positive is North 
    { 
      L2 = L1 + L0 
      &O_North = 1 
      &O_South = 0 
    } 
      ELSE 
    { 
      L2 = L1 - L0 
      &O_South = 1 
      &O_North = 0 
    } 
      L2 = L2 * 90 
      L2 = L2 / 10001750 
      IF L2 < 0 
    { 
      L2 = L2 * -1 
    } 
      &Lat_Deg = TRUNC L2 // Convert to Degrees
      CALL &OutLatDeg 
      L2 = L2 - &Lat_Deg 
      L2 = L2 * 10000 
      L2 = L2 * 0.6 // 60/100 for mins. 
      &Lat_Min = DIV L2 ,100 // Mins
      CALL &OutLatMin 
      L0 = &Lat_Min * 100 
      L2 = L2 - L0 // Secs 
      L2 = L2 / 10 
      &Lat_Sec = TRUNC L2
      CALL &OutLatSec 
    }
    
    Var 1914 name LatDeg
    Var 1915 name LatMin
    Var 1916 name LatSec
    Var 1917 name North
    Var 1918 name South
    
    Var 1919 name OutLatDeg Link SUBRUTINE
    {
      IF &ColdAndDark = 1
      {
        &Lat_Deg = -999999
      }
      ELSE
      {
        IF &TestOvhd = 1
        {
          &Lat_Deg = 88
        }
        ELSE
        {
          &Lat_Deg = &LatDeg
        }
      }
    }
    
    Var 1920 name OutLatMin Link SUBRUTINE
    {
      IF &ColdAndDark = 1
      {
        &Lat_Min = -999999
      }
      ELSE
      {
        IF &TestOvhd = 1
        {
          &Lat_Min = 88
        }
        ELSE
        {
          &Lat_Min = &LatMin
        }
      }
    }
    
    Var 1921 name OutLatSec Link SUBRUTINE
    {
      IF &ColdAndDark = 1
      {
        &Lat_Sec = -999999
        &O_DP = 0
        &O_DP1 = 0
        &O_North = 0
        &O_South = 0
      }
      ELSE
      {
        &O_DP = 1
        &O_DP1 = 1
        IF &TestOvhd = 1
        {
          &Lat_Sec = 8
          &O_North = 1
          &O_South = 1
        }
        ELSE
        {
          &Lat_Sec = &LatSec
          &O_North = &North
          &O_South = &South
        }
      }
    }
    
    Var 1922 name Lat_Deg Link IOCARD_DISPLAY Digit 131 Numbers 2 // LAT degrees 
    Var 1923 name Lat_Min Link IOCARD_DISPLAY Digit 129 Numbers 2 // LAT min 
    Var 1924 name Lat_Sec Link IOCARD_DISPLAY Digit 128 Numbers 1 // LAT sec 
    
    var 1925 name O_North Link IOCARD_OUT Device 4 Output 59   
    var 1926 name O_South Link IOCARD_OUT DEVICE 4 Output 60  
    var 1927 name O_DP Link IOCARD_OUT Output 87
    var 1928 name O_DP1 Link IOCARD_OUT Output 89
    
    Var 1929 Link FSUIPC_IN Offset $056C Length 4 // HI of Lon 
    
    Var 1930 Link FSUIPC_IN Offset $0568 Length 4 // LO of Lon 
    {
      &O_DP2 = 1
      &O_DP3 = 1 
      L1 = V1929 
      L0 = V1930 
      IF L0 < 0 // convert to unsigned 
    { 
      L0 = L0 + 4294967296 
    } 
      L0 = L0 / 4294967296 
      IF L1 > 0 // Now, if negative is West, positive is East 
    { 
      L2 = L1 + L0 
      &O_East = 1 
      &O_West = 0 
    } 
      ELSE 
    { 
      L2 = L1 - L0 
      &O_West = 1 
      &O_East = 0 
    } 
      IF L2 < 0 
    { 
      L2 = L2 * -1 
    } 
      L2 = L2 * 360 
      L2 = L2 / 4294967296 
      &Lon_Deg = TRUNC L2 // Convert to Degrees
      CALL &OutLonDeg
      L2 = L2 - &Lon_Deg 
      L2 = L2 * 10000 
      L2 = L2 * 0.6 // 60/100 for mins. 
      &Lon_Min = DIV L2 ,100 // Mins
      CALL &OutLonMin 
      L0 = &Lon_Min * 100 
      L2 = L2 - L0 // Secs 
      L2 = L2 / 10 
      &Lon_Sec = TRUNC L2
      CALL &OutLonSec
    }
    
    Var 1931 name LonDeg
    Var 1932 name LonMin
    Var 1933 name LonSec
    Var 1934 name West
    Var 1935 name East
    
    Var 1936 name OutLonDeg Link SUBRUTINE
    {
      IF &ColdAndDark = 1
      {
        &Lon_Deg = -999999
      }
      ELSE
      {
        IF &TestOvhd = 1
        {
          &Lon_Deg = 888
        }
        ELSE
        {
          &Lon_Deg = &LonDeg
        }
      }
    }
    
    Var 1937 name OutLonMin Link SUBRUTINE
    {
      IF &ColdAndDark = 1
      {
        &Lon_Min = -999999
      }
      ELSE
      {
        IF &TestOvhd = 1
        {
          &Lon_Min = 88
        }
        ELSE
        {
          &Lon_Min = &LonMin
        }
      }
    }
    
    Var 1938 name OutLonSec Link SUBRUTINE
    {
      IF &ColdAndDark = 1
      {
        &Lon_Sec = -999999
        &O_DP2 = 0
        &O_DP3 = 0
        &O_West = 0
        &O_East = 0
      }
      ELSE
      {
        &O_DP2 = 1
        &O_DP3 = 1
        IF &TestOvhd = 1
        {
          &Lon_Sec = 8
          &O_West = 1
          &O_East = 1
        }
        ELSE
        {
          &Lon_Sec = &LonSec
          &O_West = &West
          &O_East = &East
        }
      }
    }
    
    Var 1939 name Lon_Deg Link IOCARD_DISPLAY Digit 136 Numbers 3 // Lon degrees 
    Var 1940 name Lon_Min Link IOCARD_DISPLAY Digit 134 Numbers 2 // Lon min 
    Var 1941 name Lon_Sec Link IOCARD_DISPLAY Digit 133 Numbers 1 // Lon sec 
    
    var 1942 name O_West Link IOCARD_OUT DEVICE 4 Output 57
    var 1943 name O_East Link IOCARD_OUT DEVICE 4 Output 58
    var 1944 name O_DP2 Link IOCARD_OUT Output 91
    var 1945 name O_DP3 Link IOCARD_OUT Output 93 
    
    //===============================================================
    // Refresh
    //****************
    
    Var 999 Static
    {  
      CALL &OutLatDeg
      CALL &OutLatMin
      CALL &OutLatSec
      CALL &OutLonDeg
      CALL &OutLonMin
      CALL &OutLonSec
    }

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

    Re: Code help for ColdandDark and TestOvhd for Latitude and Longitude script

    Mick,
    First:
    You have not completely amended your code. Compare the beginning of your var 1913 with my var 2115. You missed the Decimal point and the N/S changes.
    Same problem for the Longitude part.

    regards,
    Nico
    Last edited by kiek; 07-15-2010 at 06:07 PM.

  6. #6
    25+ Posting Member
    Join Date
    Nov 2005
    Location
    Derby, UK
    Posts
    44
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Code help for ColdandDark and TestOvhd for Latitude and Longitude script

    Hi Nico,

    My apologies, missed that.
    Yes everything is working now.
    I had just spent two hours on the telephone to my ISP after an upgrade trying to get my internet working, which I sorted out myself by the time they answered.

    Thanks very much

    Regards
    Mick

Similar Threads

  1. Latitude/Longidude type WPT is not accepted
    By dl4saw in forum PM Boeing FMC/CDU
    Replies: 4
    Last Post: 01-03-2010, 08:01 AM
  2. no result when reading FSUIPC aircraft longitude or latitude
    By SimStar001 in forum I/O Interfacing Hardware and Software
    Replies: 12
    Last Post: 08-18-2009, 11:52 AM
  3. PM MCP SIOC Script
    By MortenHa in forum OpenCockpits General Discussion
    Replies: 9
    Last Post: 02-18-2009, 12:18 PM
  4. Flaps Script Help
    By cesarfsim in forum OpenCockpits General Discussion
    Replies: 1
    Last Post: 06-25-2008, 06:13 PM
  5. [script] pmscr737.txt
    By null null in forum PM General Q & A
    Replies: 1
    Last Post: 12-02-2004, 06:57 AM