is no control

This commit is contained in:
e2002
2022-02-07 16:21:40 +03:00
parent 3af2632d5b
commit 7d3de5eb2a
3 changed files with 40 additions and 18 deletions

View File

@@ -9,40 +9,61 @@
long encOldPosition = 0;
#if ENC_BTNL!=255
ESP32Encoder encoder;
OneButton encbutton(ENC_BTNB, true);
#endif
#if BTN_LEFT!=255
OneButton btnleft(BTN_LEFT, true);
#endif
#if BTN_CENTER!=255
OneButton btncenter(BTN_CENTER, true);
#endif
#if BTN_RIGHT!=255
OneButton btnright(BTN_RIGHT, true);
#endif
void initControls() {
#if ENC_BTNL!=255
ESP32Encoder::useInternalWeakPullResistors = UP;
encoder.attachHalfQuad(ENC_BTNL, ENC_BTNR);
encbutton.attachClick(onEncClick);
encbutton.attachDoubleClick(onEncDoubleClick);
encbutton.attachLongPressStart(onEncLPStart);
#endif
#if BTN_LEFT!=255
btnleft.attachClick(onLeftClick);
btnleft.attachDoubleClick(onLeftDoubleClick);
#endif
#if BTN_CENTER!=255
btncenter.attachClick(onEncClick);
btncenter.attachDoubleClick(onEncDoubleClick);
btncenter.attachLongPressStart(onEncLPStart);
#endif
#if BTN_RIGHT!=255
btnright.attachClick(onRightClick);
btnright.attachDoubleClick(onRightDoubleClick);
#endif
}
void loopControls() {
#if ENC_BTNL!=255
encbutton.tick();
btnleft.tick();
btncenter.tick();
btnright.tick();
encoderLoop();
#endif
#if BTN_LEFT!=255
btnleft.tick();
#endif
#if BTN_CENTER!=255
btncenter.tick();
#endif
#if BTN_RIGHT!=255
btnright.tick();
#endif
yield();
}
#if ENC_BTNL!=255
void encoderLoop() {
long encNewPosition = encoder.getCount() / 2;
if (encNewPosition != 0 && encNewPosition != encOldPosition) {
@@ -51,6 +72,7 @@ void encoderLoop() {
controlsEvent(encNewPosition > 0);
}
}
#endif
void onEncClick() {
if (display.mode == PLAYER) {
@@ -62,6 +84,7 @@ void onEncClick() {
}
}
void onEncDoubleClick() {
display.swichMode(display.mode == PLAYER ? STATIONS : PLAYER);
}

View File

@@ -1,7 +1,7 @@
#ifndef options_h
#define options_h
#define VERSION "0.4.180"
#define VERSION "0.4.181"
/*
* TFT DISPLAY
@@ -26,22 +26,21 @@
/*
* I2S DAC
*/
#define I2S_DOUT 27 // DIN connection
#define I2S_DOUT 22 // DIN connection
#define I2S_BCLK 26 // BCLK Bit clock
#define I2S_LRC 25 // WSEL Left Right Clockz
#define I2S_LRC 25 // WSEL Left Right Clock
/*
* ENCODER
*/
#define ENC_BTNL 13
#define ENC_BTNB 12
#define ENC_BTNR 14
#define ENC_BTNL 255
#define ENC_BTNB 255
#define ENC_BTNR 255
/*
* BUTTONS
*/
#define BTN_LEFT 32
#define BTN_CENTER 31
#define BTN_RIGHT 33
#define BTN_LEFT 255
#define BTN_CENTER 255
#define BTN_RIGHT 255
/*
* ESP DEVBOARD
*/