Skip to content
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

Scripted CRSF Menus #29368

Merged
merged 19 commits into from
Apr 9, 2025
Merged

Scripted CRSF Menus #29368

merged 19 commits into from
Apr 9, 2025

Conversation

andyp1per
Copy link
Collaborator

@andyp1per andyp1per commented Feb 24, 2025

Work kindly sponsored by Team Black Sheep and FOSS UAV

This PR adds the ability to create arbitrary custom menus in CRSF using lua scripting. This allows arbitrary scripted commands, including with user feedback, to be driven by transmitter menu interactions without requiring any additional installation on the transmitter. It opens up the possibility of allowing people to add arbitrary menus to individual lua scripts that can be the used easily from a transmitter. (I think this is quite a usability win fyi @rmackay9).
As much of the encoding as possible is done in lua to avoid the additional flash cost, but the menu structure itself still needs to be help in C++ in order to work correctly and efficiently.

An example menu can be seen in libraries/AP_Scripting/examples/crsf-menu.lua
and the output can be seen below.

image
image
image
image
image

@andyp1per andyp1per added the WIP label Feb 24, 2025
@andyp1per andyp1per requested a review from IamPete1 February 28, 2025 17:21
@andyp1per andyp1per marked this pull request as ready for review February 28, 2025 17:21
@rmackay9
Copy link
Contributor

rmackay9 commented Mar 4, 2025

just FYI, I added this as a bullet point on the Partners slides for this month

tridge
tridge previously requested changes Mar 5, 2025
Copy link
Contributor

@tridge tridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a more fleshed out example would be good
suggestion is ability to call an auxiliary function
compass cal?
accel cal?

Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to augment the existing CRSF test to cover some of this code

andyp1per added 14 commits April 3, 2025 14:35
add CRSF menu example
add scripted CRSF menu events
custom CRSFMenu helpers
play Beethoven's 5th on CRSF command
use native packed strings for CRSF menus and payloads
support CRSF submenus
scripted menu event processing
encoding for parameter entries
propagated payload length in processing frames and use it in scripting
support CRSF submenus
refactor parameter read and write so that custom responses can be sent
ensure parameter write responses do not override parameter metadata
@andyp1per andyp1per force-pushed the pr-crsf-menu-script branch from 1e9a102 to 5595354 Compare April 3, 2025 16:14
@andyp1per andyp1per requested a review from IamPete1 April 3, 2025 16:15
@andyp1per
Copy link
Collaborator Author

andyp1per commented Apr 3, 2025

Added a crsf-calibrate.lua applet

https://youtu.be/u8P8tj-KxXs

@IamPete1
Copy link
Member

IamPete1 commented Apr 8, 2025

Scripting stuff looks OK.

@tridge tridge added the WikiNeeded needs wiki update label Apr 9, 2025
@tridge tridge dismissed stale reviews from peterbarker and themself April 9, 2025 07:16

fixed

@tridge tridge merged commit 35ef1c6 into ArduPilot:master Apr 9, 2025
117 of 119 checks passed
@andyp1per andyp1per deleted the pr-crsf-menu-script branch April 9, 2025 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants