-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenc.h
More file actions
41 lines (34 loc) · 723 Bytes
/
enc.h
File metadata and controls
41 lines (34 loc) · 723 Bytes
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
/*
* enc.h
*
* Created on: 29 dec. 2017
* Author: MisterCavespider
*/
#ifndef ENC_H_
#define ENC_H_
#include <Arduino.h>
#include <Encoder.h>
#include <stdint.h>
#define PRESSEDV(enc) enc.c.deltaread()
#define PRESSEDP(enc) enc->c.deltaread()
#define READV(enc) enc.r.read()
#define READP(enc) enc->r.read()
#define WRITEV(enc,v) enc.r.write(v)
#define WRITEP(enc,v) enc->r.write(v)
class EncoderButton {
public:
EncoderButton(uint8_t pin);
void read();
uint8_t currentread();
uint8_t lastread();
int8_t deltaread();
virtual ~EncoderButton();
private:
uint8_t pin;
uint8_t curr, last, delta;
};
typedef struct EncoderCapsule {
Encoder r;
EncoderButton c;
} EncoderCapsule;
#endif /* ENC_H_ */