FS2020 Variable Write Bug

Discuss suspected bugs with other users and Sim Innovations Staff

Moderators: russ, Ralph

Message
Author
aerostar
Posts: 4
Joined: Wed Jun 16, 2021 3:15 am

Re: FS2020 Variable Write Bug

#21 Post by aerostar »

been having trouble with MSFS2020 Aerosoft CRJ MCDU and AFCS have reworked the buttons of these but still got problems with the ROTARY Knobs....

The problem, I guess, with the Rotary Knobs is that with the LVARs for the CRJ any presses of buttons want a second press of "0" to zero the status. This can be applied to button pushes but I dont know how to apply this to a ADD_DIAL variable.... seems like that needs another parameter in the command line.

for buttons we have ----- button_add(img_normal,img_pressed,x,y,width,height,press_callback,release_callback)
for dials we have ------------- dial_id = dial_add(image,x,y,width,height,acceleration,click_callback)
the DIAL needs a second(release) callback ?

Every pulse of the encoder/rotary needs a "0" after it....in some aircraft/situations maybe ?

JackZ
Posts: 2262
Joined: Mon Feb 22, 2016 1:02 pm

Re: FS2020 Variable Write Bug

#22 Post by JackZ »

Hi

The « callback » part of the dial_add() function does just that: call a separate function where you can put whatever code you want.
So if you need to send two values for every turn of the dual, that can be done in the callback function by adding the two Lvars write in sequence. Might be advisable to create a slight delay between the two variable_write() calls, as with modern computers the sequence of events fired can be too fast for the sim to catch up.
A simple

Code: Select all

for i=1,1000 do end
loop put in your code in between the two Lvars write should suffice, adjust the upper value by trial and error. Not the cleanest way to achieve that (the loop is a blocking process of sorts), but for a dial moved from time to time, adding a few ms to the AM thread is a non-event
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

aero
Posts: 7
Joined: Mon Jan 25, 2021 4:36 pm

Re: FS2020 Variable Write Bug

#23 Post by aero »

I have tried what you have suggested and more.... but even with the "Knobster" it doesn't work. Without the second - Click (Release) Callback - it doesn't look like it will work.

Trying to change the Value of one Variable twice in the same callback doesn't seem to give the SIM a chance to receive both values consecutively.

In FSUIPC the same Variable with value 1 doesn't work either - until you put the same variable and a value 0 in the button release - and then that does work for both - buttons AND ROTARY encoders.

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: FS2020 Variable Write Bug

#24 Post by Sling »

This has nothing to do with this thread. This is a CRJ specific thing and a rather poor implementation by Aerosoft too. It can be solved with a timer as Jacques suggested earlier.

aero
Posts: 7
Joined: Mon Jan 25, 2021 4:36 pm

Re: FS2020 Variable Write Bug

#25 Post by aero »

I have tried the following and a few other permutations but the knobster or the inbuild AM instrument tester still doesn't work for me .... here is one of the versions -

function HDGr(dir)
if dir == -1 then
print("decr")
sound_play(click_snd)
fs2020_variable_write("L:ASCRJ_FCP_HDG_SEL_DEC", "Num", -1)
for i=1,1000 do end
fs2020_variable_write("L:ASCRJ_FCP_HDG_SEL_DEC", "Num", 0)
elseif dir == 1 then
print("incr")
sound_play(click_snd)
fs2020_variable_write("L:ASCRJ_FCP_HDG_SEL_INC", "Num", 1)
for i=1,1000 do end
fs2020_variable_write("L:ASCRJ_FCP_HDG_SEL_INC", "Num", 0)
end
end
hdg_dial = dial_add("knob_nil.png", 682,100, 75, 75, HDGr)

https://i.gyazo.com/0160d7f3daa4187bd2b ... f57b0a.png

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: FS2020 Variable Write Bug

#26 Post by Keith Baxter »

Hi,

I am not a MSFS 2020 guy but your code is different to what I would do..

Code: Select all

dial_add("knob_nil.png", 682,100, 75, 75,function(dir)
    fs2020_variable_write("L:ASCRJ_FCP_HDG_SEL_DEC", "Num", dir)
end)
But if you have to wright a "0" after a your direction write then

Code: Select all

dial_add("knob_nil.png", 682,100, 75, 75,function(dir)
    fs2020_variable_write("L:ASCRJ_FCP_HDG_SEL_DEC", "Num", dir)
    fs2020_variable_write("L:ASCRJ_FCP_HDG_SEL_DEC", "Num", 0)
end)
Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

JackZ
Posts: 2262
Joined: Mon Feb 22, 2016 1:02 pm

Re: FS2020 Variable Write Bug

#27 Post by JackZ »

aero wrote: Mon Oct 24, 2022 12:47 pm I have tried the following and a few other permutations but the knobster or the inbuild AM instrument tester still doesn't work for me .... here is one of the versions -

function HDGr(dir)
if dir == -1 then
print("decr")
sound_play(click_snd)
fs2020_variable_write("L:ASCRJ_FCP_HDG_SEL_DEC", "Num", -1)
for i=1,1000 do end
fs2020_variable_write("L:ASCRJ_FCP_HDG_SEL_DEC", "Num", 0)
elseif dir == 1 then
print("incr")
sound_play(click_snd)
fs2020_variable_write("L:ASCRJ_FCP_HDG_SEL_INC", "Num", 1)
for i=1,1000 do end
fs2020_variable_write("L:ASCRJ_FCP_HDG_SEL_INC", "Num", 0)
end
end
hdg_dial = dial_add("knob_nil.png", 682,100, 75, 75, HDGr)

https://i.gyazo.com/0160d7f3daa4187bd2b ... f57b0a.png
Looks good to me. Try to increase the 1000 up to 50000 by steps to see if that improves. For better control one can add a timer()
I noticed also that you inserted a sound_play(). Let’s see if it’s not blocking the process
so your code could look like this (adjust the delay variable by trial & error between 100 up to 1000)

Code: Select all

function HDGr(dir)
delay=500 — change the delay in msec
    if dir == -1 then
        print("decr")
       — sound_play(click_snd)
        fs2020_variable_write("L:ASCRJ_FCP_HDG_SEL_DEC", "Num", 1)
	 timer_start(delay,0,function()
	fs2020_variable_write("L:ASCRJ_FCP_HDG_SEL_DEC", "Num", 0)
end)
    elseif dir == 1 then
        print("incr")
      —  sound_play(click_snd)
        fs2020_variable_write("L:ASCRJ_FCP_HDG_SEL_INC", "Num", 1)

        timer_start(delay,0,function()
        fs2020_variable_write("L:ASCRJ_FCP_HDG_SEL_INC", "Num", 0)
      end)
   end
end

hdg_dial = dial_add("knob_nil.png", 682,100, 75, 75, HDGr)
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

ylevesque
Posts: 69
Joined: Wed Jan 09, 2019 6:49 pm

Re: FS2020 Variable Write Bug

#28 Post by ylevesque »

I described a workaround in this topic:
https://siminnovations.com/forums/viewtopic.php?t=6697

Yves

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: FS2020 Variable Write Bug

#29 Post by Sling »

To all following this thread. I believe this is a momentus day because there is a fix. In my limited testing so far it not only seems to fix this long standing bug but also the more serious blocking of other LVAR writes bug that has also been mentioned on these forums. Before i get way ahead of myself and proclaim this day in the Air Manager History Books please join me in testing the fix by simply downloading the brand new AM4.2(BETA 1) plugin from the wiki and leaving your thoughts here.

A big thanks to Corjan who jumped on this and found the culprits after a quick note i sent him this morning. Now if we could just get the Bvar and Ovar support working that will round it out nicely.

User avatar
Keith Baxter
Posts: 4674
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: FS2020 Variable Write Bug

#30 Post by Keith Baxter »

Hi,
A year later.
At least Father Christmas brought you FS2020 guys a early pressie
Sarcastic me. ;)

Awesome that the SI guys are getting to fixing the bug's and niggles,

We need more of these Wednesdays. :)

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

Post Reply