TOGGLE_GPS_DRIVES_NAV1 Help RESOLVED

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Message
Author
FlightNono
Posts: 5
Joined: Thu Feb 23, 2023 7:21 pm

TOGGLE_GPS_DRIVES_NAV1 Help RESOLVED

#1 Post by FlightNono »

Good morning

Already sorry for my English, it's google translate... :D :D


I'm working on modifying an existing script to make RealSimGear's GNS430 unit work

I was able to find all the functions and set every button to work with.

I have a problem that I can't solve

here is the code used

Code: Select all

-- Button CDI

hw_button_add("ARDUINO_MEGA2560_A_D32",function()
    fs2020_event("TOGGLE_GPS_DRIVES_NAV1")
    log("GPS : " .. g_unit)
end)
By default the value is "true" so the function will always work on the GPS1

My log does return GPS 2 to me, but the function still acts on GPS 1

From what I could find and tried without much success being a beginner with Air Manager and Lua the value must be on "FALSE" and I cannot modify this value locally to precisely send the function to the GPS2

According to the command.ini file of RSG the function is defined as follows

Code: Select all

BTN_CDI+=TOGGLE_GS_DRIVES_NAV1#2
If you have any solutions, I'm willing, then I'll modify the script to modify the Arduino channel using the variable to make it available to a greater number, because by default it is on "A"

Thank you

Arnaud

SOLUTED ;) :D

I found the solution

1. I reset the RSG firmware
2. Installed their software
3. Read variables for the GNS430 in COM2
4. I changed the variable

Code: Select all

hw_button_add("ARDUINO_MEGA2560_A_D32",function()
    fs2020_event("H:AS430_CDI_PUSH")
    log("GPS : " .. g_unit)
end)
5.Enjoy

Despite my research I had not found this variable, I will reprogram with AM

Thanks for all the help

Arnaud
Last edited by FlightNono on Wed Mar 29, 2023 2:32 pm, edited 1 time in total.

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: TOGGLE_GPS_DRIVES_NAV1 Help

#2 Post by SimPassion »

FlightNono wrote: Wed Mar 29, 2023 10:55 am Good morning

Already sorry for my English, it's google translate... :D :D


I'm working on modifying an existing script to make RealSimGear's GNS430 unit work

I was able to find all the functions and set every button to work with.

I have a problem that I can't solve

here is the code used

Code: Select all

-- Button CDI

hw_button_add("ARDUINO_MEGA2560_A_D32",function()
    fs2020_event("TOGGLE_GPS_DRIVES_NAV1")
    log("GPS : " .. g_unit)
end)
By default the value is "true" so the function will always work on the GPS1

My log does return GPS 2 to me, but the function still acts on GPS 1

From what I could find and tried without much success being a beginner with Air Manager and Lua the value must be on "FALSE" and I cannot modify this value locally to precisely send the function to the GPS2

According to the command.ini file of RSG the function is defined as follows

Code: Select all

BTN_CDI+=TOGGLE_GS_DRIVES_NAV1#2
If you have any solutions, I'm willing, then I'll modify the script to modify the Arduino channel using the variable to make it available to a greater number, because by default it is on "A"

Thank you

Aranud
Hi Arnaud,
  1. where did you get the "g_unit" variable value ?
  2. did you already subscribed to a specific MSFS variable to get it ?
  3. which aircraft are you using for testing ?

FlightNono
Posts: 5
Joined: Thu Feb 23, 2023 7:21 pm

Re: TOGGLE_GPS_DRIVES_NAV1 Help

#3 Post by FlightNono »

where did you get the "g_unit" variable value ?

g_unit Was recovered with Air Manager's default script, Instrument Hardware GNS 430 which should set the units normally it seems to me

Code: Select all

gps_no = user_prop_add_enum("Selected GPS unit","GPS 1,GPS 2","GPS 2","Select GPS Unit to control")
rxp_ctrl = user_prop_add_enum("Type","Default,Reality XP","Default","For X-Plane select default or Reality XP")
local g_unit = fif(user_prop_get(gps_no)=="GPS 2", 2, 2)
local g_ctrl = fif(user_prop_get(rxp_ctrl)=="Default", 1, 2)
I mainly used this log to find each button of the RSG unit each they gave me just the Arduino chip and the number of buttons after we manage

did you already subscribed to a specific MSFS variable to get it ?
No I have not subscribed to the variables

Because I know I have to subscribe to it but as said I'm new to AM and Lua, I still lack some knowledge on it, I'm working on it by looking at how the scripts were made in AM

which aircraft are you using for testing ?
I use the Asobo default C172 with the GNS530 in GPS1 and GNS430 in GPS2 units and as said the function always uses GPS 1 but I used to like GPS 2

FlightNono
Posts: 5
Joined: Thu Feb 23, 2023 7:21 pm

Re: TOGGLE_GPS_DRIVES_NAV1 Help

#4 Post by FlightNono »

From what I could find

I will have to declare a local variable with value = FALSE or GPS2

That I should add to my function

Then subscribe...

But I couldn't find how to do it

I tried CHATGBT without success

Arnaud

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: TOGGLE_GPS_DRIVES_NAV1 Help

#5 Post by SimPassion »

FlightNono wrote: Wed Mar 29, 2023 11:35 am From what I could find

I will have to declare a local variable with value = FALSE or GPS2

That I should add to my function

Then subscribe...

But I couldn't find how to do it

I tried CHATGBT without success

Arnaud
We have to let it as it was in the original script, there the value change depending on our user property selection before starting the instrument :

Code: Select all

gps_no = user_prop_add_enum("Selected GPS unit","GPS 1,GPS 2","GPS 2","Select GPS Unit to control")
-- .../...
local g_unit = fif(user_prop_get(gps_no)=="GPS 1", 1, 2)
and all be ok, as here for example :

Code: Select all

xpl_command("sim/GPS/g430n" .. g_unit .. "_cdi")
image.png
image.png (7.93 KiB) Viewed 564 times

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: TOGGLE_GPS_DRIVES_NAV1 Help

#6 Post by SimPassion »

FlightNono wrote: Wed Mar 29, 2023 11:35 am From what I could find

I will have to declare a local variable with value = FALSE or GPS2
Nope, this is "1" or "2" so an INT value which is concatenated in the variable write statement

FlightNono
Posts: 5
Joined: Thu Feb 23, 2023 7:21 pm

Re: TOGGLE_GPS_DRIVES_NAV1 Help

#7 Post by FlightNono »

SimPassion wrote: Wed Mar 29, 2023 11:51 am
FlightNono wrote: Wed Mar 29, 2023 11:35 am From what I could find

I will have to declare a local variable with value = FALSE or GPS2

That I should add to my function

Then subscribe...

But I couldn't find how to do it

I tried CHATGBT without success

Arnaud
We have to let it as it was in the original script, there the value change depending on our user property selection before starting the instrument :

Code: Select all

gps_no = user_prop_add_enum("Selected GPS unit","GPS 1,GPS 2","GPS 2","Select GPS Unit to control")
-- .../...
local g_unit = fif(user_prop_get(gps_no)=="GPS 1", 1, 2)
and all be ok, as here for example :

Code: Select all

xpl_command("sim/GPS/g430n" .. g_unit .. "_cdi")

image.png
I tried with the original file but what you say is valid for x-plane

I'm under FS2020 and the value is always true in the script so it always returns the "CDI" on GPS1 (GNS530) and never on GPS2 (GNS430)

But I want the "CDI" to always work on the GPS2 and never on the GPS1 because I also have the Garmin GNS530 from RSG that I have to wear under AM

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: TOGGLE_GPS_DRIVES_NAV1 Help

#8 Post by SimPassion »

FlightNono wrote: Wed Mar 29, 2023 12:14 pm
SimPassion wrote: Wed Mar 29, 2023 11:51 am
FlightNono wrote: Wed Mar 29, 2023 11:35 am From what I could find

I will have to declare a local variable with value = FALSE or GPS2

That I should add to my function

Then subscribe...

But I couldn't find how to do it

I tried CHATGBT without success

Arnaud
We have to let it as it was in the original script, there the value change depending on our user property selection before starting the instrument :

Code: Select all

gps_no = user_prop_add_enum("Selected GPS unit","GPS 1,GPS 2","GPS 2","Select GPS Unit to control")
-- .../...
local g_unit = fif(user_prop_get(gps_no)=="GPS 1", 1, 2)
and all be ok, as here for example :

Code: Select all

xpl_command("sim/GPS/g430n" .. g_unit .. "_cdi")

image.png
I tried with the original file but what you say is valid for x-plane

I'm under FS2020 and the value is always true in the script so it always returns the "CDI" on GPS1 (GNS530) and never on GPS2 (GNS430)

But I want the "CDI" to always work on the GPS2 and never on the GPS1 because I also have the Garmin GNS530 from RSG that I have to wear under AM
You're right, I'm trying on my own and the MSFS handling requires a bit of adaptation
Just made an attempt and trying to figure out at the moment, before reading your answer

Just create a new hardware instrument and try this as a replacement of original script (just still have to handle properly GPS Drive NAV1/NAV2) :

Code: Select all

-- 0.0.2	2023.03.29	enjxp_SimPassion	- Made GNS 430 / GNS 530 Compatible
-- 0.0.1	2023.03.29	Sim Innovations		- Original GPS 430 hardware instrument


gps_no = user_prop_add_enum("Selected GPS unit","GPS 1,GPS 2","GPS 2","Select GPS Unit to control")
rxp_ctrl = user_prop_add_enum("Type","Default,Reality XP","Default","For X-Plane select default or Reality XP")
local g_unit = fif(user_prop_get(gps_no)=="GPS 1", 1, 2)
local g_ctrl = fif(user_prop_get(rxp_ctrl)=="Default", 1, 2)
local gps_unit = fif(g_unit==1, 530, 430)

print(gps_unit)



-- Buttons --
hw_button_add("Power",function()
    if g_ctrl == 1 then
        xpl_command("sim/GPS/g430n" .. g_unit .. "_cvol")
    else
        xpl_command("RXP/GNS/PWR_PUSH_" .. g_unit)
    end
end)

hw_button_add("Volume",function()
    if g_ctrl == 1 then
        xpl_command("sim/GPS/g430n" .. g_unit .. "_vvol")
    else
        xpl_command("RXP/GNS/VOL_PUSH_" .. g_unit)
    end
end)

hw_button_add("Com swap",function()
    if g_ctrl == 1 then
        xpl_command("sim/GPS/g430n" .. g_unit .. "_com_ff")
    else
        xpl_command("RXP/GNS/CFLP_" .. g_unit)
    end
    fs2020_event("H:AS"..gps_unit.."_COMSWAP_Push")
end)

hw_button_add("Nav swap",function()
    if g_ctrl == 1 then
        xpl_command("sim/GPS/g430n" .. g_unit .. "_nav_ff")
    else
        xpl_command("RXP/GNS/VFLP_" .. g_unit)
    end
    fs2020_event("H:AS"..gps_unit.."_NAVSWAP_Push")
end)

hw_button_add("CDI",function()
    if g_ctrl == 1 then
        xpl_command("sim/GPS/g430n" .. g_unit .. "_cdi")
    else
        xpl_command("RXP/GNS/CDI_" .. g_unit)
    end
    -- fs2020_event("TOGGLE_GPS_DRIVES_NAV1")
    fs2020_event("H:AS"..gps_unit.."_CDI_Push")
end)

hw_button_add("OBS",function()
    if g_ctrl == 1 then
        xpl_command("sim/GPS/g430n" .. g_unit .. "_obs")
    else
        xpl_command("RXP/GNS/OBS_" .. g_unit)
    end
    fs2020_event("H:AS"..gps_unit.."_OBS_Push")
end)

hw_button_add("MSG",function()
    if g_ctrl == 1 then
        xpl_command("sim/GPS/g430n" .. g_unit .. "_msg")
    else
        xpl_command("RXP/GNS/MSG_" .. g_unit)
    end
    fs2020_event("H:AS"..gps_unit.."_MSG_Push")
end)

hw_button_add("FPL",function()
    if g_ctrl == 1 then
        xpl_command("sim/GPS/g430n" .. g_unit .. "_fpl")
    else
        xpl_command("RXP/GNS/FPL_" .. g_unit)
    end
    fs2020_event("H:AS"..gps_unit.."_FPL_Push")
end)

hw_button_add("PROC",function()
    if g_ctrl == 1 then
        xpl_command("sim/GPS/g430n" .. g_unit .. "_proc")
    else
        xpl_command("RXP/GNS/PROC_" .. g_unit)
    end
    fs2020_event("H:AS"..gps_unit.."_PROC_Push")
end)

hw_button_add("Zoom out",function()
    if g_ctrl == 1 then
        xpl_command("sim/GPS/g430n" .. g_unit .. "_zoom_out")
    else
        xpl_command("RXP/GNS/RUP_" .. g_unit)
    end
    fs2020_event("H:AS"..gps_unit.."_RNG_Dezoom")
end)

hw_button_add("Zoom in",function()
    if g_ctrl == 1 then
        xpl_command("sim/GPS/g430n" .. g_unit .. "_zoom_in")
    else
        xpl_command("RXP/GNS/RDN_" .. g_unit)
    end
    fs2020_event("H:AS"..gps_unit.."_RNG_Zoom")
end)

hw_button_add("Direct To",function()
    if g_ctrl == 1 then
        xpl_command("sim/GPS/g430n" .. g_unit .. "_direct")
    else
        xpl_command("RXP/GNS/DTO_" .. g_unit)
    end
    fs2020_event("H:AS"..gps_unit.."_DirectTo_Push")
end)

hw_button_add("Menu",function()
    if g_ctrl == 1 then
        xpl_command("sim/GPS/g430n" .. g_unit .. "_menu")
    else
        xpl_command("RXP/GNS/MNU_" .. g_unit)
    end
    fs2020_event("H:AS"..gps_unit.."_MENU_Push")
end)

function callback_clr_down()
    if g_ctrl == 1 then
        xpl_command("sim/GPS/g430n" .. g_unit .. "_clr", 1)
    else
        xpl_command("RXP/GNS/CLR_" .. g_unit, 1)
    end
    timer_clear = timer_start(2000, function()
        fs2020_event("H:AS"..gps_unit.."_CLR_Push_Long")
    end)
end
function callback_clr_up()
    if g_ctrl == 1 then
        xpl_command("sim/GPS/g430n" .. g_unit .. "_clr", 0)
    else
        xpl_command("RXP/GNS/CLR_" .. g_unit, 0)
    end
    if timer_running(timer_clear) then
        timer_stop(timer_clear)
        fs2020_event("H:AS"..gps_unit.."_CLR_Push")
    end
end

hw_button_add("Clear",callback_clr_down,callback_clr_up)

hw_button_add("Enter",function()
    if g_ctrl == 1 then
        xpl_command("sim/GPS/g430n" .. g_unit .. "_ent")
    else
        xpl_command("RXP/GNS/ENT_" .. g_unit)
    end
    fs2020_event("H:AS"..gps_unit.."_ENT_Push")
end)

-- Dial PUSH C/V
hw_dial_add("CV outer",function(direction)
    if direction == 1 then
        if g_ctrl == 1 then
            xpl_command("sim/GPS/g430n" .. g_unit .. "_coarse_up")
        else
            xpl_command("RXP/GNS/COM_OUTR_CW_" .. g_unit)
        end
        fs2020_event("H:AS"..gps_unit.."_LeftLargeKnob_Right")
    elseif direction == -1 then
        if g_ctrl == 1 then
            xpl_command("sim/GPS/g430n" .. g_unit .. "_coarse_down")
        else
            xpl_command("RXP/GNS/COM_OUTR_CCW_" .. g_unit)
        end
        fs2020_event("H:AS"..gps_unit.."_LeftLargeKnob_Left")
    end
end)

hw_dial_add("CV inner",function(direction)
    if direction == 1 then
        if g_ctrl == 1 then
            xpl_command("sim/GPS/g430n" .. g_unit .. "_fine_up")
        else
            xpl_command("RXP/GNS/COM_INNR_CW_" .. g_unit)
        end
        fs2020_event("H:AS"..gps_unit.."_LeftSmallKnob_Right")
    elseif direction == -1 then
        if g_ctrl == 1 then
            xpl_command("sim/GPS/g430n" .. g_unit .. "_fine_down")
        else
            xpl_command("RXP/GNS/COM_INNR_CCW_" .. g_unit)
        end
        fs2020_event("H:AS"..gps_unit.."_LeftSmallKnob_Left")
    end
end)

hw_button_add("Com push",function()
    if g_ctrl == 1 then
        xpl_command("sim/GPS/g430n" .. g_unit .. "_nav_com_tog")
    else
        xpl_command("RXP/GNS/COM_PUSH_" .. g_unit)
    end
    fs2020_event("H:AS"..gps_unit.."_LeftSmallKnob_Push")
end)

-- Dial PUSH CRSR
hw_dial_add("Cursor outer",function(direction)
    if direction == 1 then
        if g_ctrl == 1 then
            xpl_command("sim/GPS/g430n" .. g_unit .. "_chapter_up")
        else
            xpl_command("RXP/GNS/GPS_OUTR_CW_" .. g_unit)
        end
        fs2020_event("H:AS"..gps_unit.."_RightLargeKnob_Right")
    elseif direction == -1 then
        if g_ctrl == 1 then
            xpl_command("sim/GPS/g430n" .. g_unit .. "_chapter_dn")
        else
            xpl_command("RXP/GNS/GPS_OUTR_CCW_" .. g_unit)
        end
        fs2020_event("H:AS"..gps_unit.."_RightLargeKnob_Left")
    end
end)

hw_dial_add("Cursor inner",function(direction)
    if direction == 1 then
        if g_ctrl == 1 then
            xpl_command("sim/GPS/g430n" .. g_unit .. "_page_up")
        else
            xpl_command("RXP/GNS/GPS_INNR_CW_" .. g_unit)
        end
        fs2020_event("H:AS"..gps_unit.."_RightSmallKnob_Right")
    elseif direction == -1 then
        if g_ctrl == 1 then
            xpl_command("sim/GPS/g430n" .. g_unit .. "_page_dn")
        else
            xpl_command("RXP/GNS/GPS_INNR_CCW_" .. g_unit)
        end
        fs2020_event("H:AS"..gps_unit.."_RightSmallKnob_Left")
    end
end)

hw_button_add("Push cursor",function()
    if g_ctrl == 1 then
        xpl_command("sim/GPS/g430n" .. g_unit .. "_cursor")
    else
        xpl_command("RXP/GNS/GPS_PUSH_" .. g_unit)
    end
    fs2020_event("H:AS"..gps_unit.."_RightSmallKnob_Push")
end)

FlightNono
Posts: 5
Joined: Thu Feb 23, 2023 7:21 pm

Re: TOGGLE_GPS_DRIVES_NAV1 Help

#9 Post by FlightNono »

Thanks

I have the gns430 in the console but the "cdi" is still on the GPS_1 or the GNS_530 and not the GNS-430

I subscribed locally to the variable toggle_gps_drives_nav1 = false fsuipc returns me the value 0 but the CDI will always be on GPS 1


I don't know how realsimgear gets around the problem they don't want to answer me I just could have the chip and the number of buttons the rotarys and that's it

Besides the bebounce which is by default at 4ms and RSG is at 2ms for the rotary encoder

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: TOGGLE_GPS_DRIVES_NAV1 Help

#10 Post by SimPassion »

FlightNono wrote: Wed Mar 29, 2023 1:43 pm Thanks

I have the gns430 in the console but the "cdi" is still on the GPS_1 or the GNS_530 and not the GNS-430

I subscribed locally to the variable toggle_gps_drives_nav1 = false fsuipc returns me the value 0 but the CDI will always be on GPS 1


I don't know how realsimgear gets around the problem they don't want to answer me I just could have the chip and the number of buttons the rotarys and that's it

Besides the bebounce which is by default at 4ms and RSG is at 2ms for the rotary encoder
No , this is an event (command) not a variable :

Code: Select all

fs2020_event("TOGGLE_GPS_DRIVES_NAV1")
So, in my script, try uncomenting line #56

Code: Select all

    -- fs2020_event("TOGGLE_GPS_DRIVES_NAV1")
would become :

Code: Select all

    fs2020_event("TOGGLE_GPS_DRIVES_NAV1")

Post Reply