Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.opensourcewithslu.outputdevices;

import com.pi4j.io.exception.IOException;
Comment thread
leandrumartin marked this conversation as resolved.
Outdated
import com.pi4j.io.pwm.Pwm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -30,8 +31,10 @@ public ServoMotorHelper(Pwm servoMotor) {
}

/**
* Enables the servo motor by setting an initial duty cycle and frequency.
* The servo motor remains disabled until this method is called.
* Enables the servo motor by starting PWM output at 0% duty cycle and the
* configured servo frequency.
*
* @throws IOException if the underlying PWM implementation cannot start the signal
Comment thread
leandrumartin marked this conversation as resolved.
Outdated
*/
public void enable() {
log.info("Enabling servo motor");
Expand All @@ -40,7 +43,9 @@ public void enable() {
}

/**
* Disables the servo motor, effectively stopping any ongoing PWM signal.
* Disables the servo motor and stops PWM output.
*
* @throws IOException if the underlying PWM implementation cannot stop the signal
Comment thread
leandrumartin marked this conversation as resolved.
Outdated
*/
public void disable() {
log.info("Disabling servo motor");
Expand All @@ -60,9 +65,14 @@ float map(float value) {

/**
* Sets the servo motor to a specific angle.
* This method calculates the necessary pulse width and duty cycle to achieve the specified angle.
* <p>
* The angle must be between 0 and 180 degrees. Values outside that range
* are ignored and logged. This method also waits briefly after updating the
* PWM signal so the servo has time to move.
* </p>
*
* @param angle the target angle for the servo motor, between 0 and 180 degrees.
* @throws IOException if the underlying PWM implementation cannot update the signal
Comment thread
leandrumartin marked this conversation as resolved.
Outdated
*/
public void setAngle(int angle) {
if (!isEnabled) {
Expand Down Expand Up @@ -90,7 +100,7 @@ public void setAngle(int angle) {
}

/**
* Sets the logger for this ServoMotorHelper instance.
* Sets the logger for this {@code ServoMotorHelper} instance.
* This method is intended for internal testing purposes only.
*
* @param logger the logger to be used for logging messages.
Expand Down
Loading