Added CV calibration
This commit is contained in:
@ -25,6 +25,9 @@
|
|||||||
#define ANALOGUE_INPUT_2_PIN A6
|
#define ANALOGUE_INPUT_2_PIN A6
|
||||||
const byte outsPins[6] = { 7, 8, 10, 6, 9, 11 };
|
const byte outsPins[6] = { 7, 8, 10, 6, 9, 11 };
|
||||||
|
|
||||||
|
int CV1Calibration;
|
||||||
|
int CV2Calibration;
|
||||||
|
|
||||||
const int subDivs[17] = { -24, -12, -8, -6, -4, -3, -2, 1, 2, 3, 4, 5, 6, 7, 8, 16, 32 }; //positive - divide, negative - multiply, 0 - off
|
const int subDivs[17] = { -24, -12, -8, -6, -4, -3, -2, 1, 2, 3, 4, 5, 6, 7, 8, 16, 32 }; //positive - divide, negative - multiply, 0 - off
|
||||||
|
|
||||||
byte bpm = 130;
|
byte bpm = 130;
|
||||||
@ -72,7 +75,7 @@ byte currentStep = 0;
|
|||||||
byte stepNumSelected = 0;
|
byte stepNumSelected = 0;
|
||||||
bool *patternToEdit;
|
bool *patternToEdit;
|
||||||
|
|
||||||
byte memCode = 'A'; //Change to different letter if you changed the data structure
|
byte memCode = 'a'; //Change to different letter if you changed the data structure
|
||||||
|
|
||||||
unsigned int channelPulseCount[6];
|
unsigned int channelPulseCount[6];
|
||||||
unsigned int channelPulsesPerCycle[6];
|
unsigned int channelPulsesPerCycle[6];
|
||||||
@ -119,6 +122,7 @@ bool encPressRegistered;
|
|||||||
U8G2_SSD1306_128X64_NONAME_2_HW_I2C u8g2(U8G2_R2, SCL, SDA, U8X8_PIN_NONE);
|
U8G2_SSD1306_128X64_NONAME_2_HW_I2C u8g2(U8G2_R2, SCL, SDA, U8X8_PIN_NONE);
|
||||||
RotaryEncoder encoder(ENC_D1_PIN, ENC_D2_PIN, RotaryEncoder::LatchMode::TWO03);
|
RotaryEncoder encoder(ENC_D1_PIN, ENC_D2_PIN, RotaryEncoder::LatchMode::TWO03);
|
||||||
|
|
||||||
|
//Font
|
||||||
const uint8_t velvetscreen[437] U8G2_FONT_SECTION("velvetscreen") =
|
const uint8_t velvetscreen[437] U8G2_FONT_SECTION("velvetscreen") =
|
||||||
"\64\0\2\2\3\3\2\3\4\5\5\0\0\5\0\5\0\0\221\0\0\1\230 \4\200\134%\11\255tT"
|
"\64\0\2\2\3\3\2\3\4\5\5\0\0\5\0\5\0\0\221\0\0\1\230 \4\200\134%\11\255tT"
|
||||||
"R\271RI(\6\252\334T\31)\7\252\134bJ\12+\7\233\345\322J\0,\5\221T\4-\5\213"
|
"R\271RI(\6\252\334T\31)\7\252\134bJ\12+\7\233\345\322J\0,\5\221T\4-\5\213"
|
||||||
@ -137,7 +141,17 @@ const uint8_t velvetscreen[437] U8G2_FONT_SECTION("velvetscreen") =
|
|||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
//Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
|
pinMode(ENC_BTN_PIN, INPUT_PULLUP);
|
||||||
|
pinMode(START_STOP_BTN_PIN, INPUT_PULLUP);
|
||||||
|
pinMode(SHIFT_BTN_PIN, INPUT_PULLUP);
|
||||||
|
pinMode(EXT_INPUT_PIN, INPUT_PULLUP);
|
||||||
|
attachInterrupt(digitalPinToInterrupt(EXT_INPUT_PIN), externalClock, FALLING);
|
||||||
|
|
||||||
|
for (byte i = 0; i < 6; i++) {
|
||||||
|
pinMode(outsPins[i], OUTPUT);
|
||||||
|
}
|
||||||
|
|
||||||
//check last bit in eeprom to know if the correct settings were stored
|
//check last bit in eeprom to know if the correct settings were stored
|
||||||
if (EEPROM.read(1023) == memCode) {
|
if (EEPROM.read(1023) == memCode) {
|
||||||
@ -183,20 +197,17 @@ void setup() {
|
|||||||
EEPROM.get(addr, seqB7);
|
EEPROM.get(addr, seqB7);
|
||||||
addr = addr + sizeof(seqB7);
|
addr = addr + sizeof(seqB7);
|
||||||
EEPROM.get(addr, seqB8);
|
EEPROM.get(addr, seqB8);
|
||||||
|
addr = addr + sizeof(seqB8);
|
||||||
|
EEPROM.get(addr, CV1Calibration);
|
||||||
|
addr = addr + sizeof(CV1Calibration);
|
||||||
|
EEPROM.get(addr, CV2Calibration);
|
||||||
} else {
|
} else {
|
||||||
|
//calibrateCVs();
|
||||||
saveState();
|
saveState();
|
||||||
EEPROM.write(1023, memCode);
|
EEPROM.write(1023, memCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
pinMode(ENC_BTN_PIN, INPUT_PULLUP);
|
//calibrateCVs(); //Just for the testing
|
||||||
pinMode(START_STOP_BTN_PIN, INPUT_PULLUP);
|
|
||||||
pinMode(SHIFT_BTN_PIN, INPUT_PULLUP);
|
|
||||||
pinMode(EXT_INPUT_PIN, INPUT_PULLUP);
|
|
||||||
attachInterrupt(digitalPinToInterrupt(EXT_INPUT_PIN), externalClock, FALLING);
|
|
||||||
|
|
||||||
for (byte i = 0; i < 6; i++) {
|
|
||||||
pinMode(outsPins[i], OUTPUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
u8g2.begin();
|
u8g2.begin();
|
||||||
|
|
||||||
@ -483,4 +494,13 @@ void saveState() {
|
|||||||
EEPROM.put(addr, seqB7);
|
EEPROM.put(addr, seqB7);
|
||||||
addr = addr + sizeof(seqB7);
|
addr = addr + sizeof(seqB7);
|
||||||
EEPROM.put(addr, seqB8);
|
EEPROM.put(addr, seqB8);
|
||||||
|
addr = addr + sizeof(seqB8);
|
||||||
|
EEPROM.put(addr, CV1Calibration);
|
||||||
|
addr = addr + sizeof(CV1Calibration);
|
||||||
|
EEPROM.put(addr, CV2Calibration);
|
||||||
|
}
|
||||||
|
|
||||||
|
void calibrateCVs() {
|
||||||
|
CV1Calibration = 255 - (analogRead(ANALOGUE_INPUT_1_PIN) / 2);
|
||||||
|
CV2Calibration = 255 - (analogRead(ANALOGUE_INPUT_2_PIN) / 2);
|
||||||
}
|
}
|
||||||
@ -269,7 +269,7 @@ void checkInputs() {
|
|||||||
updateScreen();
|
updateScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
//modulations
|
//modulations map(randMod, 0, 1023, -5, +5)
|
||||||
a1Input = analogRead(ANALOGUE_INPUT_1_PIN);
|
a1Input = map(analogRead(ANALOGUE_INPUT_1_PIN), 0 - CV1Calibration, 1023 - CV1Calibration, 0, 1023);
|
||||||
a2Input = analogRead(ANALOGUE_INPUT_2_PIN);
|
a2Input = map(analogRead(ANALOGUE_INPUT_2_PIN), 0 - CV2Calibration, 1023 - CV2Calibration, 0, 1023);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user