Jump to content
The simFlight Network Forums

jd

Members
  • Posts

    82
  • Joined

  • Last visited

Posts posted by jd

  1. here's my code. what aren't you happy with? how much difference is there?

    Public Function Ground_Altitude() As Single ' meters Altitude MSL of ground under plane.

    Dim x As Long

    Dim Y As Single

    Dim dwResult As Long

    Call FSUIPC_Read(&HB4C, 2, VarPtr(x), dwResult)

    Call FSUIPC_Process(dwResult)

    Y = x

    If Y > 32767 Then Y = Y - 65534

    Ground_Altitude = Mtof(Y)

    End Function

  2. Public Function Plane_Lat() As Double ' Planes latitude

    Dim fake64bit As Currency

    Dim dwResult As Long

    Call FSUIPC_Read(&H560, 8, VarPtr(fake64bit), dwResult)

    Call FSUIPC_Process(dwResult)

    Plane_Lat = fake64bit * 10000#

    Plane_Lat = Plane_Lat * 90# / (10001750# * 65536# * 65536#)

    End Function

    Public Function Plane_Lon() As Double ' Plane's longitude

    Dim fake64bit As Currency

    Dim dwResult As Long

    Call FSUIPC_Read(&H568, 8, VarPtr(fake64bit), dwResult)

    Call FSUIPC_Process(dwResult)

    Plane_Lon = fake64bit * 10000#

    Plane_Lon = Plane_Lon * 360# / (65536# * 65536# * 65536# * 65536#)

    End Function

  3. if your fsuipc read is gettin a 2byte, use integer , 4byte use long. etc. seems my code should have used an integer. but, it works :-)

    y is single, because i'm returning ground altitude as single

    the if statement is for the occasional elevations below sea level. negative numbers are not represented as negative numbers, but really big numbers above 32767

    try making cntrfuel a long

    jd

  4. your code is going to set gndalt to 0 (since the integer of (3.28084/ 256 = .01281578125) = 0)

    here is the code i've used for about 8 years

    Public Function Ground_Altitude() As Single ' meters Altitude MSL of ground under plane.

    Dim x As Long

    Dim y As Single

    Dim dwResult As Long

    Call FSUIPC_Read(&HB4C, 2, VarPtr(x), dwResult)

    Call FSUIPC_Process(dwResult)

    y = x

    If y > 32767 Then y = y - 65534

    Ground_Altitude = Mtof(y)

    End Function

    Public Function Mtof(meters As Single) As Single ' Convert Meters units to Feet

    Mtof = (meters * 3.28083989501312)

    End Function

  5. sorry i missed it

    here is my code snippet:

    Function adv_disp(Text As String, duration As Long)

    Dim dwResult As Long

    Dim j As Long

    Dim s As String

    s = Left(Text, 127)

    s = s & Chr$(0)

    Call FSUIPC_WriteS(&H3380, Len(s), s, dwResult)

    j = duration

    Call FSUIPC_Write(&H32FA, 2, VarPtr(j), dwResult)

    Call FSUIPC_Process(dwResult)

    End Function

  6. maybe this will help

    Public Function Velocity() As Single ' knots Plane's current groundspeed.

    Dim x As Long

    Dim dwResult As Long

    Call FSUIPC_Read(&H2B4, 4, VarPtr(x), dwResult)

    Call FSUIPC_Process(dwResult)

    Velocity = (x / 65536) * 3600 * 3.28084 / 5280

    End Function

    Public Function Velocity_Indicated() As Single ' knots Indicated airspeed.

    Dim x As Long

    Dim dwResult As Long

    Call FSUIPC_Read(&H2BC, 4, VarPtr(x), dwResult)

    Call FSUIPC_Process(dwResult)

    Velocity_Indicated = x / 128

    End Function

    Public Function Velocity_Y() As Single ' meters/second Vertical speed rate

    Dim x As Long

    Dim dwResult As Long

    Call FSUIPC_Read(&H2C8, 4, VarPtr(x), dwResult)

    Call FSUIPC_Process(dwResult)

    Velocity_Y = x * 60 * 3.28084 / 256

    End Function

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.