Class PhotoResistorHelper

java.lang.Object
com.opensourcewithslu.inputdevices.PhotoResistorHelper

public class PhotoResistorHelper extends Object
The PhotoResistorHelper class is used to work with the functionalities of a Photo Resistor.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    boolean
    To check if it is Dark.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PhotoResistorHelper(com.pi4j.io.gpio.digital.DigitalInput sensorInput, com.pi4j.io.gpio.digital.DigitalOutput sensorOutput)
    TouchSwitchHelper constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addEventListener(com.pi4j.io.gpio.digital.DigitalStateChangeListener function)
    Adds an event listener to the Photo Resistor.
    int
    Returns the current value of the darknessValue variable.
    void
    Initializes the Photo Resistor and calls the updateDarkness function for every half second.
    void
    Removes the event listener from the Photo Resistor.
    void
    setDarknessThreshold(int darknessThreshold)
    To set a threshold for Photo Resistor.
    void
    To set the Photo Resistor output to low for each event.
    void
    Updates the darknessValue of the Photo Resistor.

    Methods inherited from class java.lang.Object

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

    • isDark

      public boolean isDark
      To check if it is Dark.
  • Constructor Details

    • PhotoResistorHelper

      public PhotoResistorHelper(com.pi4j.io.gpio.digital.DigitalInput sensorInput, com.pi4j.io.gpio.digital.DigitalOutput sensorOutput)
      TouchSwitchHelper constructor.
      Parameters:
      sensorInput - - A Pi4J DigitalInput object.
      sensorOutput - - A Pi4J DigitalOutput object.
  • Method Details

    • getDark

      public int getDark()
      Returns the current value of the darknessValue variable.
      Returns:
      The current value of darknessValue.
    • initialize

      public void initialize()
      Initializes the Photo Resistor and calls the updateDarkness function for every half second.
    • updateDark

      public void updateDark()
      Updates the darknessValue of the Photo Resistor.
    • setToLow

      public void setToLow()
      To set the Photo Resistor output to low for each event.
    • setDarknessThreshold

      public void setDarknessThreshold(int darknessThreshold)
      To set a threshold for Photo Resistor.
      Parameters:
      darknessThreshold - value is obtained from user.
    • addEventListener

      public void addEventListener(com.pi4j.io.gpio.digital.DigitalStateChangeListener function)
      Adds an event listener to the Photo Resistor.
      Parameters:
      function - A Pi4J DigitalStateChangeListener object.
    • removeEventListener

      public void removeEventListener()
      Removes the event listener from the Photo Resistor.