Review of servo/motor functions #124
Draft
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.
Description
I've gone over the servo and DC motor functions that were added to SplashKit recently, per the related planner card.
Changes:
brake_motor
function, to activate the braking mode on a motor module.stop_motor
now allows the motor to coast to a stop.set_motor_speed
would function incorrectly if the user changed the PWM range withraspi_set_pwm_range
(the speed function assumed a default range of 255).set_motor_speed
now scales to the PWM range returned by pigpio for the enable pin.open_servo
now sets amin_angle
andmax_angle
variables for a given servo_device. This defaults to 0 and 180, as in the original code, but now allows a user to specify a range of motion for the servo.set_servo_angle
is no longer clamped to a 0..180 degree range and works with an arbitrary angle range.set_servo_value
maps an input range of 0..1 to the PWM range. This is useful when a user doesn't know the angle range of a servo, which makes the angle setting function unintuitive. This is handy because many servo datasheets don't specify their range of motion and a user may not want to measure it themselves in the case that it doesn't match the default 180 degrees.Notes:
_motor_data
has amotor_driver_type
variable which doesn't seem to be used anywhere. I've left this for now since I'm unsure about what to do with it. I'm assuming it's to implement functions specific to certain motor modules.Type of change
expected)
How Has This Been Tested?
This still needs to be tested with a variety of hardware modules. I'll try to get my hands on a couple of motor modules and servos soon.
Testing Checklist
Checklist