From f5f4ca9b932f18dfbd9f1df9983856b8a6d6c0a5 Mon Sep 17 00:00:00 2001 From: Oleksiy Date: Fri, 17 Mar 2023 01:56:34 +0200 Subject: [PATCH] fixed random --- software/GToE/GToE.ino | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/software/GToE/GToE.ino b/software/GToE/GToE.ino index 1d6b8ad..650f248 100644 --- a/software/GToE/GToE.ino +++ b/software/GToE/GToE.ino @@ -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() {