-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite in Lua for FlyWithLua Plugin #13
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I should rename this variable to clarify its purpose
fcu_driver.lua
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it be done during init?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
fcu_driver.lua
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it be done during init?
fcu_driver.lua
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this necessary when using hid? Why not work with button assignment instead?
fcu_driver.lua
Outdated
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) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please in hex :-)
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. |
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