-
Notifications
You must be signed in to change notification settings - Fork 115
Custom pwm output widgets #3668
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
Draft
Williangalvani
wants to merge
2
commits into
bluerobotics:master
Choose a base branch
from
Williangalvani:custom_pwm_output_widgets
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Custom pwm output widgets #3668
Williangalvani
wants to merge
2
commits into
bluerobotics:master
from
Williangalvani:custom_pwm_output_widgets
+1,281
−424
Conversation
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
…types of functions
Reviewer's GuideRefactors the servo function editor to delegate to specialized widgets based on the selected function type (motor, generic servo range, GPIO, actuator), introducing new dedicated Vue components for PWM range and motor configuration while preserving and adapting the existing slider-based min/trim/max editor logic. Sequence diagram for motor PWM editing and persistencesequenceDiagram
actor User
participant ServoFunctionMotorEditor
participant AutopilotStore as AutopilotStore
participant Parameter
participant Mavlink2Rest as Mavlink2Rest
User->>ServoFunctionMotorEditor: Open servo function dialog
ServoFunctionMotorEditor->>AutopilotStore: parameter(MOT_PWM_TYPE)
AutopilotStore-->>ServoFunctionMotorEditor: mot_pwm_type_param
ServoFunctionMotorEditor->>AutopilotStore: parameter(MOT_PWM_MIN, MOT_PWM_MAX or *_MIN, *_MAX)
AutopilotStore-->>ServoFunctionMotorEditor: min_param, max_param, trim_param
ServoFunctionMotorEditor->>ServoFunctionMotorEditor: initializeSliderValues()
User->>ServoFunctionMotorEditor: Drag slider thumb
ServoFunctionMotorEditor->>ServoFunctionMotorEditor: onSliderMouseDown(event)
ServoFunctionMotorEditor->>ServoFunctionMotorEditor: calculateValueFromEvent()
ServoFunctionMotorEditor->>ServoFunctionMotorEditor: findClosestThumb()
loop While dragging
User->>ServoFunctionMotorEditor: Move pointer
ServoFunctionMotorEditor->>ServoFunctionMotorEditor: onSliderMouseMove(event)
ServoFunctionMotorEditor->>ServoFunctionMotorEditor: updateThumbValue(event)
ServoFunctionMotorEditor->>ServoFunctionMotorEditor: updateValueBasedOnThumb(value)
ServoFunctionMotorEditor->>ServoFunctionMotorEditor: updateMinTrimMax()
ServoFunctionMotorEditor->>Parameter: update local Parameter.value
end
User->>ServoFunctionMotorEditor: Release mouse button
ServoFunctionMotorEditor->>ServoFunctionMotorEditor: onSliderMouseUp()
ServoFunctionMotorEditor->>Parameter: resolve selected param
ServoFunctionMotorEditor->>Mavlink2Rest: setParam(param.name, value, AutopilotStore.system_id, param.paramType.type)
Mavlink2Rest-->>ServoFunctionMotorEditor: ack
ServoFunctionMotorEditor->>Parameter: param.value = value
Class diagram for new servo function editor componentsclassDiagram
class ServoFunctionEditorDialog {
+Parameter param
+boolean value
+function_type() VueConstructor
}
class ServoFunctionRangeEditor {
+Parameter param
-number minValue
-number trimValue
-number maxValue
-number activeThumb
-boolean isDragging
+trim_param() Parameter
+max_param() Parameter
+min_param() Parameter
+minPercent() number
+trimPercent() number
+maxPercent() number
+getParamByType(type string) Parameter
+calculatePercentage(value number) number
+updateParamValue(type ParamType, newValue number) void
+initializeSliderValues() void
+getThumbPosition(index number) number
+getThumbValue(index number) number
+startDragging(index number) void
+onSliderMouseDown(event MouseEvent) void
+calculateValueFromEvent(event MouseEvent, container HTMLElement) object
+findClosestThumb(value number) number
+onSliderMouseMove(event MouseEvent) void
+onSliderMouseUp() void
+updateThumbValue(event MouseEvent) void
+updateValueBasedOnThumb(value number) void
+updateMin(value string) void
+updateTrim(value string) void
+updateMax(value string) void
+updateParamWithConstraints(value string, param Parameter, min number, max number, property string) void
+onTouchStart(event TouchEvent) void
+onTouchMove(event TouchEvent) void
+onTouchEnd() void
}
class ServoFunctionMotorEditor {
+Parameter param
-number minValue
-number trimValue
-number maxValue
-number activeThumb
-boolean isDragging
+trim_param() Parameter
+max_param() Parameter
+min_param() Parameter
+mot_pwm_type_param() Parameter
+mot_pwm_type() PwmTypes
+mot_pwm_type_is_supported() boolean
+minPercent() number
+trimPercent() number
+maxPercent() number
+getParamByType(type string) Parameter
+calculatePercentage(value number) number
+updateParamValue(type ParamType, newValue number) void
+initializeSliderValues() void
+getThumbPosition(index number) number
+getThumbValue(index number) number
+startDragging(index number) void
+onSliderMouseDown(event MouseEvent) void
+calculateValueFromEvent(event MouseEvent, container HTMLElement) object
+findClosestThumb(value number) number
+onSliderMouseMove(event MouseEvent) void
+onSliderMouseUp() void
+updateThumbValue(event MouseEvent) void
+updateValueBasedOnThumb(value number) void
+updateMin(value string) void
+updateTrim(value string) void
+updateMax(value string) void
+updateParamWithConstraints(value string, param Parameter, min number, max number, property string) void
+onTouchStart(event TouchEvent) void
+onTouchMove(event TouchEvent) void
+onTouchEnd() void
}
class ServoFunctionGpioEditor {
+Parameter param
}
class ServoFunctionActuatorEditor {
+Parameter param
}
class InlineParameterEditor {
+boolean autoSet
+string label
+Parameter param
}
class Parameter {
+string name
+number value
+object paramType
}
class AutopilotStore {
+number system_id
+parameter(name string) Parameter
}
class Mavlink2Rest {
+setParam(name string, value number, systemId number, paramType any) void
}
ServoFunctionEditorDialog --> Parameter : uses
ServoFunctionEditorDialog ..> ServoFunctionRangeEditor : selects
ServoFunctionEditorDialog ..> ServoFunctionMotorEditor : selects
ServoFunctionEditorDialog ..> ServoFunctionGpioEditor : selects
ServoFunctionEditorDialog ..> ServoFunctionActuatorEditor : selects
ServoFunctionRangeEditor *-- InlineParameterEditor : embeds
ServoFunctionMotorEditor *-- InlineParameterEditor : embeds
ServoFunctionRangeEditor ..> Parameter : reads_writes
ServoFunctionMotorEditor ..> Parameter : reads_writes
ServoFunctionRangeEditor ..> AutopilotStore : getParamByType
ServoFunctionMotorEditor ..> AutopilotStore : getParamByType
ServoFunctionRangeEditor ..> Mavlink2Rest : setParam
ServoFunctionMotorEditor ..> Mavlink2Rest : setParam
AutopilotStore <.. ServoFunctionRangeEditor
AutopilotStore <.. ServoFunctionMotorEditor
Mavlink2Rest <.. ServoFunctionRangeEditor
Mavlink2Rest <.. ServoFunctionMotorEditor
Flow diagram for selecting specialized servo function widgetflowchart TD
A[Start with selected servo function param] --> B[Read param.value]
B --> C[Lookup selected option name in param.options]
C --> D{Lowercased name contains substring?}
D -->|contains 'motor'| E[Return ServoFunctionMotorEditor]
D -->|contains 'gpio'| F[Return ServoFunctionGpioEditor]
D -->|contains 'actuator'| G[Return ServoFunctionActuatorEditor]
D -->|contains 'disabled'| H[Return undefined and render no widget]
D -->|none of the above| I[Return ServoFunctionRangeEditor]
E --> J[Dynamic component renders motor editor]
F --> J
G --> J
H --> K[No specialized widget shown]
I --> J
J --> L[User edits PWM via selected widget]
K --> L
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
43a2e67 to
12798b7
Compare
12798b7 to
19f2852
Compare
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.
adds custom widgets/optiosn for:
regular servo
motors
actuators
lights
gpio
relays
fix #3267 ?
Summary by Sourcery
Introduce specialized editors for different servo function types in the parameter editor dialog to support motor- and GPIO-specific PWM configuration while keeping a generic range editor for other functions.
Enhancements: