File tree Expand file tree Collapse file tree 1 file changed +3
-7
lines changed
libraries/Bluefruit52Lib/examples/Peripheral/blemidi Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ BLEMidi blemidi;
2828MIDI_CREATE_BLE_INSTANCE (blemidi);
2929
3030// Variable that holds the current position in the sequence.
31- int position = 0 ;
31+ unsigned int position = 0 ;
3232
3333// Store example melody as an array of note values
3434byte note_sequence[] = {
@@ -137,14 +137,10 @@ void loop()
137137
138138 // Setup variables for the current and previous
139139 // positions in the note sequence.
140- int current = position;
141- int previous = position - 1 ;
142-
140+ unsigned int current = position;
143141 // If we currently are at position 0, set the
144142 // previous position to the last note in the sequence.
145- if (previous < 0 ) {
146- previous = sizeof (note_sequence) - 1 ;
147- }
143+ unsigned int previous = (current == 0 ) ? (sizeof (note_sequence)-1 ) : current - 1 ;
148144
149145 // Send Note On for current position at full velocity (127) on channel 1.
150146 MIDI.sendNoteOn (note_sequence[current], 127 , 1 );
You can’t perform that action at this time.
0 commit comments