@@ -32,7 +32,7 @@ byte note_sequence[] = {
32
32
};
33
33
34
34
// Variable to hold the last time we sent a note
35
- unsigned long previousSend = 0 ;
35
+ // unsigned long previousSend = 0;
36
36
37
37
void setup ()
38
38
{
@@ -54,7 +54,6 @@ void setup()
54
54
// Initialize MIDI, and listen to all MIDI channels
55
55
// This will also call blemidi service's begin()
56
56
MIDI.begin (MIDI_CHANNEL_OMNI);
57
- blemidi.autoMIDIread (&MIDI);
58
57
59
58
// Attach the handleNoteOn function to the MIDI Library. It will
60
59
// be called whenever the Bluefruit receives MIDI Note On messages.
@@ -78,6 +77,7 @@ void setup()
78
77
// Start Advertising
79
78
Bluefruit.Advertising .start ();
80
79
80
+ Scheduler.startLoop (loop2);
81
81
}
82
82
83
83
void handleNoteOn (byte channel, byte pitch, byte velocity)
@@ -96,7 +96,6 @@ void handleNoteOff(byte channel, byte pitch, byte velocity)
96
96
97
97
void loop ()
98
98
{
99
-
100
99
// Don't continue if we aren't connected.
101
100
if (! Bluefruit.connected ()) {
102
101
return ;
@@ -107,16 +106,13 @@ void loop()
107
106
return ;
108
107
}
109
108
110
- // read any new MIDI messages
111
- // MIDI.read();
112
-
113
109
// Store the current time
114
- unsigned long now = millis ();
115
-
116
- // Check if enough time has passed since last send
117
- if (now - previousSend < 286 ) {
118
- return ;
119
- }
110
+ // unsigned long now = millis();
111
+ //
112
+ // // Check if enough time has passed since last send
113
+ // if (now - previousSend < 286) {
114
+ // return;
115
+ // }
120
116
121
117
// Setup variables for the current and previous
122
118
// positions in the note sequence.
@@ -143,7 +139,25 @@ void loop()
143
139
position = 0 ;
144
140
}
145
141
142
+ delay (286 );
143
+
146
144
// Log the send time
147
- previousSend = now;
145
+ // previousSend = now;
146
+ }
148
147
148
+ void loop2 ()
149
+ {
150
+ // Don't continue if we aren't connected.
151
+ if (! Bluefruit.connected ()) {
152
+ return ;
153
+ }
154
+
155
+ // Don't continue if the connected device isn't ready to receive messages.
156
+ if (! blemidi.notifyEnabled ()) {
157
+ return ;
158
+ }
159
+
160
+ // read any new MIDI messages
161
+ MIDI.read ();
149
162
}
163
+
0 commit comments