Jump to content
The simFlight Network Forums

WideClient Lua for GoFlight


r2500

Recommended Posts

There is support for GoFLight modules in FSUIPC, but not in WideClient. Instead, one can use GFdisplay.exe. But I thought it might be amusing to develop some Lua code to perform some of the same functions, both as a way to learn some Lua and because coding in Lua provides opportunities for quite elaborate functionality. My code is in the attached zip file. The reason the code is not a full replacement for GFdisplay is quite simply that I own only two modules, the display module GF-46 and the RP48 rotary/pushbutton/LED module. I like to think that adding other modules would not be at all difficult. When someone sends me the hardware, I'll give it a try :smile:.

That said, if you want to try the software, extract the four files in the attached zip. "gfDisplay.lua" goes in the same directory as WideClient. Create a subdirectory of the WideClient directory name "modules" and put the other files there. That is, if C:\flight contains WideClient.exe, C:\flight will have at a minimum three files, WideClient.exe, WideClient.ini, and gfDisplay.lua, and one directory "modules". "modules" will contain three files, gf46.lua, rp48.lua, and util.lua

When WideClient connects to the server, it will run gfDisplay.lua which in turns sets up all the necessary code and connections. On my system, for reasons I don't understand, it takes an additional 24 seconds for the display values to match the cockpit. Once that delay is past, updates are instantaneous.

In the code supplied, there are 3 sets of display items; one set contains 4 display items (autopilot altitude, autopilot vertical speed, heading bug, and OBS1), and the others each contain two. Each set can contain as many items as you wish and there can be as many sets as you want as well. You can switch the item displayed in any given set by using the pushbutton on the GF-46 module or by rotating the rightmost knob on the RP48. The latter is more convenient and you can go forwards or backwards. By rotating the 3rd RP48 knob (rightmost but one), you change the set being displayed. If you don't have the RP48, then of course you can have only one set of display values, though you could write code to substitute key presses, say, for the RP48 knobs. The second display set, as coded, shows NAV2 standby and transponder settings. The third set shows wind speed and time smoothed simulator frames per second.

The knob on the GF-46 is used to change the displayed value in the simulator. For instance, if the heading bug is displayed, turning the knob changes the bug position by one degree per click, and pressing the knob and turning changes the bug 10 degrees per rotary position.

To alter what is displayed on the GF-46 module, you will need to change the configuration tables at the start of gf46.lua. Note that each display set has a label (unused) and a current index value. In each set, each display item is encoded in a pair of tables. The first contains the display label, offset to monitor, type of offset (unsigned word or "UW", say), the ipc.read function, a display format for string.format, and a scaling table -- multiplier, divisor, and inversion flag [reciprocal of datum is what's to be scaled and displayed]. The second table holds the control values to be sent to FSUIPC via the ipc.control function for knob turned cw or ccw, or pressed and turned cw/ccw.

Code handling the RP48 is less clean.

Just for fun, I've included code to use the 8 LEDs of the RP48 to show taxi speed, with all lights lit at speeds of 20 mph or higher.

Richard

GoFDisplay.zip

Link to comment
Share on other sites

There is support for GoFLight modules in FSUIPC, but not in WideClient. Instead, one can use GFdisplay.exe. But I thought it might be amusing to develop some Lua code to perform some of the same functions, both as a way to learn some Lua and because coding in Lua provides opportunities for quite elaborate functionality. My code is in the attached zip file. The reason the code is not a full replacement for GFdisplay is quite simply that I own only two modules, the display module GF-46 and the RP48 rotary/pushbutton/LED module. I like to think that adding other modules would not be at all difficult.

Excellent!

Well done, and thank you very much for sharing! I can see clearly that your grip of Lua exceeds mine by a margin!

When WideClient connects to the server, it will run gfDisplay.lua which in turns sets up all the necessary code and connections. On my system, for reasons I don't understand, it takes an additional 24 seconds for the display values to match the cockpit. Once that delay is past, updates are instantaneous.

Whether it's 24 seconds or more or less, it is all to do with the amount of stuff requested and exchanged between Wideclient and WideServer during initialisation. It could probably be speeded up, but there can be complications so some of the delays are deliberately inserted to be sure data is correct.. Also this stuff is also usually happening at a time when FS + FSUIPC have other things to worry about in the server PC.

Best Regards

Pete

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.