Class PhotoResistorHelper
java.lang.Object
com.opensourcewithslu.inputdevices.PhotoResistorHelper
The PhotoResistorHelper class is used to work with the functionalities of a Photo Resistor.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionPhotoResistorHelper
(com.pi4j.io.gpio.digital.DigitalInput sensorInput, com.pi4j.io.gpio.digital.DigitalOutput sensorOutput) TouchSwitchHelper constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEventListener
(com.pi4j.io.gpio.digital.DigitalStateChangeListener function) Adds an event listener to the Photo Resistor.int
getDark()
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
setToLow()
To set the Photo Resistor output to low for each event.void
Updates the darknessValue of the Photo Resistor.
-
Field Details
-
isDark
public boolean isDarkTo 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.
-