morg Posted October 11, 2009 Posted October 11, 2009 (edited) UPDATE: I have released a new, better, version. See post #20 http://forums.eagle.ru/showpost.php?p=772603&postcount=20 Hi! I've written a program for controlling the leds from BS today. Buttons 1,2,5,6 display the targeting mode (ie, ground moving, autoturn etc) and 3,4,7,8 show autopilot status. When flight director is activated the autopilot leds will be amber instead of green. I hope someone will find this useful. Add the function from addtoexport.lua to your export.lua file and just start g940.exe. I have no idea what kind of runtime libraries is needed to run it, it is the first program I have written in visual studio. EDIT: updated the coroutine so you don't have to change the host ip (it uses localhost now instead of my local ip.. :doh:) Edited October 26, 2009 by morg 3
-Bazong- Posted October 11, 2009 Posted October 11, 2009 Hi! I've written a program for controlling the leds from BS today. Buttons 1,2,5,6 display the targeting mode (ie, ground moving, autoturn etc) and 3,4,7,8 show autopilot status. When flight director is activated the autopilot leds will be amber instead of green. I hope someone will find this useful. Add the function from addtoexport.lua to your export.lua file and just start g940.exe. I have no idea what kind of runtime libraries is needed to run it, it is the first program I have written in visual studio. Sweet!! Very good job! :thumbup: I'll be downloading as soon as I get my G940!! :D
morg Posted October 12, 2009 Author Posted October 12, 2009 Would be nice if someone can confirm if it works or not :music_whistling: To make it more general (and to be able to use it from other sims as well) i was considering one of the following message "formats" Send only two bytes, one controlling green leds and one red leds. Is bit manipulation easy/effective in lua? Send two 8 (one 16) character string, one for green leds and one for red. Example "11000000 10100000" for setting P1 amber, P2 green and P3 red. (space inserted in string for clarity) Send a 8 character string, ex: "01230123", with 0 no color, 1 green, 2 red and 3 amber. (or perhaps "ograogra"...) Or a more complete message, for example "ALL=red;P1=amber;P7=green" Any input or other suggestions?
Joe Kurr Posted October 14, 2009 Posted October 14, 2009 Morg, you beat me to it :) I was also thinking about writing a program to control the leds on the G940 from lockon, and was just about to (try to) translate the sample program from the SDK to C#. What programming language did you use? I think option 3, with numeric values should be the easiest to implement. Dutch Flanker Display Team | LLTM 2010 Tiger Spirit Award
morg Posted October 14, 2009 Author Posted October 14, 2009 I used C++, i can send you the source when i get home.
Scarecrow Posted October 18, 2009 Posted October 18, 2009 Bump. That is really cool, could you manage to lay out and idiots guide for this as I don't know anything about all the data export stuff in lockon and DCS. I think this should be stickied, I'm thinking of getting the G940 and would never have the required grey cells to figure this out. The OP should post it over at the logitech forum aswell as it really is something that all g940 owners should be able to find easily. I salute you sir this is the kind of thing that logitech definately ought to hav done themselves as this is pitched as a mainstream/entry level product yet they are expecting "Joe Sixpack" to do alot of programming and have some pretty specialised knowledge.
Kirai Posted October 18, 2009 Posted October 18, 2009 Great work! The only thing I wish for right now is for me to assign what ever key assignment I want to to the changing lights. Go Ugly Early
morg Posted October 18, 2009 Author Posted October 18, 2009 Scarecrow, i will write a better guide for the next release, which i hope to do when my exams are over, probably during the next weekend. Kirai, planning to make that easier as well in the next release, in the mean time you can change the variables that get sent in c:send(..) line in the coroutine. sending 0.1 or 0.3 will make the led go green, and off otherwise.
Kirai Posted October 18, 2009 Posted October 18, 2009 Scarecrow, i will write a better guide for the next release, which i hope to do when my exams are over, probably during the next weekend. Kirai, planning to make that easier as well in the next release, in the mean time you can change the variables that get sent in c:send(..) line in the coroutine. sending 0.1 or 0.3 will make the led go green, and off otherwise. Oh so it is possible for me to assign for example GEARS to P1 and make it go red when in, green when out and amber when damaged? :) Go Ugly Early
morg Posted October 18, 2009 Author Posted October 18, 2009 No, sorry, but in a week it hopefully will ;)
Kirai Posted October 19, 2009 Posted October 19, 2009 No, sorry, but in a week it hopefully will ;) Can't wait, good luck mate! :thumbup: Go Ugly Early
morg Posted October 23, 2009 Author Posted October 23, 2009 I'm sorry to say i can't keep my promise. I have a working prototype of a better version, but plans have changed and i will be away this weekend and don't have the time to finish it. I haven't searched the forums yet, but is it possible to get information "all wheels locked", "wheels retracted" and somewhere in between? (ie, moving or damaged). I only found information for the gear handle, and thats not very useful. Thankful for any help. And also, if anyone wants a special function (ie, something that is not just a on/off light/switch or lit button(like autopilot buttons, dlink etc)) please tell me so i can make sure it is supported in the first release and if you know, what commands in lua are needed to get the information. I have made a special function for the burst length setting making it different colors for the three settings, maybe that gives you an idea what i mean. Hopefully this post made some sense, i am in quite a hurry...
Kirai Posted October 23, 2009 Posted October 23, 2009 I'm sorry to say i can't keep my promise. I have a working prototype of a better version, but plans have changed and i will be away this weekend and don't have the time to finish it. I haven't searched the forums yet, but is it possible to get information "all wheels locked", "wheels retracted" and somewhere in between? (ie, moving or damaged). I only found information for the gear handle, and thats not very useful. Thankful for any help. And also, if anyone wants a special function (ie, something that is not just a on/off light/switch or lit button(like autopilot buttons, dlink etc)) please tell me so i can make sure it is supported in the first release and if you know, what commands in lua are needed to get the information. I have made a special function for the burst length setting making it different colors for the three settings, maybe that gives you an idea what i mean. Hopefully this post made some sense, i am in quite a hurry... Take your time mate. Its better to get a good program then to have something made in a rush :) Go Ugly Early
Scarecrow Posted October 24, 2009 Posted October 24, 2009 Yeah don't rush this is worth waiting for, just got my G940 yesterday. Will this work for lockon or just for DCS?
morg Posted October 24, 2009 Author Posted October 24, 2009 If lockon has support for using the luasocket module (which i assume it does, or any other udp capable module) it will work as long as you write a script for it
RealDCSpilot Posted October 25, 2009 Posted October 25, 2009 :thumbup: very nice! this will become a musthave for all g940 pilots. tested it today, my results: - added the script to export.lua - changed "localhost" to match my ip - starting the g940.exe -> all led's turned off - console says: g940 throttle found but, it's currently not working on my system. i have vista64, allowed the g940.exe communicating through all ports of the firewall. it would be nice to have a little setup guide, but take your time, don't rush... i9 13900K @5.5GHz, Z790 Gigabyte Aorus Master, RTX4090 Waterforce, 64 GB DDR5 @5600, PSVR2, Pico 4 Ultra, HOTAS & Rudder: all Virpil with Rhino FFB base made by VPforce, DCS: all modules
morg Posted October 25, 2009 Author Posted October 25, 2009 First, you shouldn't have to change from localhost (not that it does any harm) The things that pop up is: - Have you activated export in config.lua? (maybe should have mentioned that in my post...) - You didn't insert a syntax error by mistake in export.lua? Check Ka-50/temp/error.log at the bottom, it will say if it failed to load the file.
RealDCSpilot Posted October 26, 2009 Posted October 26, 2009 got this: Dispatcher::Can't execute Lua file ./Config/Export/Export.lua - ./Config/Export/Export.lua:1074: attempt to perform arithmetic on global 'CoroutineIndex' (a nil value) i inserted the function at the bottom in export.lua (line 1074). can you please post your working export.lua file? i9 13900K @5.5GHz, Z790 Gigabyte Aorus Master, RTX4090 Waterforce, 64 GB DDR5 @5600, PSVR2, Pico 4 Ultra, HOTAS & Rudder: all Virpil with Rhino FFB base made by VPforce, DCS: all modules
morg Posted October 26, 2009 Author Posted October 26, 2009 Mine is changed someways to fit the new version im working on, so it wont work either. But i think the problem is that you are missing the following rows in export.lua, and they should be before all the other coroutine stuff Coroutines = {} -- global coroutines table CoroutineIndex = 0 -- global last created coroutine index Or you can wait till tomorrow sometime when i will release the new version ;)
morg Posted October 26, 2009 Author Posted October 26, 2009 (edited) Here comes the new version! It allows for much more custumization and is ready to add support for more games/functions. I have written a readme as well, and i hope it is understandable. It still has some issues, biggest one being that people who use the mode switch probably wont like that the leds cant change based on current mode. I hope to fix that some day. The default configuration isn't very usable, it's mostly an example of the special commands for DCS. Change 'g940leds_example' to 'g940leds_AutopilotTargetingMode' in export.lua on the line that says 'Coroutines[CoroutineIndex] = coroutine.create(g940leds_example)' to get a more usable version (same as the first version of the program). Note: Requires patch 1.01! Short overview for new people: G940leds is a program that listens on a UDP port for commands about how to light the leds on the G940 throttle. I have written it in a way that hopefully will minimize the need for conditionals and other code in the interface that talks directly to the game (for DCS, the lua code). Since the program itself is written in C++, it is probably alot faster at those things than a script. It comes with example scripts that shows how to use it with it BlackShark. Update: Had made a stupid bug in the G940leds.lua file. Fix uploaded (same name though)G940leds110.rar Edited November 13, 2009 by morg forgot the attachment....
Kirai Posted October 26, 2009 Posted October 26, 2009 Here comes the new version! It allows for much more custumization and is ready to add support for more games/functions. I have written a readme as well, and i hope it is understandable. It still has some issues, biggest one being that people who use the mode switch probably wont like that the leds cant change based on current mode. I hope to fix that some day. Short overview for new people: G940leds is a program that listens on a UDP port for commands about how to light the leds on the G940 throttle. I have written it in a way that hopefully will minimize the need for conditionals and other code in the interface that talks directly to the game (for DCS, the lua code). Since the program itself is written in C++, it is probably alot faster at those things than a script. It comes with example scripts that shows how to use it with it BlackShark. well done, I will give it a try even though I suck at editing things myself :P Go Ugly Early
RealDCSpilot Posted October 28, 2009 Posted October 28, 2009 hi morg, testreport: - udp_sender console works - but blackshark error.log says: Dispatcher::Can't execute Lua file ./Config/Export/Export.lua - ./Config/Export/Export.lua:169: bad argument #1 to 'create' (Lua function expected) line169: Coroutines[CoroutineIndex] = coroutine.create(g940leds_example) maybe there is something missing, unfortunately my lua knowledge is extremely low (i only worked once with lua particle-effects tables, as a specialFX-designer for a game-prototype). my question is, where is this coroutine created? new extra lua-file? sorry, i'm a noob... :music_whistling: i9 13900K @5.5GHz, Z790 Gigabyte Aorus Master, RTX4090 Waterforce, 64 GB DDR5 @5600, PSVR2, Pico 4 Ultra, HOTAS & Rudder: all Virpil with Rhino FFB base made by VPforce, DCS: all modules
morg Posted October 28, 2009 Author Posted October 28, 2009 Yeah, the coroutine is in G940leds.lua. you have to import it with dofile("./Config/Export/G940leds.lua") before adding it to the table
RealDCSpilot Posted October 28, 2009 Posted October 28, 2009 (edited) ahh, found it. you forgot to change the name of the function to Coroutines[CoroutineIndex] = coroutine.create(g940leds) in the export.lua from your download archive. the problem was that the coroutine (g940leds_example) doesn't exist. it may be important to check your files again. love the led transition for raising / lowering landing gear by the way! :thumbup: trying my own config now, thnx for this very cool tool! Edited October 28, 2009 by Alec Delorean i9 13900K @5.5GHz, Z790 Gigabyte Aorus Master, RTX4090 Waterforce, 64 GB DDR5 @5600, PSVR2, Pico 4 Ultra, HOTAS & Rudder: all Virpil with Rhino FFB base made by VPforce, DCS: all modules
morg Posted October 28, 2009 Author Posted October 28, 2009 oops, sorry about that, will fix it. Glad you like it!
Recommended Posts