public class RotaryEncoder extends Button
A rotary encoders is usually placed at the side which is perpendicular to the shaft. They act as sensors for detecting angle, speed, length, position, and acceleration in automation field.
Example datasheet: Rotary Encoder
Example of use: RotaryEncoderExample
digitalInput
gpio
Constructor and Description |
---|
RotaryEncoder(GPIOPin swPin,
GPIOPin dtPin,
GPIOPin clkPin)
Constructor for a new rotary encoder using specific GPIO pin for sw, dt and clk pins.
|
Modifier and Type | Method and Description |
---|---|
int |
getCounterValue()
Get the current value of the counter corresponding to the position of the shaft.
|
void |
getEncoderTurn()
Updates the value of the counter used for this rotary encoder.
|
getGpioPinDigitalInput, isPressed
getType
public RotaryEncoder(GPIOPin swPin, GPIOPin dtPin, GPIOPin clkPin)
swPin
- GPIO pin corresponding to the push button of the encoder.dtPin
- GPIO pin corresponding to the data signal from the encoder.clkPin
- GPIO pin corresponding to the clock from the encoder.public void getEncoderTurn()
The counter is used to represent the position of the shaft. If you turn to the right, the counter is incremeted by one for each tick. If you turn to the left, the counter is then decremented by one for each tick.
getCounterValue()
public int getCounterValue()