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);
|
||||
}
|
||||
|
||||
}
|
||||
172
software/GToE/InputsCheck.ino
Normal file
172
software/GToE/InputsCheck.ino
Normal file
@ -0,0 +1,172 @@
|
||||
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 (!insideTab && !shiftBtnPushed) { //Change tab
|
||||
displayTab = displayTab + change;
|
||||
if (displayTab > 100) { //to address "negative" numbers
|
||||
displayTab = 0;
|
||||
} else if (displayTab > 6) {
|
||||
displayTab = 6;
|
||||
}
|
||||
} else if (!insideTab && shiftBtnPushed && displayTab == 0 && masterClockMode == 0) { //Change BPM
|
||||
bpm = bpm + change;
|
||||
if (bpm > MAXBPM) {
|
||||
bpm = MAXBPM;
|
||||
} else if (bpm < MINBPM) {
|
||||
bpm = MINBPM;
|
||||
}
|
||||
calculateBPMTiming();
|
||||
} else if (!insideTab && shiftBtnPushed && displayTab != 0) { //Change Subdiv
|
||||
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();
|
||||
}
|
||||
}
|
||||
/* 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;
|
||||
}
|
||||
|
||||
//shift button
|
||||
if (!digitalRead(SHIFT_BTN_PIN) && !shiftBtnPushed) {
|
||||
shiftBtnPushed = true;
|
||||
display.fillRoundRect(120, 52, 8, 8, 3, SSD1306_WHITE);
|
||||
display.display();
|
||||
|
||||
} else if (digitalRead(SHIFT_BTN_PIN) && shiftBtnPushed) {
|
||||
shiftBtnPushed = false;
|
||||
display.fillRoundRect(120, 52, 8, 8, 3, SSD1306_BLACK);
|
||||
display.display();
|
||||
}
|
||||
|
||||
//modulations
|
||||
a1Input = analogRead(ANALOGUE_INPUT_1_PIN);
|
||||
a2Input = analogRead(ANALOGUE_INPUT_2_PIN);
|
||||
}
|
||||
@ -5,32 +5,40 @@ void updateScreen() {
|
||||
|
||||
//Tabs
|
||||
display.drawRect(0, 48, 128, 1, SSD1306_WHITE);
|
||||
display.setCursor(0, 50);
|
||||
display.setCursor(4, 52);
|
||||
display.setTextSize(1);
|
||||
|
||||
if (displayTab == 0) {
|
||||
//display.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
|
||||
display.fillRoundRect(0, 46, 24, 18, 3, SSD1306_WHITE);
|
||||
//display.print(F(" "));
|
||||
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
||||
display.print(F(" bpm "));
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
display.print(F("BPM"));
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
|
||||
display.print(F(" bpm"));
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
display.print(F("BPM"));
|
||||
}
|
||||
|
||||
for (int i = 1; i <= 6; i++) {
|
||||
if (displayTab == i) {
|
||||
display.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
|
||||
display.print(" ");
|
||||
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
||||
if (insideTab == false) {
|
||||
display.fillRoundRect(i*12 + 12, 46, 13, 18, 3, SSD1306_WHITE);
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
} else {
|
||||
display.drawRoundRect(i*12 + 12, 46, 13, 18, 3, SSD1306_WHITE);
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
}
|
||||
display.print(" ");
|
||||
display.print(i);
|
||||
display.print(" ");
|
||||
//display.print(" ");
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
display.print(" ");
|
||||
display.print(i);
|
||||
}
|
||||
}
|
||||
|
||||
display.drawRect(0, 46, 128, 2, SSD1306_BLACK);
|
||||
//display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
||||
//display.fillRect(108, 60, 20, 8, SSD1306_WHITE);
|
||||
//display.println();
|
||||
|
||||
Reference in New Issue
Block a user