Added CV and Gate outputs via 2x i2c MCP4725 modules
This commit is contained in:
62
CV.ino
Normal file
62
CV.ino
Normal file
@ -0,0 +1,62 @@
|
||||
float noteToVoltage(uint8_t note) {
|
||||
float voltage = (note - 24) * 0.083;
|
||||
return voltage;
|
||||
}
|
||||
|
||||
void sendCVNote(uint8_t note, uint8_t track) {
|
||||
if (track == 0 && note != CV1Note) {
|
||||
CV1Note = note;
|
||||
updateCV1 = true;
|
||||
}
|
||||
if (track == 1 && note != CV2Note) {
|
||||
CV2Note = note;
|
||||
updateCV2 = true;
|
||||
}
|
||||
}
|
||||
|
||||
void sendGateOn(uint8_t track) {
|
||||
if (track == 0) {
|
||||
sendGate1 = true;
|
||||
}
|
||||
if (track == 1) {
|
||||
sendGate2 = true;
|
||||
}
|
||||
}
|
||||
|
||||
void sendGateOff(uint8_t track) {
|
||||
if (track == 0) {
|
||||
sendGate1 = false;
|
||||
}
|
||||
if (track == 1) {
|
||||
sendGate2 = false;
|
||||
}
|
||||
}
|
||||
|
||||
void sendVoltage(uint8_t voltage, uint8_t dac) {
|
||||
if (dac == 0) {
|
||||
DAC1.setVoltage(voltage);
|
||||
} else {
|
||||
DAC2.setVoltage(voltage);
|
||||
}
|
||||
}
|
||||
|
||||
void processCV() {
|
||||
if (updateCV1) {
|
||||
sendVoltage(noteToVoltage(CV1Note), 0);
|
||||
updateCV1 = false;
|
||||
}
|
||||
if (updateCV2) {
|
||||
//sendVoltage(noteToVoltage(CV2Note), 1);
|
||||
//updateCV2 = false;
|
||||
}
|
||||
if (sendGate1) {
|
||||
sendVoltage(5, 1);
|
||||
} else {
|
||||
sendVoltage(0, 1);
|
||||
}
|
||||
if (sendGate2) {
|
||||
//sendVoltage(5, 1);
|
||||
} else {
|
||||
//sendVoltage(0, 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user