fixed random
This commit is contained in:
@ -20,7 +20,7 @@
|
||||
#define ANALOGUE_INPUT_1_PIN A2
|
||||
#define ANALOGUE_INPUT_2_PIN A1
|
||||
|
||||
const int outsPins[6] = {6, 11, 7, 10, 8, 9}; //{6, 9, 7, 10, 11, 8}
|
||||
const int outsPins[6] = {6, 11, 7, 10, 8, 9};
|
||||
|
||||
const int clockModes[18] = {-24, -16, -12, -8, -6, -4, -3, -2, 1, 2, 3, 4, 5, 6, 7, 8, 16, 32}; //positive - divide, negative - multiply, 0 - off
|
||||
|
||||
@ -45,8 +45,6 @@ channel channels[6] = { //array of channel settings
|
||||
int outsClocksCounts[6];
|
||||
int playingModes[6]; //actual channel modes array updated from channels each beat
|
||||
|
||||
bool externalClockConnected;
|
||||
bool externalClockConnectedOld;
|
||||
int clockCount = 0;
|
||||
|
||||
int pulseClockCount = 0;
|
||||
@ -76,7 +74,7 @@ RotaryEncoder encoder(ENC_D1_PIN, ENC_D2_PIN, RotaryEncoder::LatchMode::TWO03);
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
//check last bit of eeprom to know if settings were stored
|
||||
//check last bit in eeprom to know if settings were stored
|
||||
if (EEPROM.read(1023) == 'H') {
|
||||
EEPROM.get(0, bpm);
|
||||
EEPROM.get(sizeof(int), channels);
|
||||
@ -85,12 +83,11 @@ void setup() {
|
||||
EEPROM.write(1023, 'H');
|
||||
}
|
||||
|
||||
|
||||
pinMode(ENC_BTN_PIN, INPUT_PULLUP);
|
||||
pinMode(START_STOP_BTN_PIN, INPUT_PULLUP);
|
||||
pinMode(START_STOP_BTN_PIN, ANALOGUE_INPUT_1_PIN);
|
||||
pinMode(INPUT_PIN, INPUT_PULLUP); //probably will need interrupt
|
||||
//attachInterrupt(digitalPinToInterrupt(INPUT_PIN), externalClock, RISING);
|
||||
attachInterrupt(digitalPinToInterrupt(INPUT_PIN), externalClock, RISING);
|
||||
|
||||
for (int i=0; i<6; i++) {
|
||||
pinMode(outsPins[i], OUTPUT);
|
||||
@ -133,7 +130,7 @@ void internalClock() {
|
||||
playingModes[i] = clockModes[channels[i].mode]; //updated here to prevent sync problems for multipliers
|
||||
if (playingModes[i] > 0) {
|
||||
if (outsClocksCounts[i] == 0) { //Pulse on 0
|
||||
if (channels[i].random == 0 || random(channels[i].random) == 0) { //random
|
||||
if (channels[i].random == 0 || random(10) > channels[i].random) {
|
||||
digitalWrite(outsPins[i], HIGH);
|
||||
}
|
||||
}
|
||||
@ -151,7 +148,7 @@ void internalClock() {
|
||||
for (int i = 0; i<6; i++) {
|
||||
if (playingModes[i] < 0) {
|
||||
if (outsClocksCounts[i] == 0) { //Pulse on 0
|
||||
if (channels[i].random == 0 || (channels[i].random == 1 && random(2))) { //random
|
||||
if (channels[i].random == 0 || random(10) > channels[i].random) { //random
|
||||
digitalWrite(outsPins[i], HIGH);
|
||||
}
|
||||
}
|
||||
@ -190,9 +187,9 @@ void internalClock() {
|
||||
}
|
||||
}
|
||||
|
||||
//void externalClock() {
|
||||
// digitalWrite(outsPins[0], !digitalRead(outsPins[0]));
|
||||
//}
|
||||
void externalClock() {
|
||||
digitalWrite(outsPins[0], !digitalRead(outsPins[0]));
|
||||
}
|
||||
|
||||
void updateTiming() {
|
||||
pulsePeriod = 60000 / (bpm * PPQN);
|
||||
@ -219,7 +216,6 @@ void checkInputs() {
|
||||
} else if (digitalRead(ENC_BTN_PIN) && encPressRegistered) {
|
||||
encPressRegistered = false;
|
||||
encReleasedTime = millis();
|
||||
//Serial.println(encReleasedTime - encPressedTime);
|
||||
|
||||
if (encReleasedTime - encPressedTime < 500) { // press shorter than .5s switches tabs
|
||||
if (insideTab == 0) {
|
||||
@ -294,7 +290,6 @@ void checkInputs() {
|
||||
//modulations
|
||||
a1Input = analogRead(ANALOGUE_INPUT_1_PIN);
|
||||
a2Input = analogRead(ANALOGUE_INPUT_2_PIN);
|
||||
|
||||
}
|
||||
|
||||
void updateScreen() {
|
||||
|
||||
Reference in New Issue
Block a user