kegel/kontroler/kontroler.ino

88 lines
1.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#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 dont 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();
}