This PR is from two commits: one that refactors script.rs to make it easier to handle, and the other that introduces new SDK message.
The degree of refactoring is higher than standard comfort level, but I hope you agree that the result is worth it. I think there are more good candidates for refactoring, but I didn't want to go too crazy in a single PR.
Be sure to run the profile_control.py example. It's a fun one. I think there's a lot of potential here.
Bullets from commit messages:
Fix fn for Message::SetParameter so that it really does restart the script if the on_set_parameter Lua function isn't present. Also, save the parameter changes first, in case the script chokes on the parameter update.
Fix documentation on mouse button function names.
Simplify how parameters are passed from main.rs to threads.rs to script.rs. More changes to come later.
Tweak the way Lua functions are called so that the functions are now cached. Caching probably isn't necessary for performance, but was just a side effect of knowing when to skip the function call if the function was absent.
Also, remove ACTIVE_SCRIPTS. It was not used except where elements were being added to it and never removed from it. (If the need for it returns, it should come back as something like a map of structs that also contains the Message channel sender.)
Finally, tweak the Makefile to avoid using brace expansion. That only works in some shells.
Change the SDK IPC message structure to make payloads easier to deal with.
Add ActiveProfile, SwitchProfile, and SetParameters SDK messages. These behave similarly to their D-Bus equivalents, except the SDK SetParameters can set multiple parameters at once while the D-Bus SetParameter only sets one. The D-Bus side can be improved later.
The Lua script message to update parameters takes multiple values as well. The value argument to the on_apply_parameter handler is no longer supplied. on_apply_parameter now only takes a list of parameter names. Documentation and build-in scripts have been updated.
The Python SDK fully supports the ActiveProfile, SwitchProfile, and SetParameters messages through get_active_profile(), switch_profile(), and set_parameters(). An example file has been provided and documentation has been updated.
The Rust SDK has also been updated, but without examples or documentation.
Export a stringify function to Lua to make life easier when debugging.
Enhance some error messages.
Additional work is still needed to improve the handling of bad input from the SDK messages.
profiles::ConfigParam, manifests::ConfigParam, ParameterValue, and UntypedParameterValue all cry out for a more organized struture.
This PR is from two commits: one that refactors script.rs to make it easier to handle, and the other that introduces new SDK message. The degree of refactoring is higher than standard comfort level, but I hope you agree that the result is worth it. I think there are more good candidates for refactoring, but I didn't want to go too crazy in a single PR. Be sure to run the profile_control.py example. It's a fun one. I think there's a lot of potential here.
Bullets from commit messages:
Fix fn for Message::SetParameter so that it really does restart the script if the on_set_parameter Lua function isn't present. Also, save the parameter changes first, in case the script chokes on the parameter update.
Fix documentation on mouse button function names.
Simplify how parameters are passed from main.rs to threads.rs to script.rs. More changes to come later.
Tweak the way Lua functions are called so that the functions are now cached. Caching probably isn't necessary for performance, but was just a side effect of knowing when to skip the function call if the function was absent.
Also, remove ACTIVE_SCRIPTS. It was not used except where elements were being added to it and never removed from it. (If the need for it returns, it should come back as something like a map of structs that also contains the Message channel sender.)
Finally, tweak the Makefile to avoid using brace expansion. That only works in some shells.
Change the SDK IPC message structure to make payloads easier to deal with.
Add ActiveProfile, SwitchProfile, and SetParameters SDK messages. These behave similarly to their D-Bus equivalents, except the SDK SetParameters can set multiple parameters at once while the D-Bus SetParameter only sets one. The D-Bus side can be improved later.
The Lua script message to update parameters takes multiple values as well. The value argument to the on_apply_parameter handler is no longer supplied. on_apply_parameter now only takes a list of parameter names. Documentation and build-in scripts have been updated.
The Python SDK fully supports the ActiveProfile, SwitchProfile, and SetParameters messages through get_active_profile(), switch_profile(), and set_parameters(). An example file has been provided and documentation has been updated.
The Rust SDK has also been updated, but without examples or documentation.
Export a stringify function to Lua to make life easier when debugging.
Enhance some error messages.
Additional work is still needed to improve the handling of bad input from the SDK messages.
profiles::ConfigParam, manifests::ConfigParam, ParameterValue, and UntypedParameterValue all cry out for a more organized struture.