June 9, 20196 yr Trying to make the HDG rotary increase step from - 1 deg per click to 10 deg per click - automatically when turning the rotary after a set number of deg's have occured in a given time. Here is a sample of the LUA actions.lua script from LINDA website for the Aerosoft Airbus A320 that I've been trying to alter with no success (I am not a programmer). Can anyone help please...... This the original for HDG plus , there is also one for HDG plusfast but you need to manually trigger which one to select _________________________________________________________ function AB_HDG_plus () AB_hdgtrk = ipc.readLvar("AB_AP_HDGTRK") AB_drift = round(ipc.readLvar("AB_AP_HDGTRK")) if AB_hdgtrk == 0 then LVarSet = "AB_AP_HDG_Select" else LVarSet = "AB_AP_TRK_set" end LVarGet = round(ipc.readLvar(LVarSet)) AddVar = LVarGet + 1 if AddVar > 359 then AddVar = 0 end DspHDG(AddVar) ipc.writeLvar(LVarSet, AddVar) end Here is one of my inept attempts at altering it..... _______________________________________ function AB_HDG_plus () AB_hdgtrk = ipc.readLvar("AB_AP_HDGTRK") AB_drift = ipc.readLvar("AB_AP_HDGTRK") if AB_hdgtrk == 0 then LVarSet = "AB_AP_HDG_Select" else LVarSet = "AB_AP_TRK_set" end LVarGet = ipc.readLvar(LVarSet) if (LvarGet - val1) > 20 then AddVar = LVarGet + 10 else AddVar = LVarGet + 1 if AddVar > 359 then AddVar = 0 end --DspHDG(AddVar) ipc.writeLvar(LVarSet, AddVar) end val1 = LVarGet sleep(200) end event.flag(1, "AB_HDG_plus") _________________________________ My general idea is when the rotary turns, a reading is taken of the HDG degrees at that time then ie 200ms later a reading is taken again and if the difference is over ie 15 deg it sets the rotary to step 10deg per click instead of 1deg step per click. As soon as the sample is less than 15deg diff then it steps back to 1deg per click. This should be easy for someone with a bit of LUA knowledge to do (I think) Thanks for any help
June 10, 20196 yr Author .... my latest attempt using "event.timer" but any iterations and many different tries later it still doesn't work Can't figure out how the event.timer is used in this... among other things Edited June 10, 20196 yr by aerostar
June 10, 20196 yr Sorry your not having any replies, i can't help with Lua , just to say i,m using a rotary encoder with LINDA Rotate left or right 10 deg Push for shift rotate left or right 1 Deg That works for my PMDG 737 Brian
June 10, 20196 yr Author Yeah that works but on the AS A320 the rotaries are push/pull so I really need to free up the push button on my rotaries.... been looking for someone to make the speed accelerate for ages. It doesn't seem like it would be any kind of challenge for someone who has even a basic understanding of LUA and really would be great if it was already an option in LINDA and the LUA actions script. BTW thanks Brian for making me feel less lonely 🙂 Edited June 10, 20196 yr by aerostar
June 10, 20196 yr 7 hours ago, aerostar said: .... my latest attempt using "event.timer" but any iterations and many different tries later it still doesn't work Can't figure out how the event.timer is used in this... among other things I'm not sure you need timers for this. I'd just bind the function to a button (rotary encoder) click but keep track of the elapsed time between calls. Something like this: local M_KnobLastTime = ipc.elapsedtime() -- Absolute time in milliseconds local function TurnTheKnob() local TimeNow = ipc.elapsedtime() local Interval = (TimeNow - M_KnobLastTime) local AccelThreshold = 200 if Interval < AccelThreshold Then -- Do fast thing else -- Do slow thing end M_KnobLastTime = TimeNow end Edited June 10, 20196 yr by MarkDH missed a bit :) MarkH https://www.youtube.com/@AlmostAviation AMD Ryzen 7 9800X3D / 64Gb DDR5 / Zotac RTX 5070 Ti / 2560 x 1440 display
June 12, 20196 yr Author Hi Mark, thanks for replying... I have been trying to get the code to fit in with the existing but I am not making headway... I have also had another option sent to try but after multiple attempts of both and another trawl of the internet I am still not getting it. This has turned out to be a lot harder (for me) than I thought. I'll continue trying meantime but any further advice, help would be welcome..... Thanks again...
June 12, 20196 yr 54 minutes ago, aerostar said: Hi Mark, thanks for replying... I have been trying to get the code to fit in with the existing but I am not making headway... I have also had another option sent to try but after multiple attempts of both and another trawl of the internet I am still not getting it. This has turned out to be a lot harder (for me) than I thought. I'll continue trying meantime but any further advice, help would be welcome..... Thanks again... Assuming that original function works, try this. (Essentially all I have done is add in my scaffolding and then changed the single line that says AddVar = LVarGet + 1.) local M_KnobLastTime = ipc.elapsedtime() -- Absolute time in milliseconds function AB_HDG_plus () -- >MH local TimeNow = ipc.elapsedtime() local Interval = (TimeNow - M_KnobLastTime) local AccelThreshold = 200 -- <MH AB_hdgtrk = ipc.readLvar("AB_AP_HDGTRK") AB_drift = round(ipc.readLvar("AB_AP_HDGTRK")) if AB_hdgtrk == 0 then LVarSet = "AB_AP_HDG_Select" else LVarSet = "AB_AP_TRK_set" end LVarGet = round(ipc.readLvar(LVarSet)) -- AddVar = LVarGet + 1 -- if AddVar > 359 then -- AddVar = 0 -- end -- >MH if Interval < AccelThreshold Then AddVar = LVarGet + 10 -- Fast else AddVar = LVarGet + 1 -- Slow end AddVar = AddVar % 360 M_KnobLastTime = TimeNow -- <MH DspHDG(AddVar) ipc.writeLvar(LVarSet, AddVar) end MarkH https://www.youtube.com/@AlmostAviation AMD Ryzen 7 9800X3D / 64Gb DDR5 / Zotac RTX 5070 Ti / 2560 x 1440 display
Archived
This topic is now archived and is closed to further replies.