mirror of
https://git.alemi.dev/cv-keyboard.git
synced 2024-11-23 17:04:49 +01:00
Various fixes that didn't fix much
This commit is contained in:
parent
b7ddcb2a97
commit
35950fd11b
1 changed files with 23 additions and 10 deletions
|
@ -33,6 +33,8 @@ int SEND[3] = { // Pins used as sender for capacitive touch buttons
|
||||||
5, 4, 16 };
|
5, 4, 16 };
|
||||||
int RECEIVE[3] = { // Pins used as receiver for capacitive touch buttons
|
int RECEIVE[3] = { // Pins used as receiver for capacitive touch buttons
|
||||||
6, 3, 17 };
|
6, 3, 17 };
|
||||||
|
int LEDS[4] = { // Pins used for leds
|
||||||
|
21, 20, 19, 18 };
|
||||||
int OW = 2; // Pin used for overwrite switch
|
int OW = 2; // Pin used for overwrite switch
|
||||||
int DEL = -1; // Pin used for delete button
|
int DEL = -1; // Pin used for delete button
|
||||||
int ADD = 14; // Pin used for add button
|
int ADD = 14; // Pin used for add button
|
||||||
|
@ -65,12 +67,9 @@ CapacitiveSensor* bCap[MAXDPAD];
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
for (int cOCTAVE = 0; cOCTAVE < 4; cOCTAVE++) {
|
for (int cOCTAVE = 0; cOCTAVE < 4; cOCTAVE++) pinMode(OCTAVE[cOCTAVE], OUTPUT);
|
||||||
pinMode(OCTAVE[cOCTAVE], OUTPUT);
|
for (int cNOTE = 0; cNOTE < 12; cNOTE++) pinMode(NOTE[cNOTE], INPUT);
|
||||||
}
|
for (int cLED = 0; cLED < 4; cLED++) pinMode(LEDS[cLED], OUTPUT);
|
||||||
for (int cNOTE = 0; cNOTE < 12; cNOTE++) {
|
|
||||||
pinMode(NOTE[cNOTE], INPUT);
|
|
||||||
}
|
|
||||||
for (int cButton = 0; cButton < MAXDPAD; cButton++) { // Capacitive Buttons configuration
|
for (int cButton = 0; cButton < MAXDPAD; cButton++) { // Capacitive Buttons configuration
|
||||||
bCap[cButton] = new CapacitiveSensor(SEND[cButton], RECEIVE[cButton]); // Initialized
|
bCap[cButton] = new CapacitiveSensor(SEND[cButton], RECEIVE[cButton]); // Initialized
|
||||||
bCap[cButton]->set_CS_AutocaL_Millis(0xFFFFFFFF); // No recalibration
|
bCap[cButton]->set_CS_AutocaL_Millis(0xFFFFFFFF); // No recalibration
|
||||||
|
@ -89,6 +88,10 @@ void setup() {
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
sync();
|
sync();
|
||||||
|
if (current == head) nstep = 0;
|
||||||
|
else nstep++;
|
||||||
|
display(nstep);
|
||||||
|
|
||||||
if (sem_beat > 0) {
|
if (sem_beat > 0) {
|
||||||
sem_beat--;
|
sem_beat--;
|
||||||
if (sem_gate > 0) { // If step was shorter than gate, close all open notes before next step
|
if (sem_gate > 0) { // If step was shorter than gate, close all open notes before next step
|
||||||
|
@ -96,8 +99,8 @@ void loop() {
|
||||||
for (int i = 0; i < MAXKEYS; i++) if (current->kboard_s[i]) playNOTE(i, !current->kboard_s[i]);
|
for (int i = 0; i < MAXKEYS; i++) if (current->kboard_s[i]) playNOTE(i, !current->kboard_s[i]);
|
||||||
for (int i = 0; i < MAXDPAD; i++) if (current->dpad_s[i]) playDrum(i, !current->dpad_s[i]);
|
for (int i = 0; i < MAXDPAD; i++) if (current->dpad_s[i]) playDrum(i, !current->dpad_s[i]);
|
||||||
}
|
}
|
||||||
if (digitalRead(ADD) && digitalRead(OW)) insertStep();
|
if (digitalRead(ADD)) insertStep();
|
||||||
if (digitalRead(ADD) && !digitalRead(OW)) deleteStep(); // Placeholder because I miss a button
|
//if (digitalRead(ADD) && !digitalRead(OW)) deleteStep(); // Placeholder because I miss a button
|
||||||
nextStep();
|
nextStep();
|
||||||
if (current != NULL) { // Play all step notes and begin counting for gate
|
if (current != NULL) { // Play all step notes and begin counting for gate
|
||||||
for (int i = 0; i < MAXKEYS; i++) if (current->kboard_s[i]) playNOTE(i, current->kboard_s[i]);
|
for (int i = 0; i < MAXKEYS; i++) if (current->kboard_s[i]) playNOTE(i, current->kboard_s[i]);
|
||||||
|
@ -144,6 +147,13 @@ octst scan(int nOct) { // This function reads the 12 NOTE pins and retu
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void display(int number){
|
||||||
|
for(int i = 0; i < 4; i++) {
|
||||||
|
digitalWrite(LEDS[i], number & 1);
|
||||||
|
number >> 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool evalButton(CapacitiveSensor* b, bool value, int note_number) {
|
bool evalButton(CapacitiveSensor* b, bool value, int note_number) {
|
||||||
long sensor = b->capacitiveSensor(1);
|
long sensor = b->capacitiveSensor(1);
|
||||||
|
|
||||||
|
@ -203,9 +213,12 @@ void playDrum(int c, bool status) {
|
||||||
|
|
||||||
void sync() {
|
void sync() {
|
||||||
if (Serial.available() && Serial.read() == MIDICLOCK) {
|
if (Serial.available() && Serial.read() == MIDICLOCK) {
|
||||||
|
//sem_beat++;
|
||||||
midiclock++;
|
midiclock++;
|
||||||
if (midiclock == 0 && sem_beat == 0) sem_beat++;
|
if (midiclock == 24){
|
||||||
else if (midiclock == 24) midiclock = 0;
|
midiclock = 0;
|
||||||
|
sem_beat++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue