Skip to content

Commit 847a4fe

Browse files
henrygabNaotoFujihiro
authored andcommitted
Fix adafruit#379 [-Wsign-compare]
comparison between signed and unsigned integer expressions Fixed by using unsigned integers and adjusting check for first index.
1 parent fc63ac9 commit 847a4fe

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

+3-7
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)