Repository navigation
Fix pan/tilt with a negative value and make profile apply reliable - #151
Open
nbougaieff wants to merge 2 commits into
Open
nbougaieff wants to merge 2 commits into
nbougaieff wants to merge 2 commits into
Conversation
The two values were combined with an addition, so a negative second value borrowed from the first: writing (1, -1) sent 3599 arcseconds instead of 3600 for the first value and the camera did not move to it. Mask the second value to its own 4 bytes before combining. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Applying a profile started one unstructured Task per value, so the writes reached the camera in no fixed order and a manual value could arrive before its auto mode was turned off. A value equal to the cached one was also skipped, although the cache can be stale after auto mode. Write the values one after another on a single task, auto modes first, without comparing against the cache. Manual values are read back and retried for a short time, since a camera can ignore a write that comes right after auto mode is switched off. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes for applying a saved profile, found with a Logitech C922. One commit each.
Pan/tilt: a negative second value corrupts the first
UVCMultipleIntControlcombines the two values with an addition. When the second value is negative it borrows from the first, so writing (1, -1) sends 3599 arcseconds instead of 3600 for the first value. On the C922 the camera then stays at 0:The fix masks the second value to its own 4 bytes before combining. #148 and #150 both touch these two lines (parentheses, wrapping operators) but keep the addition, so as far as I can tell they do not change this result.
Profiles are not applied reliably
DeviceController.setassigns each property, and every property setter starts its own unstructuredTask. The writes therefore reach the camera in no fixed order, and a manual value can arrive before its auto mode has been turned off, in which case the camera rejects it. A value equal to the cached one is also skipped, although the cache can be stale after the camera has been in auto mode.Test: reset to defaults, apply a profile with every control set to a non-default value, wait, then read every control back from the device. Two different profiles alternating, 6 rounds per run.
The fix writes the values one after another on a single task, auto modes first, without comparing against the cache. Manual values are read back and retried for up to about a second, because a camera can ignore a write that comes right after auto mode is switched off. A value whose auto mode is on in the profile is written once and not retried. The published values are updated on the main actor after the write, so the sliders follow.
Only the
setpath is changed.write(),reset()andwriteValues()are untouched, to stay out of the way of #148.Testing
🤖 Generated with Claude Code