Class FanHelper

java.lang.Object
com.opensourcewithslu.outputdevices.FanHelper

public class FanHelper extends Object
Helper class to control a fan using PWM (Pulse Width Modulation).
  • Constructor Summary

    Constructors
    Constructor
    Description
    FanHelper(com.pi4j.io.pwm.Pwm fan)
    Constructor to initialize the FanHelper with a PWM instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    setSpeed(int speed)
    Sets the fan speed by adjusting the PWM duty cycle.
    void
    Starts the fan at full speed (1024 duty cycle) for 10 seconds, then stops it.
    void
    Stops the fan by turning off the PWM (0% duty cycle).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FanHelper

      public FanHelper(com.pi4j.io.pwm.Pwm fan)
      Constructor to initialize the FanHelper with a PWM instance.
      Parameters:
      fan - the PWM instance to control the fan
  • Method Details

    • start

      public void start()
      Starts the fan at full speed (1024 duty cycle) for 10 seconds, then stops it.
    • stop

      public void stop()
      Stops the fan by turning off the PWM (0% duty cycle).
    • setSpeed

      public void setSpeed(int speed)
      Sets the fan speed by adjusting the PWM duty cycle.
      Parameters:
      speed - the desired fan speed (duty cycle). Must be between 0 and 1024.
      Throws:
      IllegalArgumentException - if the speed is out of bounds