@Test public void setAngleRange_throwsIfMinLargerThanMax() throws IOException { Servo servo = new Servo(mPwm); mExpectedException.expect(IllegalArgumentException.class); mExpectedException.expectMessage(equalTo("minAngle must be less than maxAngle")); servo.setAngleRange(1, -1); }
public void setAngleRange(double minAngle, double maxAngle) throws IOException { if (minAngle >= maxAngle) { throw new IllegalArgumentException("minAngle must be less than maxAngle"); } mMinAngle = minAngle; mMaxAngle = maxAngle; if (mAngle < mMinAngle) { mAngle = mMinAngle; updateDutyCycle(); } else if (mAngle > mMaxAngle) { mAngle = mMaxAngle; updateDutyCycle(); } }
Servo implements AutoCloseable { public void setAngleRange(double minAngle, double maxAngle) throws IOException { if (minAngle >= maxAngle) { throw new IllegalArgumentException("minAngle must be less than maxAngle"); } mMinAngle = minAngle; mMaxAngle = maxAngle; if (mAngle < mMinAngle) { mAngle = mMinAngle; updateDutyCycle(); } else if (mAngle > mMaxAngle) { mAngle = mMaxAngle; updateDutyCycle(); } } }
Servo implements AutoCloseable { public void setAngleRange(double minAngle, double maxAngle) throws IOException { if (minAngle >= maxAngle) { throw new IllegalArgumentException("minAngle must be less than maxAngle"); } mMinAngle = minAngle; mMaxAngle = maxAngle; if (mAngle < mMinAngle) { mAngle = mMinAngle; updateDutyCycle(); } else if (mAngle > mMaxAngle) { mAngle = mMaxAngle; updateDutyCycle(); } } Servo(String pin);  Servo(String pin, double frequencyHz); @VisibleForTesting  Servo(Pwm device); @VisibleForTesting  Servo(Pwm device, double frequencyHz); }
Servo implements AutoCloseable { public void setAngleRange(double minAngle, double maxAngle) throws IOException { if (minAngle >= maxAngle) { throw new IllegalArgumentException("minAngle must be less than maxAngle"); } mMinAngle = minAngle; mMaxAngle = maxAngle; if (mAngle < mMinAngle) { mAngle = mMinAngle; updateDutyCycle(); } else if (mAngle > mMaxAngle) { mAngle = mMaxAngle; updateDutyCycle(); } } Servo(String pin);  Servo(String pin, double frequencyHz); @VisibleForTesting  Servo(Pwm device); @VisibleForTesting  Servo(Pwm device, double frequencyHz); @Override void close(); void setEnabled(boolean enabled); void setPulseDurationRange(double minMs, double maxMs); double getMinimumPulseDuration(); double getMaximumPulseDuration(); void setAngleRange(double minAngle, double maxAngle); double getMinimumAngle(); double getMaximumAngle(); void setAngle(double angle); double getAngle(); }
Servo implements AutoCloseable { public void setAngleRange(double minAngle, double maxAngle) throws IOException { if (minAngle >= maxAngle) { throw new IllegalArgumentException("minAngle must be less than maxAngle"); } mMinAngle = minAngle; mMaxAngle = maxAngle; if (mAngle < mMinAngle) { mAngle = mMinAngle; updateDutyCycle(); } else if (mAngle > mMaxAngle) { mAngle = mMaxAngle; updateDutyCycle(); } } Servo(String pin);  Servo(String pin, double frequencyHz); @VisibleForTesting  Servo(Pwm device); @VisibleForTesting  Servo(Pwm device, double frequencyHz); @Override void close(); void setEnabled(boolean enabled); void setPulseDurationRange(double minMs, double maxMs); double getMinimumPulseDuration(); double getMaximumPulseDuration(); void setAngleRange(double minAngle, double maxAngle); double getMinimumAngle(); double getMaximumAngle(); void setAngle(double angle); double getAngle(); static final double DEFAULT_FREQUENCY_HZ; }