Rewrite in Lua for FlyWithLua Plugin#13
Conversation
|
Hi, thank you for your pr. Everything that make is easier to use for all people is welcome. There are a few things in it I already began working:
Why did you drop support for EFIS L/R and Toliss airplanes? Switching to lua should be one pull-request and new features a extra one. Dropping features can not be merged. |
|
HI |
No. Maybe flywithlua is a good idea. Do you want wo work on it further or should I add Toliss an EFIS? |
| cache_data["autopilot_spd"] = 0 | ||
| cache_data["autopilot_spd_is_mach"] = 0 | ||
| cache_data["autopilot_hdg_mag"] = 0 | ||
| cache_data["autopilot_alt"] = 0 | ||
| cache_data["autopilot_vs"] = 0 | ||
| cache_data["autopilot_fpa"] = 0 | ||
| cache_data["autopilot_ap1"] = 0 | ||
| cache_data["autopilot_ap2"] = 0 | ||
| cache_data["autopilot_athr"] = 0 | ||
| cache_data["autopilot_appr"] = 0 | ||
| cache_data["autopilot_loc"] = 0 | ||
| cache_data["autopilot_spd_window"] = 0 | ||
| cache_data["autopilot_fpa_window"] = 0 | ||
| cache_data["autopilot_hdg_window"] = 0 | ||
| cache_data["autopilot_trkfpa"] = 0 | ||
| cache_data["autopilot_alt_mode"] = 0 |
There was a problem hiding this comment.
is cache_data needed in lua? What I had seen it is possible to map variables direct to datarefs.
There was a problem hiding this comment.
cache_data is used to check whether the values of these datarefs have changed. Otherwise, the LCD and LED would be redrawn in every loop
There was a problem hiding this comment.
Perhaps I should rename this variable to clarify its purpose
| set_button_assignment(821, "sim/autopilot/vertical_speed_down") | ||
| set_button_assignment(822, "sim/autopilot/vertical_speed_up") |
There was a problem hiding this comment.
shouldn't it be done during init?
There was a problem hiding this comment.
this code is outdated
I have indeed attempted to directly bind buttons to achieve these functionalities, aiming to minimize the reliance on more low-level interfaces, but it did not take effect. I am still working on resolving this issue. Moreover, I am uncertain whether the button IDs might change across different machines, which could potentially lead to additional development and configuration efforts
| set_button_assignment(821, "laminar/A333/autopilot/fpa_decrease") | ||
| set_button_assignment(822, "laminar/A333/autopilot/fpa_increase") |
There was a problem hiding this comment.
shouldn't it be done during init?
| local button = {} | ||
| for index = 0,32 do | ||
| local mask = 2^index | ||
| local bit = math.floor(event_bit/mask) | ||
| local bit_last = math.floor(last_event_bit/mask) | ||
| if (bit ~= bit_last) then | ||
| if (bit % 2 == 1) then | ||
| local id = index+1 | ||
| button_press_event_list[index]=1 | ||
| end | ||
| end | ||
| end | ||
| last_event_bit = event_bit |
There was a problem hiding this comment.
is this necessary when using hid? Why not work with button assignment instead?
| function find_fcu() | ||
| for i = 1,NUMBER_OF_HID_DEVICES do | ||
| local device = ALL_HID_DEVICES[i] | ||
| if ((device.vendor_id == 16536) and (device.product_id == 47888) ) |
If you're interested and have some free time, feel free to add any features you want to this script. After all, my work also relies on what you've done before. Maybe when I get new device and aircraft models, I can work on related stuff too, but I’m not sure about that yet. |
|
I tested you script now on my linux system. It is very slow. After turning a knob it takes 3 seconds to change the value, this is not usable. Does it work better on your setup? |
This script runs smoothly on my MacBook. I haven't tried it on a Linux platform yet, but I think it might be related to the HID interface. The hid_read in the script is set to a blocking mode with a 10ms timeout., if the device not respond, the loop will be blocked. You could use logMsg in on_button_event to see what slow down the loop. I'll try to fix this issue later update : try to use the lasted commit and see if the promble still exist |
|
No, it did not change anything. I added logMsg in line 159 (in function on_button_event) and I see it get's read more often than I get the button event. After more than 20 calls I see that I presses a button. Another problem is that often it does not connect, I get this output: |
|
When starting the macro for joystick button I get: and |
|
Thanks, the macro works now |
Okay, maybe different platforms require different implementation approaches. If I have time later, I'll see if I can deploy a Linux system on my old laptop to reproduce and resolve this issue. I've uploaded a demo video showing the running effect on a Mac platform. Thank you for your review over these past few days. |
|
Your video looks very good. |
|
Hi, great work from you! Just to let you know, I am trying to extend the lua script from samrq to work with EFIS R and EFIS L for the default LR A333. LEDs, switches and buttons are working right now, the two knobs and the LCD is still to do. |
Hi, I have done some work on my script and published a preliminary version: https://github.com/alha847/winwing_fcu_efis_lr Maybe its helpful for you. |
init alt100/1000 from ww fcu





Removed dependency on libusb.
Implemented the functionality using Lua for better integration with FlyWithLua.
Tested on the default A330-300 model, with the following results:
[Almost] All buttons, LCDs, and LEDs are functioning correctly.
Some LCDs related to autopilot alt ctrl require further testing.
Fix some format problem for spd and hdg