-
Notifications
You must be signed in to change notification settings - Fork 3
/
Recording-Sign.ino
82 lines (61 loc) · 1.96 KB
/
Recording-Sign.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiUdp.h>
#include <Adafruit_NeoPixel.h>
#define SerialMon Serial
#define APPLEMIDI_DEBUG SerialMon
#include <AppleMIDI.h>
#define NUM_LEDS 7 // replace with the number of NeoPixel LEDs you're using.
#define PIN 13
#define CONTROL_NUMBER 1
#define ON_VALUE 127
char ssid[] = "ssid"; // replace with your network SSID (name)
char pass[] = "password"; // replace with your network password (use for WPA, or use as key for WEP)
char midi_name[] = "Recording Sign ESP32";
APPLEMIDI_CREATE_DEFAULTSESSION_INSTANCE();
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
void setup(){
DBG_SETUP(115200);
strip.begin();
WiFi.begin(ssid, pass);
WiFi.setAutoConnect(true);
DBG("Connecting to WiFi...");
while (WiFi.status() != WL_CONNECTED) {
colorWipe(255,0,255);
colorWipe(0,0,0);
}
DBG("Connected to WiFi.");
AppleMIDI.setName(midi_name);
DBG("Address:", WiFi.localIP(), "Port:", AppleMIDI.getPort(), "Name:", AppleMIDI.getName());
MIDI.begin(MIDI_CHANNEL_OMNI);
AppleMIDI.setHandleConnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc, const char* name) {
DBG("Connected to session", ssrc, name);
MIDI.sendControlChange(CONTROL_NUMBER, 0, 1);
colorWipe(0,0,255);
colorWipe(0,0,0);
});
AppleMIDI.setHandleDisconnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc) {
DBG("Disconnected from session", ssrc);
colorWipe(0,0,0);
});
MIDI.setHandleControlChange([](byte channel, byte number, byte value) {
DBG("Control change - Channel:", channel, "Number:", number, "Value", value);
if (number==CONTROL_NUMBER) {
if (value==ON_VALUE) {
colorWipe(255,0,0);
} else {
colorWipe(0,255,0);
}
}
});
}
void loop(){
MIDI.read();
}
void colorWipe(int red, int green, int blue) {
for (int i = 0; i<NUM_LEDS; i++) {
strip.setPixelColor(i, red, green, blue);
strip.show();
delay(70);
}
}