Jump to content
The simFlight Network Forums

How do I display a negative number for Vertical Speed Hold Var (0x07F2)?


Recommended Posts

Posted

In Lua, I am able to get the ascent value of the AP Vertical Speed Hold Var (0x07F2) to display correctly in the left window of my GoFlight GF166 (see Lua script below)

However, when adjusting for a descent value, I get a value of 65436 for -100, and that value reduces by 100 for each subsequent negative value (e.g., 65436, 65336, 65236, etc.).

How do I get the negative value to display correctly (e.g., -100, -200, -300, etc.)?

Any help would be most appreciated.

function VS_Hold(offset, value)
    gfd.SetDisplay(GF166, 1, 0, string.format("%4.0f",value))
end

event.offset(0x07F2, "UD", "VS_Hold")

Posted
6 hours ago, Delta14Sierra said:

In Lua, I am able to get the ascent value of the AP Vertical Speed Hold Var (0x07F2) to display correctly in the left window of my GoFlight GF166 (see Lua script below)

However, when adjusting for a descent value, I get a value of 65436 for -100, and that value reduces by 100 for each subsequent negative value (e.g., 65436, 65336, 65236, etc.).

How do I get the negative value to display correctly (e.g., -100, -200, -300, etc.)?

Any help would be most appreciated.

function VS_Hold(offset, value)
    gfd.SetDisplay(GF166, 1, 0, string.format("%4.0f",value))
end

event.offset(0x07F2, "UD", "VS_Hold")

I don't have any Go Flight equipment or experience, but I see two possible issues here:

1. Offset 0x07F2 is listed as 2 bytes in size in the FSUIPC7 Offsets Status PDF document. So 0x07F2 holds 16 bits, a Word quantity, not a 32 bit Double word quantity.

2. Since the vertical speed can be positive or negative, you are dealing with a Signed, not an Unsigned, value.

So given the above, in the event.offset( ) expression suggest you try "SW" , which indicates a Signed 16 bit single Word value, instead of "UD", which indicates an Unsigned 32 bit Double word value .  Easy to do, so worth a try I think.

Al

  • Like 1
  • Thanks 1
Posted

I made this function for the GoFlight MCP:

function VS_Hold(offset, value)
    if (value > 9900) then
        value = 65536 - value
        if (string.len(value) == 3 ) then
            value = "-0"..value
        elseif (string.len(value) == 4 ) then
            value = "-"..value
        end
    else
        if (string.len(value) == 3 and value > 0) then
            value = " 0"..value
        elseif (string.len(value) == 4 and value > 0) then
            value = " "..value
        end
    end
    if (value == 0) then
        value = " 0000"
    end
    gfd.SetDisplay(GFMCP, 0, 3, value)
end

event.offset(0x07F2, "UW", "VS_Hold")

Just adjust it to the number of positions of the GF166's display and replace GFMCP with GF166. By the way, thanks for commenting the lua-script for the GF166!

 

Frans

  • Thanks 1
Posted

Yes, I would think that 0x07F2 should be a signed word ("SW").

@eagle11 Your script would also be simpler if you read the value as a signed value rather than unsigned, and you are also using value as both an integer type and a string type...seems quite confused...but if it works....!

 

  • Thanks 1
Posted

Hi John,

Thanks for the comment, I'm still learning! I sold the GoFlight stuff, but I like incorporating your comment into the script. Maybe I can test it in a window. Happy Easter!

Frans

Posted

I have simplified things to the following which works just as I had hoped. Again, thank you, everyone!

function VS_Hold(offset, value)
    if (value > 9900) then
        value = 65536 - value
        value = "-"..value
    end
    gfd.SetDisplay(GF166, ID, 0, value)
end

event.offset(0x07F2, "SW", "VS_Hold")

Posted
15 hours ago, Delta14Sierra said:

I have simplified things to the following which works just as I had hoped. Again, thank you, everyone!

function VS_Hold(offset, value)
    if (value > 9900) then
        value = 65536 - value
        value = "-"..value
    end
    gfd.SetDisplay(GF166, ID, 0, value)
end

event.offset(0x07F2, "SW", "VS_Hold")

This seems more complicated rather than simplified! I don't know why you are checking for a value > 9900 and then negating - as you are passing in a signed value, this test will never pass. And where is ID set? I think you would be better off using your first script but with a signed value, i.e.

Quote

function VS_Hold(offset, value)
    gfd.SetDisplay(GF166, 1, 0, string.format("%4.0f",value))
end

event.offset(0x07F2, "SW", "VS_Hold")

John

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
×
×
  • 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.