Jump to content

New StreamDeck Plugin


Recommended Posts

Made some progress,

 

In P-51D.lua (DCS-ExportScript) within the ExportScript.ProcessIkarusDCSConfigHighImportance(mainPanelDevice) function

 

ExportScript.Tools.SendData(2001, string.format("%d", (0.12345678 * 360)))

 

allows me to monitor the DCS ID of 2001 in the "Title Text Change..." options in this stream deck plugin and correctly takes the decimal number 0.12345678 and formats it to heading of 44 degress.

 

What i need to figure out now is how to get the raw heading data as a variable, for exampe:

 

MyGyroHeading = liveData

ExportScript.Tools.SendData(2001, string.format("%d", (MyGyroHeading * 360)))

 

Have played with GetDevice(20) which seems to return an Array, next step for me is to figure out how to access an array in .lua files (not familiar with lua at all but i assume its something like var[0] or simliar.

 

I digress, need to figure out how to find the variables and access them. Output from export to streamdeck is working, just can't access the raw data from here yet.

Modules: Persian Gulf | Normandy | Channel | Nevada | Supercarrier | WWII Assets | FC3 | Spitfire | P-51D | P-47D | F-86F | L-39 | AV-8B | F-16C | F/A-18C | A-10C | F-14B | A-4E-C | BS2

 

System: X570 AMD-3900X | 32GB DDR4 3000 | 2TB Gen 4x4 5GB/s NVME | Dual 1070 TI | 4k 32" Samsung

Link to comment
Share on other sites

Has anyone successfully displayed the top and bottom PCA texts of the M-2000C ?

 

I tried with the DCS ID 2010 to 2019 without succeeding :(

 

Same here no success :(

Intel® Core i7-7700K @4,20GHz - 64 Go RAM - GeForce GTX 1070 Ti - Windows Pro 64 bit - Stream Deck - HOTAS Warthog

Link to comment
Share on other sites

In case anyone haps upon this looking for one of the questions I asked above (about applying modifiers or math to the data), I edited my planes export dcs lua file and added the following to the following:

 

function ExportScript.ProcessIkarusDCSConfigHighImportance(mainPanelDevice)
    ExportScript.Tools.SendData(2001, string.format("%d", (mainPanelDevice:get_argument_value(12) * 360))..'°')
end

 

This now creates a new ID that i can monitor "2001" that displays 180° for my heading instead of 0.5000

 

Now I can apply similiar formatting to all the other values that look strange.

Modules: Persian Gulf | Normandy | Channel | Nevada | Supercarrier | WWII Assets | FC3 | Spitfire | P-51D | P-47D | F-86F | L-39 | AV-8B | F-16C | F/A-18C | A-10C | F-14B | A-4E-C | BS2

 

System: X570 AMD-3900X | 32GB DDR4 3000 | 2TB Gen 4x4 5GB/s NVME | Dual 1070 TI | 4k 32" Samsung

Link to comment
Share on other sites

I'll post my full p-51 additions for this streamdeck plugin tomorrow for you.

Modules: Persian Gulf | Normandy | Channel | Nevada | Supercarrier | WWII Assets | FC3 | Spitfire | P-51D | P-47D | F-86F | L-39 | AV-8B | F-16C | F/A-18C | A-10C | F-14B | A-4E-C | BS2

 

System: X570 AMD-3900X | 32GB DDR4 3000 | 2TB Gen 4x4 5GB/s NVME | Dual 1070 TI | 4k 32" Samsung

Link to comment
Share on other sites

Ok, as promised, I'm posting this here so that someone stumbling across this can get a real life working example. this isn't designed as a "how-to". when I wanted to do this I couldn't find an example of anyone calling the objects i required, so i took the day and started pumping through the code and what was called from where etc.. This type of example would have saved me a number of hours of slow progress.

 

Secondly, Yesterday was the first time I've ever laid eyes on lua, so suggestions and comments on code improvement (especially relating to the fuel function) are welcome, although the fuel function is less a lua logic problem and just a logic problem in general.

 

You asked where to insert? This is in the P-51D.lua file located in the C:\Users\YOU\Saved Games\DCS\Scripts\DCS-ExportScript\ExportsModules folder, obviously (to me) a part of the DCS-ExportScript Script that is required to run this streamdeck plugin. Both are great.

 

Below the ConfigArguments {} are the comments HIGH IMPORTANCE EXPORTS and the first function that starts:

 

-- Pointed to by ProcessIkarusDCSHighImportance
function ExportScript.ProcessIkarusDCSConfigHighImportance(mainPanelDevice)
--some comments about an a10c radio
end

 

you can replace the entire function above with the code below which includes the same function and a fuel function that I basically just outlined last night for future work.

 

From the below and the stream deck plugin I can now have a number of things I wanted like live heading and TAS and Altimeter information on the buttons including a single button that shows all the temperature and pressure information live with warnings, proper fuel guages etc.

 

I plan to change some of these numerical values into actual working guages on the streamdeck in the future. Maybe analog fuel guages or on jets having weapon systems that show the loadouts like the mfd's etc..

 

Anyways, here you go, hope this saves someone an hour or two as an example, not necessarily a pop this in my script and it works. keep in mind that although the code works, you would still need to setup the streamdeck plugin to work with it.

 

-----------------------------
-- HIGH IMPORTANCE EXPORTS --
-- done every export event --
-----------------------------

function ExportScript.CalculateFuel(fuelNeedlePosition)
--This is inaccurate at best, but gives a much better option than a straight multiplier. Have to figure out something better
--which multiplier applies (e.g. falls between 0.0 and 0.2, multiplier is value from dcs * (5.0 / 0.2) or .125 * 25 = us gallons)
-- Fuel_Tank_Left {0.0,5.0,15.0,30.0,45.0,60.0,75.0,92.0} {0.0,0.2,0.36,0.52,0.65,0.77,0.92,1.0} This is the multiplier's to position of needle index
local usGallons

if fuelNeedlePosition >= 0.96 then 
	usGallons = fuelNeedlePosition * (92.9)
elseif fuelNeedlePosition >= 0.92 and fuelNeedlePosition < 0.96 then --0.92 = 75usg - 92usg    MULTIPLIER = 
	usGallons = fuelNeedlePosition * (92.9-6)
elseif fuelNeedlePosition >= 0.77 and fuelNeedlePosition < 0.92 then --0.77 = 60 usg - 75 usg   MULTIPLIER = 
	usGallons = fuelNeedlePosition * (81.5-2)
elseif fuelNeedlePosition >= 0.65 and fuelNeedlePosition < 0.77 then --0.65 = 45 usg - 60 usg   MULTIPLIER = 
	usGallons = fuelNeedlePosition * (77.9-4)
elseif fuelNeedlePosition >= 0.52 and fuelNeedlePosition < 0.65 then --0.52 = 30 usg - 45 usg   MULTIPLIER = 
	usGallons = fuelNeedlePosition * (69.2-6)
elseif fuelNeedlePosition >= 0.36 and fuelNeedlePosition < 0.52 then --0.36 = 15 usg - 30 usg   MULTIPLIER = 
	usGallons = fuelNeedlePosition * (57.7-8)
elseif fuelNeedlePosition >= 0.2 and fuelNeedlePosition < 0.36 then --0.20 = 5 usg - 15 usg   MULTIPLIER = 
	usGallons = fuelNeedlePosition * (41.7-8)
elseif fuelNeedlePosition >= 0.0 and fuelNeedlePosition < 0.2 then --0.00 = 0 usg - 5 usg   MULTIPLIER = 
	usGallons = fuelNeedlePosition * 25
end

return usGallons
end


-- Pointed to by ProcessIkarusDCSHighImportance
function ExportScript.ProcessIkarusDCSConfigHighImportance(mainPanelDevice)

local trueHeading = string.format("%d", (mainPanelDevice:get_argument_value(12) * 360)) .. "°" .. "\nHDG"
ExportScript.Tools.SendData(2012, trueHeading) --True heading

ExportScript.Tools.SendData(2002, string.format("%d", (mainPanelDevice:get_argument_value(2) * 360)).. '° HDG')  --commanded heading knob

--	[96] = "%.4f",		-- Altimeter_10000_footPtr {0.0, 100000.0}{0.0, 1.0}
--add altimeter values up
local digAltitude = mainPanelDevice:get_argument_value(96) * 100000
local lowAltitude = 0
if digAltitude > 90000 then
	ExportScript.Tools.SendData(2025, "-") --ten thousands
else
	ExportScript.Tools.SendData(2025, string.format("%d", digAltitude)) --ten thousands
end

if digAltitude <= 50 then
	lowAltitude = 1
elseif digAltitude > 90000 then
	lowAltitude = 1
else
	lowAltitude = 0
end
ExportScript.Tools.SendData(2096, lowAltitude)

--[[
[160] = "%.4f",		-- Fuel_Tank_Fuselage {0.0,10.0,20.0,30.0,40.0,50.0,60.0,70.0,80.0,85.0} {0.0,0.12,0.28,0.40,0.51,0.62,0.72,0.83,0.96,1.0}
]]

ExportScript.Tools.SendData(2155, string.format("%d", ExportScript.CalculateFuel(mainPanelDevice:get_argument_value(155))) .. ' gal'  ) --155 Left Fuel Tank
ExportScript.Tools.SendData(2156, string.format("%d", ExportScript.CalculateFuel(mainPanelDevice:get_argument_value(156))) .. ' gal'  ) --156 Right Fuel Tank
--ExportScript.Tools.SendData(2155, string.format("%.4f", mainPanelDevice:get_argument_value(155))..' gal') --155 Left Fuel Tank
--ExportScript.Tools.SendData(2156, string.format("%d", mainPanelDevice:get_argument_value(156))..' gal') --156 Right Fuel Tank

local fuel_fuselage = mainPanelDevice:get_argument_value(160) * 100
if fuel_fuselage > 0.25 then
	ExportScript.Tools.SendData(2160, string.format("%d", (fuel_fuselage))..' gal') --160 Fuselage Tank
else
	ExportScript.Tools.SendData(2160, '- gal') --160 Fuselage Tank
end


local speedNum = mainPanelDevice:get_argument_value(11) * 1000
local speedNeedle = string.format("%d", (mainPanelDevice:get_argument_value(11) * 1000)) .. "\nMPH"
ExportScript.Tools.SendData(2011, speedNeedle) --Air Speed Needle

if speedNum < 455 then
	ExportScript.Tools.SendData(3011, 0) --Within Limits
else
	ExportScript.Tools.SendData(3011, 1) --About to Overspeed
end


local manifold = mainPanelDevice:get_argument_value(10) * 75 --manifold pressure
local rpm = mainPanelDevice:get_argument_value(23) * 4500
local tofTemp = mainPanelDevice:get_argument_value(30) * 100 --Oil.Temp.
local tofOil = mainPanelDevice:get_argument_value(31) * 200
local tofFuel = mainPanelDevice:get_argument_value(32) * 25

local FullInfoString = "Man. " .. string.format("%d", manifold) .. " inHg" ..
		   "\nEngRPM " .. string.format("%d", rpm) ..
		   "\nOil Temp " .. string.format("%d", tofTemp) .. " °C" ..
		   "\nOil " .. string.format("%d", tofOil) .. " PSI" ..
		   "\nFuel " .. string.format("%d", tofFuel) .. " PSI"

ExportScript.Tools.SendData(3033, FullInfoString)

--SYSTEMS MONITORING FOR ABOVE VALUES (changes stream deck buutton to red for one of the above values out of range (danger))
local infoDanger = 0

if manifold > 60 then --Manifold no more than 60 inches mercury
	infoDanger = 1
elseif rpm > 3025 then --rpm no more than 3000
	infoDanger = 1
elseif tofTemp > 90 then --temp no more than 90c
	infoDanger = 1
elseif tofOil > 90 then --Oil press. no more than 90PSI
	infoDanger = 1
elseif tofOil < 50 then --oil press. no less than 50
	infoDanger = 1
elseif tofFuel > 19 then --fuel press. no more than 19
	infoDanger = 1
elseif tofFuel < 12 then --fuel press. no less than 12
	infoDanger = 1
end

ExportScript.Tools.SendData(3032, infoDanger)

end

  • Like 1

Modules: Persian Gulf | Normandy | Channel | Nevada | Supercarrier | WWII Assets | FC3 | Spitfire | P-51D | P-47D | F-86F | L-39 | AV-8B | F-16C | F/A-18C | A-10C | F-14B | A-4E-C | BS2

 

System: X570 AMD-3900X | 32GB DDR4 3000 | 2TB Gen 4x4 5GB/s NVME | Dual 1070 TI | 4k 32" Samsung

Link to comment
Share on other sites

For some context, I posted a video of the live data on the stream deck so you can match the output with the above:

 

Modules: Persian Gulf | Normandy | Channel | Nevada | Supercarrier | WWII Assets | FC3 | Spitfire | P-51D | P-47D | F-86F | L-39 | AV-8B | F-16C | F/A-18C | A-10C | F-14B | A-4E-C | BS2

 

System: X570 AMD-3900X | 32GB DDR4 3000 | 2TB Gen 4x4 5GB/s NVME | Dual 1070 TI | 4k 32" Samsung

Link to comment
Share on other sites

Thanks chacal, Forgot to mention that the icons are a mix and match from all types of other icon stream deck projects on these forums. Would give credit where its due, but goodness knows which icons are from each person.

 

Next step is to create an icon pack for the p-51 when i have time. will post here.

Modules: Persian Gulf | Normandy | Channel | Nevada | Supercarrier | WWII Assets | FC3 | Spitfire | P-51D | P-47D | F-86F | L-39 | AV-8B | F-16C | F/A-18C | A-10C | F-14B | A-4E-C | BS2

 

System: X570 AMD-3900X | 32GB DDR4 3000 | 2TB Gen 4x4 5GB/s NVME | Dual 1070 TI | 4k 32" Samsung

Link to comment
Share on other sites

Anyone tell me how to get the F-18 SAI cage knob to work with one or two stream deck buttons?

I can't seem to make it go.

Not sure how much help you need in getting it working.

 

Looks like its ID 213 with a decimal number. Without testing (I'll take a look tonight if I have time), I'd guess it's a standard 0 for caged and 1 for un-caged (or vice-versa)

 

I'd monitor ID 213 in the text change box (3'rd option of the plugin) and cage/uncage the knob to see the value change live on the stream deck. That will tell you which values it needs to cage/uncage, and then use those values to send them in the first option.

Modules: Persian Gulf | Normandy | Channel | Nevada | Supercarrier | WWII Assets | FC3 | Spitfire | P-51D | P-47D | F-86F | L-39 | AV-8B | F-16C | F/A-18C | A-10C | F-14B | A-4E-C | BS2

 

System: X570 AMD-3900X | 32GB DDR4 3000 | 2TB Gen 4x4 5GB/s NVME | Dual 1070 TI | 4k 32" Samsung

Link to comment
Share on other sites

Hi Ctytler, quick question: am I correct that it is not possible to have an image state change and a title text change set for the same button? Or am I doing something wrong?

 

Background: I'm trying to program the Master Arm switch in the UH-1H, which is a three-way switch that has Off, Safe and Arm positions. I've had no problem getting the title text change function to display the state of the switch (-1=OFF,0=SAFE,1=ARM), but I'd also like to have the "Arm" position trigger a different (second state) icon since it's not possible to have different text colors for the different title text options on the same switch.

 

Thanks again for this amazing tool, and your excellent tutorial videos!

Link to comment
Share on other sites

Not sure how much help you need in getting it working.

 

Looks like its ID 213 with a decimal number. Without testing (I'll take a look tonight if I have time), I'd guess it's a standard 0 for caged and 1 for un-caged (or vice-versa)

 

I'd monitor ID 213 in the text change box (3'rd option of the plugin) and cage/uncage the knob to see the value change live on the stream deck. That will tell you which values it needs to cage/uncage, and then use those values to send them in the first option.

 

ID 214 gets mixed up with it somehow and in a way that I cannot seem to figure out.

It's as if it 213 won't work unless 214 is at a particular value.

I'm not smart enough to figure out how to shift them.

 

*Edit*

Got it sorted. Seems the knob needs to be three separate buttons one for 'CW' and one for 'CCW,' and one for push/pull.

It was more fun than the parking brake.


Edited by slaintemaith
Link to comment
Share on other sites

Hi Ctytler, quick question: am I correct that it is not possible to have an image state change and a title text change set for the same button? Or am I doing something wrong?

 

Background: I'm trying to program the Master Arm switch in the UH-1H, which is a three-way switch that has Off, Safe and Arm positions. I've had no problem getting the title text change function to display the state of the switch (-1=OFF,0=SAFE,1=ARM), but I'd also like to have the "Arm" position trigger a different (second state) icon since it's not possible to have different text colors for the different title text options on the same switch.

 

Thanks again for this amazing tool, and your excellent tutorial videos!

 

It is absolutely possible. Many of my switches show text change state and image change.

 

image change is second set of options and can monitor the same or different ID as the third option. It cannot change states 3 times (for a three way), but you could absolutely show armed or not. (e.g. text shows actual state -1, 0 or 1, but if armed then red light on button glows.

Modules: Persian Gulf | Normandy | Channel | Nevada | Supercarrier | WWII Assets | FC3 | Spitfire | P-51D | P-47D | F-86F | L-39 | AV-8B | F-16C | F/A-18C | A-10C | F-14B | A-4E-C | BS2

 

System: X570 AMD-3900X | 32GB DDR4 3000 | 2TB Gen 4x4 5GB/s NVME | Dual 1070 TI | 4k 32" Samsung

Link to comment
Share on other sites

ID 214 gets mixed up with it somehow and in a way that I cannot seem to figure out.

It's as if it 213 won't work unless 214 is at a particular value.

I'm not smart enough to figure out how to shift them.

 

*Edit*

Got it sorted. Seems the knob needs to be three separate buttons one for 'CW' and one for 'CCW,' and one for push/pull.

It was more fun than the parking brake.

 

Glad you got it sorted.

Modules: Persian Gulf | Normandy | Channel | Nevada | Supercarrier | WWII Assets | FC3 | Spitfire | P-51D | P-47D | F-86F | L-39 | AV-8B | F-16C | F/A-18C | A-10C | F-14B | A-4E-C | BS2

 

System: X570 AMD-3900X | 32GB DDR4 3000 | 2TB Gen 4x4 5GB/s NVME | Dual 1070 TI | 4k 32" Samsung

Link to comment
Share on other sites

Few questions:

 

-Is it possible to add a counter for something that doesnt have a gauge or clickable data, for example: BF109-K4 mk108 cannon ammo amount.

 

-I can find a dcs id for altitude (Bf109 again), but the value just starts from like 0.0001 and ends up at 1. Any way to make a conversion for this value to meters for example?

 

Thanks.

Link to comment
Share on other sites

Few questions:

 

-Is it possible to add a counter for something that doesnt have a gauge or clickable data, for example: BF109-K4 mk108 cannon ammo amount.

 

-I can find a dcs id for altitude (Bf109 again), but the value just starts from like 0.0001 and ends up at 1. Any way to make a conversion for this value to meters for example?

 

Thanks.

 

1. Gun Counter. You'll need to find the data that store the ammo info. Not sure personally, but now you have me wanting one, so I'll take a look.

 

2. Yes for altitude (check my video above) I have both and fuel and heading etc... this is why i originally posted my question on this thread. (I had heading information like 0.5000 which I wanted to make 180 by using 0.5000 *360 to output proper information).

 

My code above is doing what you are asking. You'll have to interpret it for your use case, but none the less it's a perfect example.

 

Keep in mind, if you are grabbing a needle position of the altitude it could be like the fuel guages and not linear in value. Make sure your output is linear (meaning 0.0100 is 100 feet and 0.0500 is 500 feet etc... not 0.0100 is 100 feet and 0.0325 is 500 feet) in which case it's much more complex, but still doable.

Modules: Persian Gulf | Normandy | Channel | Nevada | Supercarrier | WWII Assets | FC3 | Spitfire | P-51D | P-47D | F-86F | L-39 | AV-8B | F-16C | F/A-18C | A-10C | F-14B | A-4E-C | BS2

 

System: X570 AMD-3900X | 32GB DDR4 3000 | 2TB Gen 4x4 5GB/s NVME | Dual 1070 TI | 4k 32" Samsung

Link to comment
Share on other sites

I always output the raw information that I want changed (e.g. heading information) and output it to a stream deck key first and then make a table of that data compared to my guages while flying the plane to make sure i understand the output.

 

e.g. guage in plane shows 70gal, raw output shows 0.9234, guage in plane shows 60 gal and raw output shows 0.8254 etc...

Modules: Persian Gulf | Normandy | Channel | Nevada | Supercarrier | WWII Assets | FC3 | Spitfire | P-51D | P-47D | F-86F | L-39 | AV-8B | F-16C | F/A-18C | A-10C | F-14B | A-4E-C | BS2

 

System: X570 AMD-3900X | 32GB DDR4 3000 | 2TB Gen 4x4 5GB/s NVME | Dual 1070 TI | 4k 32" Samsung

Link to comment
Share on other sites

Sounds to me after reading your post again about your altitude value that you are not getting the altitude value ID, instead you are getting the altimeter needle position id which relates from .0001 to 1 the position of the altimeter needle.

Modules: Persian Gulf | Normandy | Channel | Nevada | Supercarrier | WWII Assets | FC3 | Spitfire | P-51D | P-47D | F-86F | L-39 | AV-8B | F-16C | F/A-18C | A-10C | F-14B | A-4E-C | BS2

 

System: X570 AMD-3900X | 32GB DDR4 3000 | 2TB Gen 4x4 5GB/s NVME | Dual 1070 TI | 4k 32" Samsung

Link to comment
Share on other sites

I took a quick look at the bf-109 exportscript lua file and found the following

 

	[8] = "%.4f",	-- Altimeter_FinePtr {0.0, 1000.0} = {0.0, 1.0}
[9] = "%.4f",	-- Altimeter_CoarsePtr {0.0, 13000.0} = {0.0, 1.0}

 

Looks to me (without testing) that these are the positions of the fine needle and the coars needle on the altimiter.

 

What we can deduce from the comments here are that

 

Altimeter_FinePtr (thousand feet total meaning it's the hundred foot needle)

Has altitude data from 0 - 1000 ' {0.0, 1000.0} or from 2,000-3,000 etc..

and the last brackets {0.0,1.0} means it will display this as raw information 0.000 - 1.000 defined by the %.4f formatting rule.

 

so 0.5000 is 500 feet.

 

To be more correct, it means the needle will be pointing at 500 feet when we are at 500 feet or 1,500 feet or 2,500 feet.

 

the next needle Altimeter_CoarsePtr goes from 0 to 13000.

 

At this very part of me writing this i realize its meters not feet, so change feet to meters in all the above (I'm lazy and busy right now)

 

so the Altimeter_CorsePtr goes from 0 to 13000M

 

We can probably just use this variable to give us meters

 

so if 0 is 0 meters and 1.0 is 13000m, then 0.5000 is 0.5000 * 13000 or 6500m

 

so you could use just that information to do this:

 

local digAltitude = mainPanelDevice:get_argument_value(9) * 13000

ExportScript.Tools.SendData(2000, string.format("%d", digAltitude).." M") 

 

This should output your altitude in M like 6500 M


Edited by nosaMtrevoC

Modules: Persian Gulf | Normandy | Channel | Nevada | Supercarrier | WWII Assets | FC3 | Spitfire | P-51D | P-47D | F-86F | L-39 | AV-8B | F-16C | F/A-18C | A-10C | F-14B | A-4E-C | BS2

 

System: X570 AMD-3900X | 32GB DDR4 3000 | 2TB Gen 4x4 5GB/s NVME | Dual 1070 TI | 4k 32" Samsung

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...