blob: bbfbf30a78393b668af4981e319665920f1b8f7c (
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
33
34
35
36
|
#ifndef __RotaryEncoderIncluded
#define __RotaryEncoderIncluded
#include "RepRapFirmware.h"
#if SUPPORT_12864_LCD
// 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
#endif
|