dummy_encoders
This commit is contained in:
@@ -33,7 +33,6 @@ constexpr uint8_t nrOfButtons = sizeof(button) / sizeof(button[0]);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (ENC_BTNL!=255 && ENC_BTNR!=255) || (ENC2_BTNL!=255 && ENC2_BTNR!=255)
|
#if (ENC_BTNL!=255 && ENC_BTNR!=255) || (ENC2_BTNL!=255 && ENC2_BTNR!=255)
|
||||||
#include "../yoEncoder/yoEncoder.h"
|
|
||||||
#if (ENC_BTNL!=255 && ENC_BTNR!=255)
|
#if (ENC_BTNL!=255 && ENC_BTNR!=255)
|
||||||
yoEncoder encoder = yoEncoder(ENC_BTNL, ENC_BTNR, ENCODER_STEPS, ENC_INTERNALPULLUP);
|
yoEncoder encoder = yoEncoder(ENC_BTNL, ENC_BTNR, ENCODER_STEPS, ENC_INTERNALPULLUP);
|
||||||
#endif
|
#endif
|
||||||
@@ -131,7 +130,7 @@ void loopControls() {
|
|||||||
if(display.mode()==LOST || display.mode()==UPDATING) return;
|
if(display.mode()==LOST || display.mode()==UPDATING) return;
|
||||||
if (ctrls_on_loop) ctrls_on_loop();
|
if (ctrls_on_loop) ctrls_on_loop();
|
||||||
#if ENC_BTNL!=255
|
#if ENC_BTNL!=255
|
||||||
encoderLoop();
|
encoder1Loop();
|
||||||
#endif
|
#endif
|
||||||
#if ENC2_BTNL!=255
|
#if ENC2_BTNL!=255
|
||||||
encoder2Loop();
|
encoder2Loop();
|
||||||
@@ -154,32 +153,46 @@ void loopControls() {
|
|||||||
touchscreen.loop();
|
touchscreen.loop();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#if ENC_BTNL!=255 || ENC2_BTNL!=255
|
||||||
#if ENC_BTNL!=255
|
void encodersLoop(yoEncoder *enc, bool first){
|
||||||
void encoderLoop() {
|
int8_t encoderDelta = enc->encoderChanged();
|
||||||
int8_t encoderDelta = encoder.encoderChanged();
|
|
||||||
if (encoderDelta!=0)
|
if (encoderDelta!=0)
|
||||||
{
|
{
|
||||||
|
uint8_t encBtnState = digitalRead(first?ENC_BTNB:ENC2_BTNB);
|
||||||
|
# if defined(DUMMYDISPLAY) && !defined(USE_NEXTION)
|
||||||
|
first = first?(first && encBtnState):(!encBtnState);
|
||||||
|
if(first){
|
||||||
|
int nv = config.store.volume+encoderDelta;
|
||||||
|
if(nv<0) nv=0;
|
||||||
|
if(nv>254) nv=254;
|
||||||
|
player.setVol((byte)nv, false);
|
||||||
|
}else{
|
||||||
|
if(encoderDelta > 0) player.next(); else player.prev();
|
||||||
|
}
|
||||||
|
# else
|
||||||
|
if(first){
|
||||||
controlsEvent(encoderDelta > 0, encoderDelta);
|
controlsEvent(encoderDelta > 0, encoderDelta);
|
||||||
}
|
}else{
|
||||||
}
|
if (encBtnState == HIGH && display.mode() == PLAYER) {
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENC2_BTNL!=255
|
|
||||||
void encoder2Loop() {
|
|
||||||
int8_t encoderDelta = encoder2.encoderChanged();
|
|
||||||
if (encoderDelta!=0)
|
|
||||||
{
|
|
||||||
uint8_t bp = 2;
|
|
||||||
if (ENC2_BTNB != 255) {
|
|
||||||
bp = digitalRead(ENC2_BTNB);
|
|
||||||
}
|
|
||||||
if (bp == HIGH && display.mode() == PLAYER) {
|
|
||||||
display.putRequest(NEWMODE, STATIONS);
|
display.putRequest(NEWMODE, STATIONS);
|
||||||
while(display.mode() != STATIONS) {delay(10);}
|
while(display.mode() != STATIONS) {delay(10);}
|
||||||
}
|
}
|
||||||
controlsEvent(encoderDelta > 0, encoderDelta);
|
controlsEvent(encoderDelta > 0, encoderDelta);
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ENC_BTNL!=255
|
||||||
|
void encoder1Loop() {
|
||||||
|
encodersLoop(&encoder, true);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ENC2_BTNL!=255
|
||||||
|
void encoder2Loop() {
|
||||||
|
encodersLoop(&encoder2, false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -334,10 +347,16 @@ void onBtnLongPressStart(int id) {
|
|||||||
}
|
}
|
||||||
case EVT_BTNCENTER:
|
case EVT_BTNCENTER:
|
||||||
case EVT_ENCBTNB: {
|
case EVT_ENCBTNB: {
|
||||||
|
# if defined(DUMMYDISPLAY) && !defined(USE_NEXTION)
|
||||||
|
break;
|
||||||
|
# endif
|
||||||
display.putRequest(NEWMODE, display.mode() == PLAYER ? STATIONS : PLAYER);
|
display.putRequest(NEWMODE, display.mode() == PLAYER ? STATIONS : PLAYER);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EVT_ENC2BTNB: {
|
case EVT_ENC2BTNB: {
|
||||||
|
# if defined(DUMMYDISPLAY) && !defined(USE_NEXTION)
|
||||||
|
break;
|
||||||
|
# endif
|
||||||
display.putRequest(NEWMODE, display.mode() == PLAYER ? VOL : PLAYER);
|
display.putRequest(NEWMODE, display.mode() == PLAYER ? VOL : PLAYER);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
#define controls_h
|
#define controls_h
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
|
#if (ENC_BTNL!=255 && ENC_BTNR!=255) || (ENC2_BTNL!=255 && ENC2_BTNR!=255)
|
||||||
|
#include "../yoEncoder/yoEncoder.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
enum controlEvt_e { EVT_BTNLEFT, EVT_BTNCENTER, EVT_BTNRIGHT, EVT_ENCBTNB, EVT_BTNUP, EVT_BTNDOWN, EVT_ENC2BTNB };
|
enum controlEvt_e { EVT_BTNLEFT, EVT_BTNCENTER, EVT_BTNRIGHT, EVT_ENCBTNB, EVT_BTNUP, EVT_BTNDOWN, EVT_ENC2BTNB };
|
||||||
|
|
||||||
//enum tsDirection_e { TSD_STAY, TSD_LEFT, TSD_RIGHT, TSD_UP, TSD_DOWN, TDS_REQUEST };
|
//enum tsDirection_e { TSD_STAY, TSD_LEFT, TSD_RIGHT, TSD_UP, TSD_DOWN, TDS_REQUEST };
|
||||||
@@ -14,7 +18,8 @@ boolean checklpdelay(int m, unsigned long &tstamp);
|
|||||||
|
|
||||||
void initControls();
|
void initControls();
|
||||||
void loopControls();
|
void loopControls();
|
||||||
void encoderLoop();
|
void encodersLoop(yoEncoder *enc, bool first=true);
|
||||||
|
void encoder1Loop();
|
||||||
void encoder2Loop();
|
void encoder2Loop();
|
||||||
void irLoop();
|
void irLoop();
|
||||||
//void touchLoop();
|
//void touchLoop();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef options_h
|
#ifndef options_h
|
||||||
#define options_h
|
#define options_h
|
||||||
|
|
||||||
#define VERSION "0.8.121"
|
#define VERSION "0.8.129"
|
||||||
|
|
||||||
/*******************************************************
|
/*******************************************************
|
||||||
DO NOT EDIT THIS FILE.
|
DO NOT EDIT THIS FILE.
|
||||||
|
|||||||
Reference in New Issue
Block a user