Repository navigation
Conversation
2df1f5d to
4f500f2
Compare
Browser-based editor, developed by Atx_Heli, for the nine adjustable parameter slots on OSD Screens 5 and 6, offline or over USB via Web Serial and MAVLink. Adds the tool to the main index with an icon. Co-Authored-By: Claude Opus 5.5 <[email protected]>
4f500f2 to
465c86b
Compare
IamPete1
left a comment
There was a problem hiding this comment.
Should make use of existing modules. Everything needs un-minifying so it can be reivewed.
I would prefer than the style matched the other WebTools, but I don't care that much.
| @@ -0,0 +1,58 @@ | |||
| 'use strict'; | |||
There was a problem hiding this comment.
We already have a MAVLink implementation in modules/MAVLink. This new tool should use that so we only have to keep it upto date in one spot.
| @@ -0,0 +1,8 @@ | |||
| <!doctype html> | |||
There was a problem hiding this comment.
Its impossible to review minified code. Please re-format.
| @@ -0,0 +1,90 @@ | |||
| 'use strict'; | |||
There was a problem hiding this comment.
Per html please un minify to make it easier to review.
| @@ -0,0 +1,48 @@ | |||
| :root{font:15px/1.5 system-ui,-apple-system,Segoe UI,sans-serif;color:#223247;background:#eef3f8}*{box-sizing:border-box}body{margin:0}.wrap{max-width:1320px;margin:auto;padding:24px}header{padding:20px 4px 16px}h1{font-size:clamp(28px,4vw,40px);line-height:1.1;color:#123a73;margin:5px 0}.eyebrow{font-size:12px;font-weight:800;letter-spacing:1.8px;color:#446991}.by{font-weight:700;color:#123a73;margin:8px 0}.notice{background:#fff6df;border:1px solid #e5c97c;border-left:5px solid #bd8525;padding:13px 16px;border-radius:8px;margin:12px 0 18px}.card{background:#fff;border:1px solid #d8e2ed;border-radius:12px;box-shadow:0 3px 18px #2442600a;margin:15px 0;padding:18px}.toolbar{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin:4px 0 12px}.toolbar:last-child{margin-bottom:0}button,.filebtn,select{font:inherit;border-radius:7px;border:1px solid #b6c8da;padding:8px 12px;background:#f8fbff;color:#163b68;cursor:pointer}button:hover,.filebtn:hover{background:#e5effb}button:focus-visible,input:focus-visible,select:focus-visible{outline:3px solid #78aaf1;outline-offset:1px}label{font-weight:600}select{margin-left:6px}#fetchMeta,#saveJson{background:#123a73;color:white;border-color:#123a73}#fetchMeta:hover,#saveJson:hover{background:#22558f}.muted{color:#667789;font-weight:400}.tiny{font-size:12px}.tabs{display:flex;gap:8px;border-bottom:1px solid #d8e2ed;padding-bottom:10px;margin-bottom:14px}.tabs button.active{background:#123a73;color:#fff}.tablewrap{overflow-x:auto}table{border-collapse:collapse;width:100%;min-width:980px}th{background:#edf3f9;color:#304e6d;text-align:left;font-size:13px}th,td{border-bottom:1px solid #e6ecf2;padding:10px 8px;vertical-align:middle}th small{display:block;font-weight:400}td:first-child{font-weight:700;color:#123a73;text-align:center}input[type=text],input[type=number]{font:inherit;width:100%;padding:8px;border:1px solid #bdccda;border-radius:6px;background:#fff}input[type=text]:focus,input[type=number]:focus{border-color:#4174a8}td:nth-child(2){width:30%}td:nth-child(n+3):nth-child(-n+5){width:12%}.desc{font-size:12px;color:#65758a;max-width:280px;overflow-wrap:anywhere}.logtop{display:flex;justify-content:space-between;align-items:center}.logtop h2{font-size:18px;margin:0 0 10px}#log{min-height:100px;max-height:230px;overflow:auto;background:#f7f9fc;border:1px solid #dfe7ef;border-radius:7px;padding:10px;font:13px/1.6 ui-monospace,Consolas,monospace}.log-success{color:#16743b}.log-warning{color:#b3242d}.log-info{color:#334b63}footer{text-align:center;color:#6c7d90;padding:16px}@media(max-width:600px){.wrap{padding:12px}.card{padding:12px}.toolbar>*{flex-grow:1}} | |||
Address review feedback: - Reformat index.html, app.js, style.css and usb.js so they can be reviewed (app.js formatting only, no code changes) - Remove the bundled MAVLink codec and use modules/MAVLink/mavlink.js; usb.js keeps only the Web Serial transport - Correct browser support notes: Firefox works on Windows, but snap builds of Firefox and Chromium on Linux cannot access serial ports - README: serve from the repo root so the shared module loads Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for the review. Pushed d666196:
Tested against a real flight controller over USB, and lint passes. I've left matching the styling of the other WebTools for a follow-up, since you said it wasn't essential. Happy to do it in this PR if you'd prefer. |
| Plane: 'https://autotest.ardupilot.org/Parameters/ArduPlane/apm.pdef.xml', | ||
| Copter: 'https://autotest.ardupilot.org/Parameters/ArduCopter/apm.pdef.xml', | ||
| Rover: 'https://autotest.ardupilot.org/Parameters/Rover/apm.pdef.xml', |
There was a problem hiding this comment.
The other tools just include the json files directly. Removing the need to mess about running a fetch and allowing the tool to run offline.
There was a problem hiding this comment.
Done in f861095. Each vehicle now has a bundled <Vehicle>_params.json (Plane, Copter, Rover), loaded the same way as the other tools, so there is no runtime fetch and it works offline. They are full parameter lists, because any writable parameter can go in a slot, trimmed to just display name, range and increment (~450 KB each). Read-only parameters are left out. update_params.py regenerates them from the published apm.pdef.json.
| for (const screen of [5, 6]) for (let slot = 1; slot <= 9; slot++) state.slots[`${screen}:${slot}`] = emptySlot(); | ||
| // Show an in-progress label until the action settles, including failures. | ||
| // Allow one paint frame so synchronous operations visibly update their button. | ||
| async function withProgress(id, label, action) { |
There was a problem hiding this comment.
I think this is equivalent to our pre-existing loading overlay helper. Search for init_loading_overlay and loading_call
There was a problem hiding this comment.
Agreed, switched to Libraries/LoadingOverlay.js and removed withProgress. The overlay is only used for the slow FC read and write. The other buttons (save, clear, fill, etc.) are instant, so they now just run directly.
| await downloadMetadata(); | ||
| }), | ||
| ); | ||
| $('xmlFile').addEventListener('change', event => loadFile(event, text => applyMetadata(text, 'local XML'))); |
There was a problem hiding this comment.
Does anyone actually ever need to do this? If they do then you would be better off getting them to load the json param def.
There was a problem hiding this comment.
No, it was only a fallback for when the autotest fetch was blocked. Now that the metadata is bundled it is not needed, so it has been removed, along with the Download metadata button.
| $('jsonFile').addEventListener('change', event => loadFile(event, loadJson)); | ||
| $('paramFile').addEventListener('change', event => loadFile(event, parseParam)); | ||
| $('saveJson').addEventListener('click', () => withProgress('saveJson', 'SAVING…', saveJson)); |
There was a problem hiding this comment.
Its not clear to me how the json that can be saved and loaded is different from a param file. Does it include any more information?
There was a problem hiding this comment.
Yes, it holds the part a .param file can't: the parameter assigned to each slot. In a .param file the slot assignment is stored as OSDn_PARAMm_KEY/IDX/GRP, which are internal AP_Param key/index/group numbers. They aren't readable and can't be turned back into a parameter name without the firmware, which is why the .param import only brings in MIN/MAX/INCR/EN. The JSON saves each slot by name (e.g. RLL_RATE_P) plus its ranges and enable state, so a layout can be saved, shared and applied to another FC. That matters for usability, so I'd like to keep it. I've added this explanation to the README.
| <div class="toolbar"> | ||
| <label | ||
| >USB baud | ||
| <select id="baud" title="USB serial speed; 115200 is typical"> | ||
| <option>115200</option> | ||
| <option>57600</option> | ||
| <option>921600</option> | ||
| <option>460800</option> | ||
| </select></label | ||
| ><button id="usbConnect" title="Choose a USB serial device using the browser permission dialog"> | ||
| Connect USB</button | ||
| ><button id="usbDisconnect" title="Close USB connection">Disconnect</button | ||
| ><button | ||
| id="readFC" | ||
| title="Read FC parameters and OSD slots; replaces the editor's current slot assignments" | ||
| > | ||
| Read from FC</button | ||
| ><button id="writeFC" title="Write changed OSD slots and verify them">Write to FC</button | ||
| ><span id="usbStatus" class="muted" aria-live="polite">Disconnected</span> |
There was a problem hiding this comment.
Does supporting MAVLink and USB add enough value compared to just downloading a param param file and then loading it with your favorite GCS. All the other WebTools just give you a param file.
There was a problem hiding this comment.
I guess one enhancement would be to allow loading a log and then extract the params from it.
There was a problem hiding this comment.
For this tool I think it's the core of it, for the same reason as the JSON. Assigning a parameter to a slot by name only works through OSD_PARAM_CONFIG / OSD_PARAM_SHOW_CONFIG, where the FC resolves the name to key/idx/grp itself. A param-file-only tool could set the ranges but couldn't show what's in each slot or change it, and that's the main thing users struggle with. Mission Planner has an equivalent screen, but QGC and MAVProxy users don't.
There was a problem hiding this comment.
Nice idea, but a log has the same problem: it records the slot as KEY/IDX/GRP numbers, not names, and I don't know of a way to map those back to a parameter name without the firmware. So I'll leave log loading out for now.
| <div class="toolbar"> | ||
| <label | ||
| >Vehicle | ||
| <select id="vehicle" title="Select a vehicle type to load its published parameter catalog"> |
There was a problem hiding this comment.
If you did load from a log then you could get the vehicle type along with the params. If you keep the MAVLink stuff you should also be able to get (guess) the vehicle type from the heartbeat.
There was a problem hiding this comment.
Done. When connected, the vehicle is now set from the heartbeat MAV_TYPE, including all multirotor, heli and VTOL types. The manual selector stays for offline editing.
| ><button id="saveJson" title="Save both OSD screens as a desktop-compatible JSON project"> | ||
| Save JSON</button | ||
| ><label class="filebtn" title="Import numeric OSD fields from a Mission Planner .param file" | ||
| >Load .param<input id="paramFile" type="file" accept=".param,.txt,text/plain" hidden /></label |
There was a problem hiding this comment.
Should also add .parm which I think is what MAVProxy give you.
- Bundle per-vehicle parameter metadata (<Vehicle>_params.json) instead of fetching apm.pdef.xml at runtime; add update_params.py to regenerate it from the published apm.pdef.json, keeping only writable params with display name, range and increment - Remove Download metadata and Load metadata XML - Use the shared LoadingOverlay for FC read/write instead of a custom button progress helper - Set vehicle from heartbeat for all copter, heli and VTOL MAV_TYPEs - Accept .parm files - README: explain why JSON is needed to keep slot assignments Co-Authored-By: Claude Opus 5.5 <[email protected]>
Previous review (2026-11-22)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head The new OSD Parameter Editor works for the common read/edit/write path, and the earlier maintainer points (shared MAVLink module, un-minified code, bundled metadata, shared loading overlay, Blocking
Should fix
Low
Minor (3)
|
- Reset a slot's config_type when its parameter changes, so the ranges entered are applied instead of the old type's fixed ranges - Verify type and ranges on write readback, and store the FC's values - Treat OSD_PARAM_INVALID_PARAMETER_INDEX replies as empty, writable slots - Close the port properly when the serial read loop fails - Export .param enable flags from the Enable checkbox - Disable a slot when its name is cleared by typing - Confirm the vehicle type from the FC parameter list - Remove development notes from the page Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Addressed the automated review in 6c656bc (checked against Blocking
Should fix
Low / minor
The SITL segfault is a firmware issue, outside this PR. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Previous review (2026-11-22)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head No blocking issues remain at this head. A few smaller lifecycle and UI points are left. Since the last review, 6c656bc fixed the config_type blocker and all four should-fix items: result-2 slots, Should fix
Low
Minor (3)
The earlier SITL segfault note is firmware-side and is not carried forward. |
- Clear the read baseline on connect and at read start, and abort a read whose USB link dropped or changed, so Write can't be enabled from a partial or stale read - Detect Copter from PILOT_SPD_UP (Copter 4.7+) as well as PILOT_SPEED_UP - Refresh the Current value cell when the parameter name is edited - Shift Min/Max/Increment CSS column ranges for the new Current value column - Block repeat Connect clicks while the port is opening - Swallow the orphaned wait rejection when send() fails in request() Co-Authored-By: Claude Opus 5.5 <[email protected]>
Previous review (2026-11-22)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head No blocking issues at this head; three small points remain. Since the last review, 0ca3766 fixed the stale-baseline should-fix item and all five lower-severity items: Copter detection from Low
Minor (1)
|
- Clear FC parameter values on connect and disconnect so the Current value column doesn't show a previous FC's values - Fetch a slot's OSDn_PARAMm_EN with PARAM_REQUEST_READ if the parameter list missed it; if still unknown, leave the slot out of the writable baseline so a range edit can't silently enable it - Ignore disconnect callbacks from a connection that is no longer current Co-Authored-By: Claude Opus 5.5 <[email protected]>
Previous review (2026-11-22)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head No blocking issues at this head; two small points remain. Since the last review, 8748b13 fixed all three earlier items: the stale Current value column, slots with an unknown enable flag being writable, and a late disconnect callback dropping a new connection. Low
Minor (1)
|
- Snapshot each changed slot when Write starts, so edits made while it runs can't change what is sent or what the readback is checked against. - Compare ranges at float32 precision with no absolute floor, so small increment changes (e.g. 1e-6 -> 1e-5) are detected. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Addressed the latest automated review in cfac013: Low
Minor
|
Previous review (2026-11-23)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head No blocking issues at this head; one small regression remains. Since the last review, cfac013 fixed both earlier items: Write now sends and verifies a snapshot of each slot, and small increment changes such as 0.000001 to 0.00001 are now detected. Low
|
Round the sent range values the same way as the FC readback (float32, 7 significant digits) before comparing, so values with more than 7 significant digits no longer fail verification. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Addressed the latest automated review in 77e22c0: Low
|
Previous review (2026-11-23)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head No blocking issues at this head; two small float-precision points remain. Since the last review, 77e22c0 fixed the false readback mismatch for values such as Low
|
- Store ranges read from the FC as the shortest decimal that converts back to the same float32 (instead of 7 significant digits), so an untouched range is re-sent unchanged, e.g. ADSB_ICAO_ID max 16777215 - Verify readback against the values sent with the 1-ulp sameNumber(), so float32 ties that jspack rounds up (6593937.25, 16777225) no longer give a false readback range mismatch Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Addressed the latest automated review in cc1eae7: Low
|
Previous review (2026-11-24)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head No blocking issues at this head; three small points remain. Since the last review, cc1eae7 fixed both float-precision items: untouched ranges such as Low
Minor (2)
|
- Upper-case parameter names when loading bundled metadata, so the upstream mixed-case FOLLP_LkAHD matches the FC's FOLLP_LKAHD. - Race send() against the response wait in request(), so a stalled serial write still times out instead of leaving Read/Write busy. - Correct the fcText() comment: the tolerance is strictly under half an ulp, not a quarter. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Addressed the latest automated review in 5edde30:
|
|
Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head No blocking issues at this head; two small, rarely hit points remain. Since the last review, 5edde30 fixed all three earlier points: Minor (2)
|

This PR adds a browser-based ArduPilot OSD Parameter Editor, developed by Atx_Heli.
The utility allows users to configure the nine adjustable parameter slots on OSD Screens 5 and 6.
Features
The tool is also added to the main WebTools index page with an icon.
Compatibility
Works in desktop Chrome, Edge and Firefox using Web Serial, with no additional software installation required. Requires HTTPS or localhost. Safari is not supported (no Web Serial).
Testing
Tested extensively on PC in both Chrome and Firefox with an ArduPlane 4.8-dev flight controller, including USB connect, read, write and verification of OSD slots.
Author: Atx_Heli
🤖 Generated with Claude Code