17 #include <SimpleRotary.h>
39 Encoder() : encoder_(ENCODER_PIN1, ENCODER_PIN2, ENCODER_SW_PIN) {}
44 reversed_ = direction == 1;
56 switch (encoder_.rotate()) {
58 return DIRECTION_INCREMENT;
60 return DIRECTION_DECREMENT;
62 return DIRECTION_UNCHANGED;
67 switch (encoder_.rotate()) {
69 return DIRECTION_DECREMENT;
71 return DIRECTION_INCREMENT;
73 return DIRECTION_UNCHANGED;
91 return Pressed() == PRESS_SHORT;
100 SimpleRotary encoder_;
101 static const int LONG_PRESS_DURATION_MS = 1000;
108 return encoder_.pushType(LONG_PRESS_DURATION_MS);
Arduino pin definitions for the Modulove A-RYTH-MATIC module.
Direction Rotate()
Get the rotary direction if it has turned.
Definition: encoder.h:49
PressType Pressed()
Definition: encoder.h:78
PressType
Enum for type of switch press.
Definition: encoder.h:33
bool ShortPressed()
Definition: encoder.h:90
Direction
Enum constants for encoder rotation increment/decrement state.
Definition: encoder.h:26
bool LongPressed()
Definition: encoder.h:95
void setDirection(byte direction)
Set the encoder direction by passing 0 for cw increment or 1 for ccw increment.
Definition: encoder.h:43