Skip to content

Commit fac650d

Browse files
committed
(Untested) Removed altAdj
1 parent 94064f0 commit fac650d

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

sixtube_lm/sixtube_lm.ino

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,17 @@ const byte mainSel = A2; //main select button - must be equipped
4141
const byte mainAdjUp = A1; //main up/down buttons or rotary encoder - must be equipped
4242
const byte mainAdjDn = A0;
4343
const byte altSel = 0; //alt select button - if unequipped, set to 0
44-
const byte altAdjUp = 0; //A6; //alt up/down buttons or rotary encoder - if unequipped, set to 0
45-
const byte altAdjDn = 0; //A3;
4644

4745
// What type of adj controls are equipped?
4846
// 1 = momentary buttons. 2 = quadrature rotary encoder.
4947
const byte mainAdjType = 1;
50-
const byte altAdjType = 0; //if unquipped, set to 0
5148

5249
// In normal running mode, what do the controls do?
5350
// -1 = nothing/switch, -2 = cycle through functions, fn in fnsEnabled[] = go to that function
5451
// If using soft alarm/power switch per below, the control(s) set to -1 will do the switching.
5552
const char mainSelFn = -2;
5653
const char mainAdjFn = -1;
57-
// const byte altSelFn = -1;
58-
// const byte altAdjFn = -1;
54+
const byte altSelFn = -1;
5955

6056
//What are the signal pin(s) connected to?
6157
const char piezoPin = 10;
@@ -251,18 +247,16 @@ void initInputs(){
251247
pinMode(A7, INPUT); digitalWrite(A7, HIGH);
252248
//rotary encoder init
253249
if(mainAdjType==2) AdaEncoder mainRot = AdaEncoder('a',mainAdjUp,mainAdjDn);
254-
//if(altAdjType==2) AdaEncoder altRot = AdaEncoder('b',altAdjUp,altAdjDn);
255250
}
256251

257252
void checkInputs(){
258253
//TODO can all this if/else business be defined at load instead of evaluated every sample? OR is it compiled that way?
259254
//TODO potential issue: if user only means to rotate or push encoder but does both?
260255
//check button states
261256
checkBtn(mainSel); //main select
262-
if(mainAdjType==1) { checkBtn(mainAdjUp); checkBtn(mainAdjDn); } //main adjust buttons (if equipped)
257+
if(mainAdjType==1) { checkBtn(mainAdjUp); checkBtn(mainAdjDn); } //if mainAdj is buttons
258+
if(mainAdjType==2) checkRot(); //if mainAdj is rotary encoder
263259
if(altSel!=0) checkBtn(altSel); //alt select (if equipped)
264-
if(altAdjType==1) { checkBtn(altAdjUp); checkBtn(altAdjDn); } //alt adjust buttons (if equipped)
265-
if(mainAdjType==2 || altAdjType==2) checkRot(); //if main or alt rotary encoder is equipped, check for moves
266260
}
267261

268262
bool readInput(byte pin){
@@ -302,9 +296,8 @@ void btnStop(){
302296
}
303297

304298
void checkRot(){
305-
//Changes in rotary encoders. When rotation(s) occur, will call ctrlEvt to simulate btn presses.
299+
//Changes in rotary encoder. When rotation(s) occur, will call ctrlEvt to simulate btn presses.
306300
if(btnCur==0) {
307-
//TODO does this work with more than one encoder? maybe on separate loops?
308301
//https://github.com/GreyGnome/AdaEncoder/blob/master/Examples/MyEncoder/MyEncoder.ino
309302
AdaEncoder *thisEncoder=NULL;
310303
thisEncoder = AdaEncoder::genie();
@@ -315,7 +308,7 @@ void checkRot(){
315308
byte dir = (clicks<0?0:1);
316309
clicks = abs(clicks);
317310
for(byte i=0; i<clicks; i++){ //in case of more than one click
318-
ctrlEvt((thisEncoder->getID()=='a'?(dir?mainAdjUp:mainAdjDn):(dir?altAdjUp:altAdjDn)),1);
311+
ctrlEvt((dir?mainAdjUp:mainAdjDn),1);
319312
}
320313
inputLast2 = inputLast; inputLast = inputThis;
321314
}
@@ -331,7 +324,7 @@ void ctrlEvt(byte ctrl, byte evt){
331324
//evt: 1=press, 2=short hold, 3=long hold, 0=release.
332325
//We only handle press evts for adj ctrls, as that's the only evt encoders generate.
333326
//But we can handle short and long holds and releases for the sel ctrls (always buttons).
334-
//TODO needs alt handling
327+
//TODO needs altSel
335328

336329
//Before all else, is it a press to stop the signal? Silence it
337330
if(signalRemain>0 && evt==1){
@@ -558,8 +551,8 @@ void doSetHold(){
558551
//TODO integrate this with checkInputs?
559552
if(doSetHoldLast+250<millis()) {
560553
doSetHoldLast = millis();
561-
if(fnSetPg!=0 && ((mainAdjType==1 && (btnCur==mainAdjUp || btnCur==mainAdjDn)) || (altAdjType==1 && (btnCur==altAdjUp || btnCur==altAdjDn))) ){ //if we're setting, and this is an adj input for which the type is button
562-
bool dir = (btnCur==mainAdjUp || btnCur==altAdjUp ? 1 : 0);
554+
if(fnSetPg!=0 && (mainAdjType==1 && (btnCur==mainAdjUp || btnCur==mainAdjDn)) ){ //if we're setting, and this is an adj btn
555+
bool dir = (btnCur==mainAdjUp ? 1 : 0);
563556
//If short hold, or long hold but high velocity isn't supported, use low velocity (delta=1)
564557
if(btnCurHeld==2 || (btnCurHeld==3 && fnSetValVel==false)) doSet(dir?1:-1);
565558
//else if long hold, use high velocity (delta=10)

0 commit comments

Comments
 (0)