blob: 097ff1191062f178e0941c99958285808db4b0e7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#ifndef __RotaryEncoderIncluded
#define __RotaryEncoderIncluded
#include "RepRapFirmware.h"
// Class to manage a rotary encoder with a push button
class RotaryEncoder
{
const Pin pin0, pin1, pinButton;
int ppc;
int encoderChange;
unsigned int encoderState;
bool buttonState;
bool newPress;
bool reverseDirection;
uint32_t whenSame;
unsigned int ReadEncoderState() const;
static constexpr uint32_t DebounceMillis = 5;
public:
RotaryEncoder(Pin p0, Pin p1, Pin pb);
void Init(int pulsesPerClick);
void Poll();
int GetChange();
bool GetButtonPress();
int GetPulsesPerClick() const { return ppc; }
};
#endif
|