88class EncButton : public VirtEncButton {
99 public:
1010 // настроить пины (энк, энк, кнопка, 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);
1413 }
1514
1615 // настроить пины (энк, энк, кнопка, 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 ) {
1817 e0 = encA;
1918 e1 = encB;
2019 b = btn;
2120 pinMode (e0 , modeEnc);
2221 pinMode (e1 , modeEnc);
2322 pinMode (b, modeBtn);
23+ setBtnLevel (btnLevel);
2424 initEnc (readEnc ());
2525 }
2626
@@ -32,7 +32,8 @@ class EncButton : public VirtEncButton {
3232
3333 // функция обработки, вызывать в loop
3434 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));
3637 }
3738
3839 // ====================== READ ======================
@@ -56,16 +57,16 @@ template <uint8_t ENCA, uint8_t ENCB, uint8_t BTN>
5657class EncButtonT : public VirtEncButton {
5758 public:
5859 // настроить пины (энк, энк, кнопка, 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);
6262 }
6363
6464 // настроить пины (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 ) {
6666 pinMode (ENCA, modeEnc);
6767 pinMode (ENCB, modeEnc);
6868 pinMode (BTN, modeBtn);
69+ setBtnLevel (btnLevel);
6970 initEnc (readEnc ());
7071 }
7172
@@ -77,7 +78,8 @@ class EncButtonT : public VirtEncButton {
7778
7879 // функция обработки, вызывать в loop
7980 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));
8183 }
8284
8385 // ====================== READ ======================
0 commit comments