mirror of
https://github.com/erik-toth/audio-synth.git
synced 2025-12-06 08:00:02 +00:00
Software Update 3: Example 2 CV-Gates
This commit is contained in:
@@ -216,7 +216,7 @@ void CV::setVoltage(uint8_t cvIndex, Key k)
|
|||||||
{
|
{
|
||||||
if(cvIndex >= _nCV) return;
|
if(cvIndex >= _nCV) return;
|
||||||
if(isNotKey(k)) setVoltage(cvIndex, 0);
|
if(isNotKey(k)) setVoltage(cvIndex, 0);
|
||||||
setVoltage(cvIndex, _keyToVoltage[_getKeyToVoltageIndex(k)]);
|
else setVoltage(cvIndex, _keyToVoltage[_getKeyToVoltageIndex(k)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CV::clearAll()
|
void CV::clearAll()
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
/*
|
||||||
|
* Example Code Two
|
||||||
|
*/
|
||||||
#include "FIRMWARE_DEF.h"
|
#include "FIRMWARE_DEF.h"
|
||||||
#include "FIRMWARE.h"
|
#include "FIRMWARE.h"
|
||||||
|
|
||||||
@@ -33,10 +36,20 @@ void loop()
|
|||||||
if(n > 0)
|
if(n > 0)
|
||||||
{
|
{
|
||||||
Serial.printf("\n\rCurrent queue length: %i", n);
|
Serial.printf("\n\rCurrent queue length: %i", n);
|
||||||
|
if(n == 1)
|
||||||
|
{
|
||||||
|
cv.setVoltage(0, keyboard.getQueue(0));
|
||||||
|
cv.setVoltage(1, NOT_A_KEY);
|
||||||
|
}
|
||||||
|
else if(n >= 2)
|
||||||
|
{
|
||||||
|
cv.setVoltage(0, keyboard.getQueue(0));
|
||||||
|
cv.setVoltage(1, keyboard.getQueue(1));
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; (i < N_CV_GATES) && (i < n); i++)
|
for(int i = 0; (i < N_CV_GATES) && (i < n); i++)
|
||||||
{
|
{
|
||||||
Key k = keyboard.getQueue(i);
|
Key k = keyboard.getQueue(i);
|
||||||
cv.setVoltage(i, k);
|
|
||||||
if(isNotKey(k)) Serial.printf("\n\rQueue position %i: NOT A KEY", i);
|
if(isNotKey(k)) Serial.printf("\n\rQueue position %i: NOT A KEY", i);
|
||||||
else Serial.printf("\n\rQueue position %i: R%iC%i", i, k.row, k.col);
|
else Serial.printf("\n\rQueue position %i: R%iC%i", i, k.row, k.col);
|
||||||
}
|
}
|
||||||
|
|||||||
50
dev/digital/Firmware_TEST/src/main.cpp.1
Normal file
50
dev/digital/Firmware_TEST/src/main.cpp.1
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Example Code One
|
||||||
|
*/
|
||||||
|
#include "FIRMWARE_DEF.h"
|
||||||
|
#include "FIRMWARE.h"
|
||||||
|
|
||||||
|
static byte pins_keyboard_row[N_KEYBOARD_ROW] = {PIN_K_R0, PIN_K_R1, PIN_K_R2, PIN_K_R3};
|
||||||
|
static byte pins_keyboard_col[N_KEYBOARD_COL] = {PIN_K_C0, PIN_K_C1, PIN_K_C2};
|
||||||
|
|
||||||
|
Keyboard keyboard(N_KEYBOARD_ROW, N_KEYBOARD_COL, pins_keyboard_row, pins_keyboard_col);
|
||||||
|
|
||||||
|
Adafruit_MCP4728 MCP4728;
|
||||||
|
MCP4728_channel_t cvMap[N_CV_GATES] = {MCP4728_CHANNEL_A, MCP4728_CHANNEL_B};
|
||||||
|
uint16_t keyToVoltage[N_KEYBOARD_ROW*N_KEYBOARD_COL] = {
|
||||||
|
1*83, 5*83, 9*83,
|
||||||
|
2*83, 6*83, 10*83,
|
||||||
|
3*83, 7*83, 11*83,
|
||||||
|
4*83, 8*83, 12*83
|
||||||
|
};
|
||||||
|
|
||||||
|
CV cv(&MCP4728, &Wire, N_CV_GATES, cvMap, keyToVoltage, N_KEYBOARD_ROW, N_KEYBOARD_COL);
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
Serial.begin(BAUDRATE);
|
||||||
|
keyboard.begin();
|
||||||
|
cv.begin(PIN_SDA, PIN_SCL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
keyboard.update();
|
||||||
|
|
||||||
|
int n = keyboard.getQueueLength();
|
||||||
|
|
||||||
|
if(n > 0)
|
||||||
|
{
|
||||||
|
Serial.printf("\n\rCurrent queue length: %i", n);
|
||||||
|
for(int i = 0; (i < N_CV_GATES) && (i < n); i++)
|
||||||
|
{
|
||||||
|
Key k = keyboard.getQueue(i);
|
||||||
|
cv.setVoltage(i, k);
|
||||||
|
if(isNotKey(k)) Serial.printf("\n\rQueue position %i: NOT A KEY", i);
|
||||||
|
else Serial.printf("\n\rQueue position %i: R%iC%i", i, k.row, k.col);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else cv.clearAll();
|
||||||
|
|
||||||
|
delay(50);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user