I figured I needed to clean up the original source before trying to fit it into the FreeRTOS environment ...
Otto::_execute:
Removed unnecessary braces and simplified the if condition.
Renamed the variable cycles to completeCycles for clarity.
Removed the check cycles >= 1 because the loop will not execute if cycles is less than 1.
Combined the execution of complete cycles and the final incomplete cycle into one loop.
Used static_cast for converting steps to an integer for complete cycles to make the type conversion clearer.
Calculated remainingSteps outside of the if condition for better readability.
Simplified the condition for executing the final incomplete cycle to check if remainingSteps is greater than 0.
Otto::oscillateServos:
Combined the initialization of x and ref into a single declaration double ref = millis();.
Changed the termination condition of the outer loop to currentTime <= endTime for clarity and to avoid recalculating T * cycle + ref in each iteration.
Used currentTime = millis() inside the loop declaration for updating the current time.
Adjusted indentation and spacing for readability.
Otto::_moveSingle:
Combined the checks for position being out of range into a single if condition.
Removed unnecessary variable servoNumber.
Simplified the condition for checking if the servo_number is valid.
Used >= and < in the condition to ensure that only valid servo_number values are processed.
Adjusted indentation and spacing for readability.
Otto::_moveServos:
Moved common initialization code outside of conditional blocks.
Removed unnecessary variable declarations and assignments.
Adjusted loop structures for better readability.
Used static_cast for the increment calculation to ensure floating-point division.
Updated comments for clarity.
flag variable f has been renamed to servoPositionsMatch, which makes its purpose clearer: it indicates whether the current servo positions match their target positions.
I figured I needed to clean up the original source before trying to fit it into the FreeRTOS environment ...
Otto::_execute:
Otto::oscillateServos:
Otto::_moveSingle:
Otto::_moveServos:
much much more to come ...