diff --git a/README.md b/README.md index d4b72a6..40881b1 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Three tact buttons or Encoder or all together | ------ | ------ | | GND | GND | | VIN | +5v | -| DOUT(DIN) | 27* | +| DOUT(DIN) | 22* | | BCLK | 26* | | LRC(WSEL) | 25* | diff --git a/yoRadio/controls.cpp b/yoRadio/controls.cpp index 174bc25..c9912e2 100644 --- a/yoRadio/controls.cpp +++ b/yoRadio/controls.cpp @@ -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); } diff --git a/yoRadio/options.h b/yoRadio/options.h index a8f7abc..78187a7 100644 --- a/yoRadio/options.h +++ b/yoRadio/options.h @@ -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 */