LEGO Technic Move hub - add servo/stepper support#223
Conversation
Agent-Logs-Url: https://github.com/vicocz/brickcontroller2/sessions/391dbddf-e12f-4d5f-bf17-72fec9d7ff6b Co-authored-by: vicocz <11756608+vicocz@users.noreply.github.com>
…com/vicocz/brickcontroller2 into local/tehnice-move-hub-improvements
There was a problem hiding this comment.
Pull request overview
Adds non-PLAYVM servo support (and introduces stepper handling) for the LEGO Technic Move Hub’s C channel by switching to absolute-position commands when the channel is configured as a servo/stepper.
Changes:
- Allow C channel to be configured as a servo in both PLAYVM and non-PLAYVM modes, and as a stepper in non-PLAYVM mode.
- Configure port position reporting for stepper channels during connect setup.
- Add dedicated output send paths for servo (
GotoAbsPosition) and stepper (relative target based on current position) on channel C.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // stepper for normal mode but C channel only | ||
| ChannelOutputType.StepperMotor => !EnablePlayVmMode && channel == CHANNEL_C, | ||
|
|
||
| // other types (such as stepper) are not supported at all |
There was a problem hiding this comment.
Confirmed — the comment on line 69 now reads "other types are not supported at all" without any mention of stepper, so it correctly matches the current behavior where StepperMotor is handled explicitly above it.
| _outputValues.Initialize(); | ||
| } | ||
| _calibratedZeroAngle = default; | ||
| _calibratedZeroAngles.AsSpan().Clear(); |
There was a problem hiding this comment.
Not fixed — line 209 still clears _calibratedZeroAngles. The flow is: AfterConnectSetupAsync (line 64 in BluetoothDevice.cs) populates calibration → StartOutputTaskAsync (line 68) → ProcessOutputsAsync → ResetOutputValues (line 89 in WirelessProtocolBasedDevice.cs) clears it at line 209 before first command. The calibration is lost before it can be used.
| // stepper channels accumulate the input value as a step coefficient | ||
| _ when channel >= CHANNEL_A && channel <= CHANNEL_C && GetOutputType(channel) == ChannelOutputType.StepperMotor | ||
| => _outputValues.AccumulateOutput(channel, (Half)validatedValue), |
| /// Accumulates the value into the channel's current output. | ||
| /// Non-zero values are added; zero values are ignored (input released). | ||
| /// </summary> | ||
| public bool AccumulateOutput(int channel, TValue value) |
No description provided.