Class IncrementalRotaryEncoder
- java.lang.Object
-
- com.hardkernel.odroid.things.contrib.RotaryEncoder.IncrementalRotaryEncoder
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class IncrementalRotaryEncoder extends java.lang.Object implements java.lang.AutoCloseableDriver for GPIO based Incremental Rotary Encoder.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceIncrementalRotaryEncoder.RotaryListenerInterface definition for Rotary Encoder rolling do clock wise (cw) and counter clock wise (ccw).
-
Constructor Summary
Constructors Constructor Description IncrementalRotaryEncoder(java.lang.String dtName, java.lang.String swName, java.lang.String clkName, IncrementalRotaryEncoder.RotaryListener rotaryListener)Create a new Incremental Rotary Encoder with dt, sw and clk name for GPIOs and rotaryListener.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidregisterSwitch(com.google.android.things.pio.GpioCallback callback)Register Switch input Gpio callback.voidstartEncoder()Start listening for RotaryListener's cw and ccw work.voidstopEncoder()Stop listening for RotaryListener's works.voidunregisterSwitch()Unregister Gpio Callback for sw.
-
-
-
Constructor Detail
-
IncrementalRotaryEncoder
public IncrementalRotaryEncoder(java.lang.String dtName, java.lang.String swName, java.lang.String clkName, IncrementalRotaryEncoder.RotaryListener rotaryListener) throws java.io.IOExceptionCreate a new Incremental Rotary Encoder with dt, sw and clk name for GPIOs and rotaryListener.- Parameters:
dtName- GPIO pin for dt.swName- GPIO pin for sw. You can control callback with registerSwitch / unregisterSwitch.clkName- GPIO pin for sw.rotaryListener- method interface stuffs for cw / ccw.- Throws:
java.io.IOException- Exception about wrong GPIO pin name.
-
-
Method Detail
-
registerSwitch
public void registerSwitch(com.google.android.things.pio.GpioCallback callback) throws java.io.IOExceptionRegister Switch input Gpio callback.- Parameters:
callback- GPIO Callback for sw.- Throws:
java.io.IOException- it called from registering or already registered callback.
-
unregisterSwitch
public void unregisterSwitch()
Unregister Gpio Callback for sw.
-
startEncoder
public void startEncoder() throws java.io.IOExceptionStart listening for RotaryListener's cw and ccw work.- Throws:
java.io.IOException- Error about gpio getValue
-
stopEncoder
public void stopEncoder()
Stop listening for RotaryListener's works.
-
close
public void close() throws java.lang.Exception- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
java.lang.Exception
-
-