Some changes in navigation (not yet finished)
This commit is contained in:
@ -86,8 +86,9 @@ bool needPulseReset[6] = { true, true, true, true, true, true };
|
||||
|
||||
unsigned int displayTab = 0;
|
||||
unsigned int displayTabOld;
|
||||
unsigned int insideTab = 0;
|
||||
bool insideTab = false;
|
||||
bool playBtnPushed = false;
|
||||
bool shiftBtnPushed = false;
|
||||
|
||||
int a1Input = 0;
|
||||
int a2Input = 0;
|
||||
@ -141,7 +142,8 @@ void setup() {
|
||||
|
||||
pinMode(ENC_BTN_PIN, INPUT_PULLUP);
|
||||
pinMode(START_STOP_BTN_PIN, INPUT_PULLUP);
|
||||
pinMode(START_STOP_BTN_PIN, ANALOGUE_INPUT_1_PIN);
|
||||
// pinMode(START_STOP_BTN_PIN, ANALOGUE_INPUT_1_PIN); // no idea where this came from
|
||||
pinMode(SHIFT_BTN_PIN, INPUT_PULLUP);
|
||||
pinMode(EXT_INPUT_PIN, INPUT_PULLUP);
|
||||
attachInterrupt(digitalPinToInterrupt(EXT_INPUT_PIN), externalClock, FALLING);
|
||||
|
||||
@ -154,7 +156,6 @@ void setup() {
|
||||
display.clearDisplay();
|
||||
|
||||
//Splash screen
|
||||
//displayLogo();
|
||||
display.drawBitmap(48, 0, splash_logo, 33, 39, 1);
|
||||
|
||||
display.setCursor(0, 56);
|
||||
@ -399,140 +400,4 @@ void saveState() {
|
||||
EEPROM.put(addr, masterClockMode);
|
||||
addr = addr + sizeof(masterClockMode);
|
||||
EEPROM.put(addr, channels);
|
||||
}
|
||||
|
||||
void checkInputs() {
|
||||
|
||||
//encoder button
|
||||
if (!digitalRead(ENC_BTN_PIN) && !encPressRegistered) {
|
||||
encPressRegistered = true;
|
||||
encPressedTime = millis();
|
||||
} else if (digitalRead(ENC_BTN_PIN) && encPressRegistered) {
|
||||
encPressRegistered = false;
|
||||
encReleasedTime = millis();
|
||||
|
||||
if (encReleasedTime - encPressedTime < 500) { // press shorter than .5s switches tabs
|
||||
if (insideTab == 0) {
|
||||
displayTabOld = displayTab;
|
||||
displayTab++;
|
||||
if (displayTab > 6) {
|
||||
displayTab = 0;
|
||||
}
|
||||
} else if (insideTab < 3 && displayTab != 0) {
|
||||
insideTab++;
|
||||
} else if (insideTab < 2 && displayTab == 0) {
|
||||
insideTab++;
|
||||
} else {
|
||||
insideTab = 1;
|
||||
}
|
||||
updateScreen();
|
||||
} else if (encReleasedTime - encPressedTime < 2000) { // longer press (<2s) and switches random mode, longer than 2s presses are ignored
|
||||
if (insideTab == 0) {
|
||||
insideTab = 1;
|
||||
} else {
|
||||
insideTab = 0;
|
||||
}
|
||||
updateScreen();
|
||||
}
|
||||
}
|
||||
|
||||
//encoder
|
||||
encoder.tick();
|
||||
int encPosition = encoder.getPosition();
|
||||
if (encPositionOld != encPosition) {
|
||||
int change = encPositionOld - encPosition;
|
||||
if (displayTab == 0 && insideTab == 0 && masterClockMode == 0) {
|
||||
bpm = bpm + change;
|
||||
if (bpm > MAXBPM) {
|
||||
bpm = MAXBPM;
|
||||
} else if (bpm < MINBPM) {
|
||||
bpm = MINBPM;
|
||||
}
|
||||
calculateBPMTiming();
|
||||
|
||||
} else if (displayTab == 0 && insideTab == 1) { //Clock mode
|
||||
masterClockMode = masterClockMode + change;
|
||||
if (masterClockMode > 250) {
|
||||
masterClockMode = 0;
|
||||
} else if (masterClockMode > 3) {
|
||||
masterClockMode = 3;
|
||||
}
|
||||
|
||||
} else if (displayTab == 0 && insideTab == 2 && masterClockMode == 0) { //bpm modulation
|
||||
bpmModulationRange = bpmModulationRange + change;
|
||||
if (bpmModulationRange == 255 && bpmModulationChannel == 0) {
|
||||
bpmModulationRange = 0;
|
||||
} else if (bpmModulationRange == 255 && bpmModulationChannel == 1) {
|
||||
bpmModulationRange = 9;
|
||||
bpmModulationChannel = 0;
|
||||
} else if (bpmModulationRange > 9 && bpmModulationChannel == 0) {
|
||||
bpmModulationRange = 0;
|
||||
bpmModulationChannel = 1;
|
||||
} else if (bpmModulationRange > 9 && bpmModulationChannel == 1) {
|
||||
bpmModulationRange = 9;
|
||||
}
|
||||
|
||||
} else if (displayTab != 0 && insideTab == 0) { //subdivision
|
||||
channels[displayTab - 1].mode = channels[displayTab - 1].mode - change;
|
||||
if (channels[displayTab - 1].mode == 65535) { //65535 is 0-1 for unsigned vars
|
||||
channels[displayTab - 1].mode = 0;
|
||||
} else if (channels[displayTab - 1].mode > (sizeof(clockModes) / sizeof(int)) - 1) {
|
||||
channels[displayTab - 1].mode = (sizeof(clockModes) / sizeof(int)) - 1;
|
||||
}
|
||||
if (!isPlaying) {
|
||||
calculateCycles();
|
||||
}
|
||||
|
||||
} else if (displayTab != 0 && insideTab == 1) { //random
|
||||
channels[displayTab - 1].random = channels[displayTab - 1].random + change;
|
||||
if (channels[displayTab - 1].random == 65535) {
|
||||
channels[displayTab - 1].random = 0;
|
||||
} else if (channels[displayTab - 1].random > 9) {
|
||||
channels[displayTab - 1].random = 9;
|
||||
}
|
||||
|
||||
} else if (displayTab != 0 && insideTab == 2) { //modulation
|
||||
channels[displayTab - 1].modulationRange = channels[displayTab - 1].modulationRange + change;
|
||||
if (channels[displayTab - 1].modulationRange < 0 && channels[displayTab - 1].modulationChannel == 0) {
|
||||
channels[displayTab - 1].modulationRange = 0;
|
||||
} else if (channels[displayTab - 1].modulationRange > 6 && channels[displayTab - 1].modulationChannel == 0) {
|
||||
channels[displayTab - 1].modulationChannel = 1;
|
||||
channels[displayTab - 1].modulationRange = 0;
|
||||
} else if (channels[displayTab - 1].modulationRange < 0 && channels[displayTab - 1].modulationChannel == 1) {
|
||||
channels[displayTab - 1].modulationChannel = 0;
|
||||
channels[displayTab - 1].modulationRange = 6;
|
||||
} else if (channels[displayTab - 1].modulationRange > 6 && channels[displayTab - 1].modulationChannel == 1) {
|
||||
channels[displayTab - 1].modulationRange = 6;
|
||||
}
|
||||
|
||||
} else if (displayTab != 0 && insideTab == 3) { //offset
|
||||
channels[displayTab - 1].offset = channels[displayTab - 1].offset + change;
|
||||
if (channels[displayTab - 1].offset == 65535) {
|
||||
channels[displayTab - 1].offset = 0;
|
||||
} else if (channels[displayTab - 1].offset >= channelPulsesPerCycle[displayTab - 1]) {
|
||||
channels[displayTab - 1].offset = channelPulsesPerCycle[displayTab - 1];
|
||||
}
|
||||
}
|
||||
updateScreen();
|
||||
encPositionOld = encPosition;
|
||||
}
|
||||
|
||||
//play button
|
||||
if (!digitalRead(START_STOP_BTN_PIN) && !playBtnPushed) {
|
||||
if (masterClockMode == 0) {
|
||||
calculateBPMTiming();
|
||||
resetClocks();
|
||||
isPlaying = !isPlaying;
|
||||
}
|
||||
playBtnPushed = true;
|
||||
saveState();
|
||||
updateScreen(); //to wake up the screen if turned off
|
||||
} else if (digitalRead(START_STOP_BTN_PIN) && playBtnPushed) {
|
||||
playBtnPushed = false;
|
||||
}
|
||||
|
||||
//modulations
|
||||
a1Input = analogRead(ANALOGUE_INPUT_1_PIN);
|
||||
a2Input = analogRead(ANALOGUE_INPUT_2_PIN);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user