Skip to content
Snippets Groups Projects
Commit 46105798 authored by Quentin Bolsee's avatar Quentin Bolsee
Browse files

better code

parent 12e415f1
Branches
No related tags found
No related merge requests found
......@@ -15,22 +15,20 @@
#define USE_MIDI
// MIDI
#ifdef USE_MIDI
#include <Arduino.h>
#include <Adafruit_TinyUSB.h>
#include <MIDI.h>
#endif
Adafruit_NeoPixel pixels(1, 12, NEO_GRB + NEO_KHZ800);
int colors[N_TX][3] = {{255, 26, 0}, {0, 255, 0}, {0, 16, 255}};
// MIDI
#ifdef USE_MIDI
Adafruit_USBD_MIDI usb_midi;
MIDI_CREATE_INSTANCE(Adafruit_USBD_MIDI, usb_midi, MIDI);
int rx_notes[N_TX] = {90, 93, 102};
#endif
// NEOPIXEL
Adafruit_NeoPixel pixels(1, 12, NEO_GRB + NEO_KHZ800);
int colors[N_TX][3] = {{255, 26, 0}, {0, 255, 0}, {0, 16, 255}};
// CAPACITIVE SENSING
int tx_pins[N_TX] = {TX1, TX2, TX3};
int32_t rx_values[N_TX];
......@@ -55,14 +53,6 @@ void setup() {
#endif
}
void loop() {
}
void setup1() {
}
int32_t measure(int pin) {
int32_t up, down;
up = down = 0;
......@@ -81,11 +71,12 @@ int32_t measure(int pin) {
bool any = false;
void loop1() {
void loop() {
for (int i = 0; i < N_TX; i++) {
rx_values[i] = measure(tx_pins[i]);
if (rx_triggered[i]) {
if (rx_values[i] < rx_thresholds[i]) {
// release
rx_triggered[i] = false;
#ifdef USE_MIDI
MIDI.sendNoteOff(64, 0, 1+i);
......@@ -93,6 +84,7 @@ void loop1() {
}
} else {
if (rx_values[i] > rx_thresholds[i]) {
// pressed
rx_triggered[i] = true;
#ifdef USE_MIDI
MIDI.sendNoteOn(64, 127, 1+i);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment