Rotary encoders
Available methods
Configuration
setPinMode(INPUT, PULL_UP)- The first parameter can be set toINPUT,INPUT_PULLUPorINPUT_PULLDOWN. If this method is not used, the default mode isINPUT_PULLUPand (if available) the internal pull-up resistor of the pin will be used. If the first parameter is set toINPUT, you will have to implement an external pull-down or pull-up resistor. You should then set the second parameter toPULL_DOWNorPULL_UP.setMultiplexer(&mux)- Sets the multiplexer that the rotary encoder subscribes to.setGroup(&group)- Register the rotary encoder to a group.
Core
process()- Polls the rotary encoder and handles all its functionality (used in the loop method).storePinStates(clkState, dtState)- Store pin states from an ISR or interrupt handler. Call this from a hardware interrupt (e.g.attachInterrupton the CLK pin) to feed the encoder a pair of pin readings without blocking the interrupt context. The next call toprocess()will consume the stored states and apply state-table decoding as normal.
Event handlers
setOnTurnLeft(handler)- Sets the onTurnLeft handler. Called when you turn left.setOnTurnRight(handler)- Sets the onTurnRight handler. Called when you turn right.
State
isTurningLeft()- Returns true if the encoder is currently turning left, false otherwise.isTurningRight()- Returns true if the encoder is currently turning right, false otherwise.isEnabled()- Checks if the rotary encoder is enabled.isDisabled()- Checks if the rotary encoder is disabled.isMuxed()- Checks if the rotary encoder is currently attached to a multiplexer.isGrouped()- Checks if the rotary encoder is currently added to a group.enable()- Enables the rotary encoder.disable()- Disables the rotary encoder.
Custom properties
setInteger("id", 0)- Define an integer. First parameter is the name, second is the value.setString("name", "Rotary Encoder")- Define a string. First parameter is the name, second is the value.setBoolean("active", true)- Define a boolean. First parameter is the name, second is the value.getInteger("id")- Get the value of an integer.getString("name")- Get the value of a string.getBoolean("active")- Get the value of a boolean.