88 lines
1.8 KiB
C++
88 lines
1.8 KiB
C++
#include <OSCBundle.h>
|
||
|
||
// SERIAL
|
||
#ifdef BOARD_HAS_USB_SERIAL
|
||
#include <SLIPEncodedUSBSerial.h>
|
||
SLIPEncodedUSBSerial SLIPSerial( thisBoardsSerialUSB );
|
||
#else
|
||
#include <SLIPEncodedSerial.h>
|
||
SLIPEncodedSerial SLIPSerial(Serial); // Change to Serial1 or Serial2 etc. for boards with multiple serial ports that don’t have Serial
|
||
#endif
|
||
|
||
OSCBundle bundle;
|
||
|
||
byte knofi[] = {
|
||
2, // gor (clip)
|
||
3, // dol (clip)
|
||
4, // levo (track)
|
||
5, // desno (track)
|
||
6, // quantize
|
||
7, // duplicate
|
||
8, // delete
|
||
9, // play/pavza
|
||
10,// overdub on/off
|
||
11,// record arm on/off
|
||
12,// record 4 beats
|
||
13,// record 8 beats
|
||
14 // record on/off
|
||
};
|
||
byte KNOFI_LEN = 13;
|
||
// Za stanje vrednosti
|
||
byte knofi_prej[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||
|
||
// Kako dolgo pocakaj za dvoklik? (v milisekundah)
|
||
int dvoklik_interval = 250;
|
||
|
||
const char* kanali[16] = {
|
||
"/play",
|
||
"/overdub/launcher",
|
||
"/recarm", // rabi info o trenutno izbranem tracku
|
||
"",
|
||
"",
|
||
"",
|
||
"",
|
||
"",
|
||
"",
|
||
"/clip/create/4",
|
||
"/clip/create/8",
|
||
"/clip/record" // rabi info o trenutno izbranem clipu / tracku
|
||
};
|
||
|
||
|
||
byte knofi_dvoklik[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||
|
||
void setup() {
|
||
for(int i = 0; i < KNOFI_LEN; i++) {
|
||
pinMode(knofi[i], INPUT_PULLUP);
|
||
}
|
||
|
||
//Serial.begin(9600);
|
||
SLIPSerial.begin(115200);
|
||
}
|
||
|
||
byte vrednost;
|
||
|
||
void loop() {
|
||
//Serial.println("Keys pressed:");
|
||
for(int i = 0; i < KNOFI_LEN; i++) {
|
||
vrednost = !digitalRead(knofi[i]);
|
||
//Serial.print(vrednost);
|
||
//Serial.print(", ");
|
||
|
||
// Je gumb sveze vklopljen?
|
||
if (!knofi_prej[i] && vrednost) {
|
||
bundle.add(kanali[i]);
|
||
//Serial.println(kanali[i]);
|
||
}
|
||
|
||
knofi_prej[i] = vrednost;
|
||
}
|
||
//Serial.println("");
|
||
SLIPSerial.beginPacket();
|
||
bundle.send(SLIPSerial);
|
||
SLIPSerial.endPacket();
|
||
//Serial.println("");
|
||
|
||
bundle.empty();
|
||
}
|