-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncoderMenuSwitch.h
More file actions
46 lines (36 loc) · 1.1 KB
/
Copy pathEncoderMenuSwitch.h
File metadata and controls
46 lines (36 loc) · 1.1 KB
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
37
38
39
40
41
42
43
44
45
46
#ifndef _ENCODERMENUSWITCH_H
#define _ENCODERMENUSWITCH_H
#include <Arduino.h>
class EncoderMenuSwitch
{
// Encoder variables
bool init = false;
uint8_t pinOutA;
uint8_t pinOutB;
uint8_t valuePinA = LOW;
uint8_t valuePinAcurrent = LOW;
// Switchbutton variables
bool btnFirstPress = false;
uint8_t btnPin;
unsigned long btnElapsedMs = 0;
public:
enum EncoderDirection {
ENCODER_UP,
ENCODER_DOWN
};
//----------------------------------------------
// Constructors
//----------------------------------------------
EncoderMenuSwitch();
//----------------------------------------------
// Methods
//----------------------------------------------
void Initialize(uint8_t pinA, uint8_t pinB, uint8_t pinSwt);
void Dispatch();
};
//----------------------------------------------
// Callbacks
//----------------------------------------------
extern void OnEncoderMoved(EncoderMenuSwitch::EncoderDirection dir) __attribute__ ((weak));
extern void OnEncoderClick() __attribute__ ((weak));
#endif