Jump to content
The simFlight Network Forums

rustam

Members
  • Content count

    38
  • Joined

  • Last visited

Community Reputation

0 Neutral

About rustam

  • Rank
    Advanced Member

Profile Information

  • Gender
    Male
  • Location
    Rio
  1. Hi there, I know, it's an old topic but I'm putting it here not to spoil the forum with yet another similar topic. Please feel free to relocate it as appropriate. Anyway, I'm trying to get the values for Prop RPM percentage (%) and Torque pressure (psi) for Aerosoft Twin Otter DHC-6-300 and to display them on the screen via a LUA script. The script works OK but I'm not sure if the offsets I'm working with are correct - the values match with the aircraft's gauge indicators only if divided with certain 'guesstimated' scalars , as shown below (e.g., 386.45 and 327.66). So, is there any elegant solution to get correct values for the above parameters? PS: FSX Acceleration with FSUIPC v4.972a propRPM1 = round (ipc.readDBL(0x2400) / 386.45) propRPM2 = round (ipc.readDBL(0x2500) / 386.45) torque1 = round (ipc.readUD(0x08F4) / 327.66) torque2 = round (ipc.readUD(0x098C) / 327.66) Thanks!
  2. Thank you, Thomas! That's exactly what I was looking for. It works! :)
  3. Hello everybody, I'd like to display heading and course degrees on Horizontal Situation Indicator (HSI) through FSUIPC. I can see the tool-tips regular way (mouse hovering) but it's inconvenient during flight. E.g., I've tried to use the offset 0x0580 further converted to magnetic heading and displayed at each inc/dec of the heading bug but what I've got is aircraft's positional heading, not the one selected on HSI. Basically, what I want to achieve is a sort of 'tool-tip display using FSUIPC'. So, I wonder if one can successfully retrieve these values using FSUIPC on each turn/press of the HSI rotary button? Thanks!
  4. OMG, it was so obvious... This one works finally: function Armrest_Toggle() ipc.writeLvar("L:Twot_Armrest", nToggleVal(ipc.readLvar("L:Twot_Armrest"), 0, 1)) end Thank you VERY much for the hint, Thomas!!!
  5. I tried this to no avail yet... function nToggleVal(nCurrVal, nVal1, nVal2) if nCurrVal == nVal1 then return nVal2 else return nVal1 end end function Armrest_Toggle() ipc.writeLvar(nToggleVal(ipc.readLvar("L:Twot_Armrest"), 0, 1)) end if ipcPARAM == 0 then Armrest_Toggle() end FSUIPC.ini is unchanged - FSUIPC recognizes the button OK. The problem is associated with function call I think. But I don't know why the above syntax doesn't work... :(
  6. Thank you, Thomas!!! Strange, I thought calling functions was just a matter of proper environment definition (local or global), but direction of declaration is smth new for me... I'll try your suggestion and return to this thread. And Happy New Year!!!
  7. Hi there, I'm trying to call the function 'Armrest_Toggle' with a button assigned through FSUIPC as follows: if ipcPARAM == 0 then Armrest_Toggle() end local function Armrest_Toggle() ipc.writeLvar(nToggleVal(ipc.readLvar("L:Twot_Armrest"), 0, 1)) end local function nToggleVal(nCurrVal, nVal1, nVal2) if nCurrVal == nVal1 then return nVal2 else return nVal1 end end I'm tracing the changes in LVars and when I press the assigned button, I get this error: 273111 *** LUA Error: ...Games\Microsoft Flight Simulator X\Modules\dhc-6.lua:26: attempt to call global 'Armrest_Toggle' (a nil value) And here is the content of FSUIPC.ini, as relates to the particular aircraft I've loaded into the sim: [JoyNames] AutoAssignLetters=No 0=X52 Pro Flight Controller 0.GUID={A1946F60-C51A-11E6-8005-444553540000} [Profile.DHC-6] 1=Aerosoft DHC-6 [Buttons.DHC-6] 0=P0,1,CL1:R,0 ; armrest toggle -{Lua dhc-6}- [General] ShortAircraftNameOk=Substring [LuaFiles] 1=dhc-6 2=ipcReady 3=linda I wonder what can cause this error? Thanks in advance!!! FSUIPC4.log
  8. RealAir Beech Duke Turbine

    Thank you VERY much, Sir!!! I took the liberty to translate your LINDA script to "basic" Lua language since I don't use Linda with FSX. And it works pretty well! I hope you don't mind... :) Cheers, Rustam
  9. The power of C libraries... :) Amazing solution, thanks a million!!! I took the liberty to slightly modify your code - otherwise I see a blank spot instead of a zero: adf2_main = string.format("%03X", adf2_main) Thanks again, Roman!!!
  10. Simply brilliant! Thank you!!!
  11. Since on aircraft I'm flying the ADF frequency is barely visible, especially the fractions part, I've written this piece of "dirty" code to display it on the screen: -- Converts decimal values stored at offsets 02D4 & 02D6 to hex function dec2hex(num) local a = {} local b = {} local i = 0 num = tonumber(num) while num > 0 do local q = math.floor(num / 16) -->> find quotient local r = num - q * 16 -->> find remainder if r == 10 then r = "A" -->> this IF part is not required anyway due to offset limits but it makes the converter sort of complete! elseif r == 11 then r = "B" elseif r == 12 then r = "C" elseif r == 13 then r = "D" elseif r == 14 then r = "E" elseif r == 15 then r = "F" end num = q i = i + 1 a[i] = r end -- reverse the array elements for j = 1,i do b[j] = a[i] i = i - 1 end -- join the array elements to a string return table.concat(b,"") end adf = ipc.readUW(0x02D4) adf_f = ipc.readUW(0x02D6) if adf_f == 0 then -->> Do I need to modify this IF part?! adf = dec2hex(adf) elseif adf_f == 256 then adf = dec2hex(adf) + 1000 elseif adf_f > 256 then adf = dec2hex(adf) + 1000 + (adf_f - 256)/10 elseif adf_f > 0 and adf_f < 256 then adf = dec2hex(adf) + adf_f/10 end ipc.display("ADF = "..adf.." kHz") ipc.sleep(50) The code goes into a WHILE loop and so far works ok. What I really wonder is how I can modify the IF section indicated above to read hi / low bytes at offset 02D6 properly (instead of doing this "dirty" hex / decimal addition) and amend to the value of offset 02D4 converted to hex? I'm sure the answer is really simple but I can't figure the better approach yet... Thanks!
  12. As far as I can trace in the event log, by default the controls 65607 and 65615 has max step of 31. Therefore, I'm trying to implement the following code to bypass default values with step 256/16384: -- Elevator Trim ------------------------------------------------------------------------- if ipcPARAM == 890 then -- Up local val = ipc.readSW(0x0BC0) local newval = val + 256 if newval > 16383 then ipc.writeSW(0x0BC0,16383) ipc.writeLvar(soundSet,0) else ipc.writeSW(0x0BC0,newval) ipc.writeLvar(soundSet,10) end end if ipcPARAM == 891 then -- Down local val = ipc.readSW(0x0BC0) local newval = val - 256 if newval < -16383 then ipc.writeSW(0x0BC0,-16383) ipc.writeLvar(soundSet,0) else ipc.writeSW(0x0BC0,newval) ipc.writeLvar(soundSet,10) end end But it seems strange that when I reach 0 (zero) trimming down the elevator, instead of switching to negative values, the offset values start counting down from 65536, as shown in the image below, whereas in the List of Offsets it's clearly stated that elevator trim control input at offset xBC0 ranges from –16383 to +16383 being of type signed word (SW). Or, am I getting smth wrong?! :) Thanks! Rustam
  13. Adding Sounds to Your Cockpit (LUA)

    Thank you, Michael!!! Very helpful and generous of you indeed...
  14. Roman, Thanks a lot! I followed your tips and guess what - it works, although a bit unexpectedly! :D I see your point... The lesson learnt: the key, as you have also mentioned, is the state of all buttons involved in compound button programming, not what one expects them to do even if the syntax I posted in OP is pretty much logical... Have a nice day! Rustam
  15. Thanks, Roman! I double checked the contents of the INI file, nothing suspicious or similar to what you have described... But a 2nd set of eyes is better anyway: [JoyNames] AutoAssignLetters=No 0=Saitek X52 Pro Flight Controller 0.GUID={355F3F90-50DC-11E5-8001-444553540000} [LuaFiles] 1=SW_AN2 2=ipcReady 3=linda [Profile.SW_AN2] 1=Antonov [Buttons.SW_AN2] 0=CP(+0,28)0,4,CL1:R,1125 ; adf near-far switch 1=R0,6,CL1:R,780 ; mixture lean 2=R0,7,CL1:R,781 ; mixture enrich 3=CR(+0,18)0,6,CL1:R,812 ; prop pitch decr 4=CR(+0,18)0,7,CL1:R,813 ; prop pitch incr 5=R0,2,CL1:R,891 ; elevator trim down 6=R0,3,CL1:R,890 ; elevator trim up 7=P0,12,CL1:R,88 ; flaps up incr 8=P0,13,CL1:R,79 ; flaps down incr 9=P0,4,CL1:R,751 ; emerg flaps switch 10=P0,5,CL1:R,131 ; brakes 11=CP(+0,15)0,5,CL1:R,133 ; parking brakes 12=P0,1,CL1:R,1 ; cold & dark + autostart 13=U0,14,CL1:R,59 ; landing light left 14=P0,14,CL1:R,58 ; landing light right 15=P0,8,CL1:R,60 ; navigation light 16=P0,9,CL1:R,62 ; strobe light 17=P0,10,CL1:R,61 ; taxi light 18=P0,19,CL1:R,300 ; cockpit door 19=P0,21,CL1:R,301 ; pax door 20=CP(+0,15)0,21,CL1:R,302 ; cargo door 21=R0,20,CL1:R,900 ; aileron trim left 22=R0,22,CL1:R,901 ; aileron trim right 23=P0,31,CL1:R,132 ; manual pump 24=CP(+0,18)0,31,CL1:R,107 ; manual primer 25=CP(+0,15)0,31,CL1:R,57 ; tailwheel lock 26=CP(+0,15)0,25,CL1:R,1264 ; fuel tanks 27=CP(+0,15)0,8,CL1:R,65 ; battery 28=CP(+0,15)0,9,CL1:R,64 ; generator 29=CP(+0,15)0,23,CL1:R,804 ; magnetos 30=P0,23,CL1:R,920 ; cowl flaps incr 31=P0,25,CL1:R,921 ; cowl flaps decr [Axes.SW_AN2] RangeRepeatRate=10 0=0X,256,D,1,0,0,0 1=0Y,256,D,2,0,0,0 2=0Z,256,D,4,25,0,0 3=0R,256,D,3,0,0,0 [JoystickCalibration.SW_AN2] Aileron=-16384,-512,512,16384 AileronTrimControl=0 AllowSuppressForPFCquad=Yes ApplyHeloTrim=No BrakeReleaseThreshold=0 CowlFlaps1Control=0 CowlFlaps2Control=0 CowlFlaps3Control=0 CowlFlaps4Control=0 Elevator=-16384,-512,512,16384 ExcludeMixtureSet=Yes ExcludePropPitchSet=Yes ExcludeThrottleSet=Yes FlapDetents=No FlapsSetControl=0 MaxSteerSpeed=60 MaxThrottleForReverser=256 Reverser1Control=66422 Reverser2Control=66425 Reverser3Control=66428 Reverser4Control=66431 Reverser=-16384,-11000 ReverserControl=66292 Rudder=-16384,-512,512,16384 RudderTrimControl=0 SepRevsJetsOnly=No SlopeAileron=-2 SlopeElevator=-2 SlopeRudder=-3 SlopeThrottle=-4 SteeringTillerControl=0 Throttle=-9000,16384 UseAxisControlsForNRZ=No [General] AdvDisplayHotKey=65,11 AileronSpikeRemoval=Yes AutoScanDevices=Yes AutoTuneADF=No AxesWrongRange=No AxisCalibration=No AxisIntercepts=No BlankDisplays=No BrakeReleaseThreshold=75 ClearWeatherDynamics=No ClockSync=Yes ClockSyncMins=1 CloudIcing=No CloudTurbulence=No Console=No CustomWeatherModify=No DelayedMouseLookZoom=No DeleteVehiclesForAES=Yes DirectAxesToCalibs=No DisconnTrimForAP=Yes DontResetAxes=No ElevatorSpikeRemoval=Yes EnableMouseLook=No EventsViaCommands=Yes FixControlAccel=Yes FixMachSpeedBug=Yes GenerateCirrus=No GetNearestAirports=Yes History=5A32BD8JRGOS3PH71NH2N InitDelay=0 InitDelayDevicesToo=No LoadFlightMenu=No LoadPlanMenu=No LuaRerunDelay=66 MagicBattery=No MaxIce=-4 MaxSurfaceWind=0 MinIce=-4 MouseWheelMove=No MouseWheelTrim=No MouseWheelTrimSpeed=1 NewInterceptTextMenu=No OneCloudLayer=No OOMcheck=Yes OOMcheckInterval=10 OwnWeatherChanges=No PatchSIM1friction=Yes PauseAfterCrash=Yes PollGFTQ6=No PressureSmoothness=0 ReversedElevatorTrim=No RudderSpikeRemoval=Yes SaveDataWithFlights=No SavePreviousFlight=No ShortAircraftNameOk=Substring ShowMultilineWindow=Yes ShowPMcontrols=No SimConnectStallTime=1 SmoothBySimTime=No SpoilerIncrement=512 SuppressAllGusts=No SuppressCloudTurbulence=No SuppressMultilineFS=No SuppressSingleline=No SuppressWindTurbulence=No SuppressWindVariance=No TCASid=Flight TCASrange=40 TemperatureSmoothness=0 ThrottleSyncAll=No TimeForSelect=4 TurbulenceDivisor=20,20,40,40 TurbulenceRate=1.0,5.0 UpdatedByVersion=4945 UpperWindGusts=No UseMidMouseBtn=No UseProfiles=Yes UseSystemTime=No VisibilityOptions=No WeatherReadFactor=2 WeatherRewriteSeconds=1 WhiteMessages=Yes WindAjustAltitude=No WindAjustAltitudeBy=2000 WindDiscardLevel=400 WindLimitLevel=200 WindSmoothAirborneOnly=Yes WindSmoothing=No WindSmoothness=2 WindTurbulence=No ZapSound=firework ZeroElevForAPAlt=Yes JoystickTimeout=20 ConsoleWindow=0,0,0,0 LogEvents=Yes FSVersionUsed="Microsoft Flight Simulator X",10.0.61637.0 SimConnectUsed=10.0.61259.0 [Axes] PollInterval=10 RangeRepeatRate=10 [Buttons] PollInterval=25 ButtonRepeat=20,10 [JoystickCalibration] Aileron=-16384,-512,512,16384 AileronTrimControl=0 AllowSuppressForPFCquad=Yes ApplyHeloTrim=No CowlFlaps1Control=0 CowlFlaps2Control=0 CowlFlaps3Control=0 CowlFlaps4Control=0 Elevator=-16384,-512,512,16384 ExcludeMixtureSet=Yes ExcludePropPitchSet=Yes ExcludeThrottleSet=Yes FlapDetents=No FlapsSetControl=0 MaxSteerSpeed=60 MaxThrottleForReverser=256 Reverser1Control=66422 Reverser2Control=66425 Reverser3Control=66428 Reverser4Control=66431 Reverser=-16384,-11000 ReverserControl=66292 Rudder=-16384,-512,512,16384 RudderTrimControl=0 SepRevsJetsOnly=No SteeringTillerControl=0 Throttle=-16384,16384 UseAxisControlsForNRZ=No [AutoSave] AutoSaveEnabled=No Files=10 Interval=60 Next=1 SaveOnGround=No [GPSout] GPSoutEnabled=No Port=COM0 Speed=4800 Interval=2000 PosTo6Decimal=No SimModeIndicator=No Sentences= [GPSout2] GPSoutEnabled=No Port=<none set> Speed=4800 Interval=2000 PosTo6Decimal=No SimModeIndicator=No Sentences= [WideServer] WideFSenabled=Yes [Window.LUA display] Docked=7354, 2828, 3545, 2459 Thanks! Rustam
×