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