Jump to content

G940 Leds - working program :)


Recommended Posts

it took me only 5 mins to setup my own config.

 

awesome program & script and very well documented!

 

 

:thumbup: :thumbup: :thumbup: :thumbup: :thumbup:


Edited by Alec Delorean

i9 13900K @5.5GHz, Z790 Gigabyte Aorus Master, RTX4090 Waterforce, 64 GB DDR5 @5600, Pico 4, HOTAS & Rudder: all Virpil with Rhino FFB base made by VPforce, DCS: all modules

Link to comment
Share on other sites

  • Replies 100
  • Created
  • Last Reply

Top Posters In This Topic

hi morg,

 

i want to add the led-function for autopilot route/descent mode.

 

something like this:

 

local route_descent = get_argument_str(MainPanel,XXX)

 

i forgot where to find the right value...

i9 13900K @5.5GHz, Z790 Gigabyte Aorus Master, RTX4090 Waterforce, 64 GB DDR5 @5600, Pico 4, HOTAS & Rudder: all Virpil with Rhino FFB base made by VPforce, DCS: all modules

Link to comment
Share on other sites

aahh, thanks, found it.

i was looking in the wrong file - command_defs.lua.

 

added the correct argument now.

 

local ap_route = get_argument_str(MainPanel,560) -- AP Route mode

 

c:send("SetOneAmber=5;DCSSetOneGreen=5"..ap_route..";")

 

working! :smartass:

 

 

added some advertisement for you at the bottom of my 1st g940 thread:

 

http://forums.eagle.ru/showpost.php?p=761425&postcount=1 :smilewink:


Edited by Alec Delorean

i9 13900K @5.5GHz, Z790 Gigabyte Aorus Master, RTX4090 Waterforce, 64 GB DDR5 @5600, Pico 4, HOTAS & Rudder: all Virpil with Rhino FFB base made by VPforce, DCS: all modules

Link to comment
Share on other sites

Finally gave this a try today. I'm on Win7 x64, and it works great. I was a bit confused at first as my buttons lit up like a Christmas tree in all sorts of colors and states, and didn't react to changing the states of the AP or TM. However, changing coroutine.create to g940leds_AutopilotTargetingMode solved that, and now it does exactly what I was hoping (guess I need to play with g940leds_example to see what that actually does). This is an excellent little utility that finally pumps some real value into this formerly dormant feature of the G940.

 

Oh, and one small request. Would it be possible to have the lights be turned off upon exiting the led app--or better yet, upon exit of BS. Right now, after I exit the lights remain in their last state, so I restart the application briefly to shut off the lights, then exit again.


Edited by ddahlstrom
Link to comment
Share on other sites

  • 2 weeks later...

I've been trying out TouchPal, but can't get both it and the G940 LED software to work together (they both customize export.lua). I've tried simply merging them together and removing anything in common, but it just results in lockups. Is there anyway to get both of these to play together nicely?

Link to comment
Share on other sites

You can override lua functions with new ones.

 

If you do something like this at the end of export.lua, both the original and the new function will be called in sequence:

 

-- Save the original function in a variable for later use
oldExportAfterNextFrame = LuaExportAfterNextFrame

-- Define a new export function
-- This one has to have the exact same name and parameters as the original
function LuaExportAfterNextFrame()
 oldExportAfterNextFrame() -- execute original function
 -- Put your code here
end

 

I don't know if the syntax is exactly right (my flightsim PC is still packed up from the Flightsim Weekend), but this should be the way to do it.

 

This can also be done in separate files, as long as you include them at the end of export.lua (with the dofile() function)

Dutch Flanker Display Team | LLTM 2010 Tiger Spirit Award
Link to comment
Share on other sites

Ok, I figured it out. There was a little more to it. I don't really claim to know what I'm doing. I read a lua (sorry, Lua) tutorial today, and now know enough to be really dangerous. I guess I was thrown by the coroutine stuff. Your hint suggested that I didn't need it. What I ended up doing was taking the stock export.lua supplied by the TouchPal project and adding three lines.

 

1. Add this to the end of LuaExportStart():

g940socketsetup()

2. Add this to the end of LuaExportAfterNextFrame():

g940leds_AutopilotTargetingMode()

3. Add this to the end of the file:

dofile("./Config/Export/G940leds.lua")

Then, inside G940leds.lua, I changed 'c' to 'd' in the g940socketsetup() function. This was needed since TouchPal calls the socket 'c'.

 

Finally, I refactored g940leds_AutopilotTargetingMode() to get rid of the coroutine stuff and the internal loop (since we're now calling it on every frame).

 

function g940leds_AutopilotTargetingMode()
   
   local MainPanel = GetDevice(0)    

   local bankhold = get_argument_str(MainPanel,330) -- Lit button
   local pitchhold = get_argument_str(MainPanel,331) -- Lit button
   local headinghold = get_argument_str(MainPanel,332) -- Lit button
   local altitudehold = get_argument_str(MainPanel,333) -- Lit button
   local flightdirector = get_argument_str(MainPanel,334) -- Lit button
   
   local autoturn = get_argument_str(MainPanel,437) -- Lit button
   local airborne = get_argument_str(MainPanel,438) -- Lit button
   local forwardhemisphere = get_argument_str(MainPanel,439) -- Lit button
   local groundmoving = get_argument_str(MainPanel,440) -- Lit button
   
   -- Create a string with flightdirector on the autopilot buttons for use with DCSAddRedIfGreen
   local fdstring = "0.00.0" .. flightdirector .. flightdirector .. "0.00.0" .. flightdirector .. flightdirector
       
   d:send("DCSSetGreen=" ..autoturn..forwardhemisphere..bankhold..pitchhold..airborne..groundmoving..headinghold..altitudehold..";DCSAddRedIfGreen=" .. fdstring..";")    
end

With these changes, TouchPal and G940LEDs now run in perfect sync.

 

Dave


Edited by ddahlstrom
Link to comment
Share on other sites

Greetings.

 

I've had my G940 for several weeks now. I even followed this thread before the purchase (seems there's not much out there taking advantage of the G940 LEDs). After pondering Morg's code and trying to get my head around it, I decided the next logical step would be purchasing DCS:BS (loving it, btw).

 

I'm no programmer but I can usually edit a config file or two without screwing things up. I've got Morg's program running. All the files are in place as per the instructions. The communications part appears to be working (I can update the LEDs with udp_sender.exe).

 

Nothing seems to happen when the application calls up the example functions (I've tried switching between the g940leds_AutopilotTargetingMode and g940leds_example).

 

My (dumb) question is: do I need to configure the controller in the Logitech software (ie: change the default DCS:BS load) so that it somehow reflects what these example functions are doing (ie: button#3 should be gear, etc)?

 

I just have a feeling that the LEDs are not working because I'm missing a step somewhere. It took me a few hours to realize that the udp_sender.exe would only work if main application was already running. I'm at further disadvantage because I'm not even remotely familiar with the sim yet.

 

Any tips appreciated.

Link to comment
Share on other sites

Thirdup, you might have missed to enable exporting in the Config.lua file that is located in the same director as export.lua.

 

Or you might have introduced a syntax error when editing in the files, have you checked Ka-50/temp/error.log (path and filename from memory, might be errors.log). If there is an error in one of the lua files it will be at the bottom of that file.

 

Might also be a firewall problem, altough i consider that highly unlikely when udp_sender is working.

Link to comment
Share on other sites

So it doesn't matter which profile I have loaded into the G940 via the Logitech software? For some reason I've got it in my head that I should have my button profile set up in the same fashion as the LED program uses (ie: button1 is autopilot on/off, button2 is toggle gear, etc)..

Link to comment
Share on other sites

Still can't clear that last hurdle......

 

I confirmed that exporting was set to "true" in the config.lua.

 

I'm working off a fresh BS install, so I used the included example_export.lua (removed the "example_" of course)

 

G940leds.exe launches and detects the G940 (it turns off all LEDs)

 

Udp_sender.exe is communicating and I can send color changes manually.

 

Game launch and flight still are not producing anything on the LEDs.

 

G940leds.exe is displaying the "hello" message (so it appears that the app is at least getting to the coroutine).

 

No errors in "errors.log" relating to this set of lua's (although I can produce one if try and I now know where they would be).

 

I've attempted to run both included coroutines with the same results.

 

I also tested/changed the "hello" message text to reflect which coroutine was running, and I can confirm that the export.lua edits are calling the assigned coroutine in the G940leds.lua.

 

I suck at this stuff, but I'm not giving up hope just yet.

Link to comment
Share on other sites

Since it sounds like you're doing things right, I'm just throwing a few less likely things out.

 

1. Did you use a non-friendly editor like notepad to do any of your editing?

2. Are you using v.1.0 of BS or 1.01? (not sure whether this makes a difference, but I know it works in 1.01)

Link to comment
Share on other sites

Hmmm, you know....I have a seperate text editor but I may have actually edited the lua's with notepad (actually, the only edit I think I initally made was to the config....so that might explain alot if the first thing I did horked things).

 

Not sure on the BS version (off-the-shelf install). I was unaware of a patch, but I'll check that first thing.

Link to comment
Share on other sites

Since it sounds like you're doing things right, I'm just throwing a few less likely things out.

 

1. Did you use a non-friendly editor like notepad to do any of your editing?

2. Are you using v.1.0 of BS or 1.01? (not sure whether this makes a difference, but I know it works in 1.01)

 

Well, I owe you a beer. I'm not sure which actually was causing the issue, but installing the 1.01 patch did the trick (it over-wrote my modified export.lua file which might have been the culprit).....I then used Morg's "example_export.lua" (sans "example_").

 

In any event, at least my throttle is all lit up like Christmas now.

 

*which of course means that I'll now have to figure it all out and see what i can break next.

 

Thanks ddahlstrom and thanks Morg!

Link to comment
Share on other sites

  • 2 months later...
  • Recently Browsing   0 members

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