8
8
class EncButton : public VirtEncButton {
9
9
public:
10
10
// настроить пины (энк, энк, кнопка, pinmode энк, pinmode кнопка)
11
- EncButton (uint8_t encA = 0 , uint8_t encB = 0 , uint8_t btn = 0 , uint8_t modeEnc = INPUT, uint8_t modeBtn = INPUT_PULLUP) {
12
- init (encA, encB, btn, modeEnc, modeBtn);
13
- setButtonLevel (LOW);
11
+ EncButton (uint8_t encA = 0 , uint8_t encB = 0 , uint8_t btn = 0 , uint8_t modeEnc = INPUT, uint8_t modeBtn = INPUT_PULLUP, uint8_t btnLevel = LOW) {
12
+ init (encA, encB, btn, modeEnc, modeBtn, btnLevel);
14
13
}
15
14
16
15
// настроить пины (энк, энк, кнопка, pinmode энк, pinmode кнопка)
17
- void init (uint8_t encA = 0 , uint8_t encB = 0 , uint8_t btn = 0 , uint8_t modeEnc = INPUT, uint8_t modeBtn = INPUT_PULLUP) {
16
+ void init (uint8_t encA = 0 , uint8_t encB = 0 , uint8_t btn = 0 , uint8_t modeEnc = INPUT, uint8_t modeBtn = INPUT_PULLUP, uint8_t btnLevel = LOW ) {
18
17
e0 = encA;
19
18
e1 = encB;
20
19
b = btn;
21
20
pinMode (e0 , modeEnc);
22
21
pinMode (e1 , modeEnc);
23
22
pinMode (b, modeBtn);
23
+ setBtnLevel (btnLevel);
24
24
initEnc (readEnc ());
25
25
}
26
26
@@ -32,7 +32,8 @@ class EncButton : public VirtEncButton {
32
32
33
33
// функция обработки, вызывать в loop
34
34
int8_t tick () {
35
- return VirtEncButton::tick (readEnc (), EBread (b));
35
+ if (read_ef (EB_EISR)) return VirtEncButton::tick (EBread (b));
36
+ else return VirtEncButton::tick (readEnc (), EBread (b));
36
37
}
37
38
38
39
// ====================== READ ======================
@@ -56,16 +57,16 @@ template <uint8_t ENCA, uint8_t ENCB, uint8_t BTN>
56
57
class EncButtonT : public VirtEncButton {
57
58
public:
58
59
// настроить пины (энк, энк, кнопка, pinmode энк, pinmode кнопка)
59
- EncButtonT (uint8_t modeEnc = INPUT, uint8_t modeBtn = INPUT_PULLUP) {
60
- init (modeEnc, modeBtn);
61
- setButtonLevel (LOW);
60
+ EncButtonT (uint8_t modeEnc = INPUT, uint8_t modeBtn = INPUT_PULLUP, uint8_t btnLevel = LOW) {
61
+ init (modeEnc, modeBtn, btnLevel);
62
62
}
63
63
64
64
// настроить пины (pinmode энк, pinmode кнопка)
65
- void init (uint8_t modeEnc = INPUT, uint8_t modeBtn = INPUT_PULLUP) {
65
+ void init (uint8_t modeEnc = INPUT, uint8_t modeBtn = INPUT_PULLUP, uint8_t btnLevel = LOW ) {
66
66
pinMode (ENCA, modeEnc);
67
67
pinMode (ENCB, modeEnc);
68
68
pinMode (BTN, modeBtn);
69
+ setBtnLevel (btnLevel);
69
70
initEnc (readEnc ());
70
71
}
71
72
@@ -77,7 +78,8 @@ class EncButtonT : public VirtEncButton {
77
78
78
79
// функция обработки, вызывать в loop
79
80
int8_t tick () {
80
- return VirtEncButton::tick (readEnc (), EBread (BTN));
81
+ if (read_ef (EB_EISR)) return VirtEncButton::tick (EBread (BTN));
82
+ else return VirtEncButton::tick (readEnc (), EBread (BTN));
81
83
}
82
84
83
85
// ====================== READ ======================
0 commit comments