FS2020 Variable Write Bug
Re: FS2020 Variable Write Bug
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 ?
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 ?
Re: FS2020 Variable Write Bug
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
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
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
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ
Re: FS2020 Variable Write Bug
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.
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.
Re: FS2020 Variable Write Bug
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.
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Re: FS2020 Variable Write Bug
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
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
- Keith Baxter
- Posts: 4674
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: FS2020 Variable Write Bug
Hi,
I am not a MSFS 2020 guy but your code is different to what I would do..
But if you have to wright a "0" after a your direction write then
Keith
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)
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)
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
Re: FS2020 Variable Write Bug
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()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
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
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ
Re: FS2020 Variable Write Bug
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.
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.
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
- Keith Baxter
- Posts: 4674
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: FS2020 Variable Write Bug
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
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