11package com .opensourcewithslu .outputdevices ;
22
3+ import com .pi4j .io .exception .IOException ;
34import com .pi4j .io .pwm .Pwm ;
45import org .slf4j .Logger ;
56import org .slf4j .LoggerFactory ;
@@ -30,8 +31,10 @@ public ServoMotorHelper(Pwm servoMotor) {
3031 }
3132
3233 /**
33- * Enables the servo motor by setting an initial duty cycle and frequency.
34- * The servo motor remains disabled until this method is called.
34+ * Enables the servo motor by starting PWM output at 0% duty cycle and the
35+ * configured servo frequency.
36+ *
37+ * @throws IOException if the underlying PWM implementation cannot start the signal
3538 */
3639 public void enable () {
3740 log .info ("Enabling servo motor" );
@@ -40,7 +43,9 @@ public void enable() {
4043 }
4144
4245 /**
43- * Disables the servo motor, effectively stopping any ongoing PWM signal.
46+ * Disables the servo motor and stops PWM output.
47+ *
48+ * @throws IOException if the underlying PWM implementation cannot stop the signal
4449 */
4550 public void disable () {
4651 log .info ("Disabling servo motor" );
@@ -60,9 +65,14 @@ float map(float value) {
6065
6166 /**
6267 * Sets the servo motor to a specific angle.
63- * This method calculates the necessary pulse width and duty cycle to achieve the specified angle.
68+ * <p>
69+ * The angle must be between 0 and 180 degrees. Values outside that range
70+ * are ignored and logged. This method also waits briefly after updating the
71+ * PWM signal so the servo has time to move.
72+ * </p>
6473 *
6574 * @param angle the target angle for the servo motor, between 0 and 180 degrees.
75+ * @throws IOException if the underlying PWM implementation cannot update the signal
6676 */
6777 public void setAngle (int angle ) {
6878 if (!isEnabled ) {
@@ -90,7 +100,7 @@ public void setAngle(int angle) {
90100 }
91101
92102 /**
93- * Sets the logger for this ServoMotorHelper instance.
103+ * Sets the logger for this {@code ServoMotorHelper} instance.
94104 * This method is intended for internal testing purposes only.
95105 *
96106 * @param logger the logger to be used for logging messages.
0 commit comments