From a5305b27b24c391cad34fbaec7e17328d354a580 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Fri, 8 Nov 2019 00:48:46 -0800 Subject: [PATCH] Fix #379 [-Wsign-compare] comparison between signed and unsigned integer expressions Fixed by using unsigned integers and adjusting check for first index. --- .../examples/Peripheral/blemidi/blemidi.ino | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/blemidi/blemidi.ino b/libraries/Bluefruit52Lib/examples/Peripheral/blemidi/blemidi.ino index 2dd581e2..d455b8c4 100644 --- a/libraries/Bluefruit52Lib/examples/Peripheral/blemidi/blemidi.ino +++ b/libraries/Bluefruit52Lib/examples/Peripheral/blemidi/blemidi.ino @@ -28,7 +28,7 @@ BLEMidi blemidi; MIDI_CREATE_BLE_INSTANCE(blemidi); // Variable that holds the current position in the sequence. -int position = 0; +unsigned int position = 0; // Store example melody as an array of note values byte note_sequence[] = { @@ -137,14 +137,10 @@ void loop() // Setup variables for the current and previous // positions in the note sequence. - int current = position; - int previous = position - 1; - + unsigned int current = position; // If we currently are at position 0, set the // previous position to the last note in the sequence. - if (previous < 0) { - previous = sizeof(note_sequence) - 1; - } + unsigned int previous = (current == 0) ? (sizeof(note_sequence)-1) : current - 1; // Send Note On for current position at full velocity (127) on channel 1. MIDI.sendNoteOn(note_sequence[current], 127, 1);