Class IncrementalRotaryEncoder

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class IncrementalRotaryEncoder
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Driver for GPIO based Incremental Rotary Encoder.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  IncrementalRotaryEncoder.RotaryListener
      Interface definition for Rotary Encoder rolling do clock wise (cw) and counter clock wise (ccw).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void registerSwitch​(com.google.android.things.pio.GpioCallback callback)
      Register Switch input Gpio callback.
      void startEncoder()
      Start listening for RotaryListener's cw and ccw work.
      void stopEncoder()
      Stop listening for RotaryListener's works.
      void unregisterSwitch()
      Unregister Gpio Callback for sw.
      • Methods inherited from class java.lang.Object

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

      • IncrementalRotaryEncoder

        public IncrementalRotaryEncoder​(java.lang.String dtName,
                                        java.lang.String swName,
                                        java.lang.String clkName,
                                        IncrementalRotaryEncoder.RotaryListener rotaryListener)
                                 throws java.io.IOException
        Create 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.IOException
        Register 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.IOException
        Start 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:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception