Skip to content

Commit d6f41d4

Browse files
authored
Merge pull request #384 from henrygab/patch-2
Fix #379 [-Wsign-compare]
2 parents b1b3447 + a5305b2 commit d6f41d4

File tree

1 file changed

+3
-7
lines changed
  • libraries/Bluefruit52Lib/examples/Peripheral/blemidi

1 file changed

+3
-7
lines changed

libraries/Bluefruit52Lib/examples/Peripheral/blemidi/blemidi.ino

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ BLEMidi blemidi;
2828
MIDI_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
3434
byte 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);

0 commit comments

Comments
 (0)