added offset (still needs some work)
This commit is contained in:
@ -32,15 +32,16 @@ struct channel {
|
||||
unsigned int random;
|
||||
bool modulationChannel; //0 - A1, 1 - A2
|
||||
int modulationRange;
|
||||
unsigned int offset;
|
||||
};
|
||||
|
||||
channel channels[6] = { //array of channel settings
|
||||
{ 8, 0, 0, 0 },
|
||||
{ 8, 0, 0, 0 },
|
||||
{ 8, 0, 0, 0 },
|
||||
{ 8, 0, 0, 0 },
|
||||
{ 8, 0, 0, 0 },
|
||||
{ 8, 0, 0, 0 }
|
||||
{ 8, 0, 0, 0, 0 },
|
||||
{ 8, 0, 0, 0, 0 },
|
||||
{ 8, 0, 0, 0, 0 },
|
||||
{ 8, 0, 0, 0, 0 },
|
||||
{ 8, 0, 0, 0, 0 },
|
||||
{ 8, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
int channelPulseCount[6];
|
||||
@ -98,12 +99,12 @@ void setup() {
|
||||
//Serial.begin(9600);
|
||||
|
||||
//check last bit in eeprom to know if settings were stored
|
||||
if (EEPROM.read(1023) == 'H') {
|
||||
if (EEPROM.read(1023) == 'K') {
|
||||
EEPROM.get(0, bpm);
|
||||
EEPROM.get(sizeof(int), channels);
|
||||
} else {
|
||||
saveState();
|
||||
EEPROM.write(1023, 'H');
|
||||
EEPROM.write(1023, 'K');
|
||||
}
|
||||
|
||||
pinMode(ENC_BTN_PIN, INPUT_PULLUP);
|
||||
@ -116,6 +117,8 @@ void setup() {
|
||||
pinMode(outsPins[i], OUTPUT);
|
||||
}
|
||||
|
||||
calculateCycles();
|
||||
|
||||
display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
|
||||
|
||||
//Splash screen
|
||||
@ -198,7 +201,7 @@ void sendTriggers() {
|
||||
|
||||
//multiplier
|
||||
for (int i = 0; i<6; i++) {
|
||||
if (channelPulseCount[i] == 0) { //Pulse on 0
|
||||
if (channelPulseCount[i] == channels[i].offset) { //Pulse on 0
|
||||
if (channels[i].random == 0 || random(10) > channels[i].random) { //random
|
||||
digitalWrite(outsPins[i], HIGH);
|
||||
}
|
||||
@ -211,6 +214,16 @@ void sendTriggers() {
|
||||
}
|
||||
}
|
||||
|
||||
void calculateCycles() {
|
||||
for (int i = 0; i<6; i++) {
|
||||
if (playingModes[i] > 0) {
|
||||
channelPulsesPerCycle[i] = (playingModes[i] * PPQN) - 1;
|
||||
} else {
|
||||
channelPulsesPerCycle[i] = (PPQN / abs(playingModes[i])) - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void externalClock() {
|
||||
externalPulseCounted = false;
|
||||
}
|
||||
@ -220,7 +233,6 @@ void updateTiming() {
|
||||
pulsePeriod = 60000 / (bpm * PPQN);
|
||||
} else if (masterClockMode == 2) { //for external beat clock
|
||||
pulsePeriod = (newExtPulseTime - lastExtPulseTime) / PPQN;
|
||||
//Serial.println("pulsePeriod");
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,7 +265,7 @@ void checkInputs() {
|
||||
if (displayTab>6) {
|
||||
displayTab = 0;
|
||||
}
|
||||
} else if (insideTab < 2) {
|
||||
} else if (insideTab < 3) {
|
||||
insideTab ++;
|
||||
} else {
|
||||
insideTab = 1;
|
||||
@ -308,6 +320,13 @@ void checkInputs() {
|
||||
channels[displayTab-1].modulationChannel = !channels[displayTab-1].modulationChannel;
|
||||
channels[displayTab-1].modulationRange = 0;
|
||||
}
|
||||
} else if (displayTab != 0 && insideTab == 3) { //offset
|
||||
channels[displayTab-1].offset = channels[displayTab-1].offset + change;
|
||||
if (channels[displayTab-1].offset >= channelPulsesPerCycle[displayTab-1]) {
|
||||
channels[displayTab-1].offset = channelPulsesPerCycle[displayTab-1];
|
||||
} else if (channels[displayTab-1].offset <= 0 ) {
|
||||
channels[displayTab-1].offset = 0;
|
||||
}
|
||||
}
|
||||
updateScreen();
|
||||
encPositionOld = encPosition;
|
||||
@ -434,6 +453,15 @@ void updateScreen() {
|
||||
} else {
|
||||
display.print(F("Off "));
|
||||
}
|
||||
if (insideTab == 3) {
|
||||
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
|
||||
} else {
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
}
|
||||
display.setCursor(58,44);
|
||||
display.print(F(" OFT:"));
|
||||
display.print(channels[displayTab-1].offset);
|
||||
display.print(F(" "));
|
||||
}
|
||||
|
||||
display.display();
|
||||
|
||||
Reference in New Issue
Block a user