Midi input and callback functions

So I have a midi In connected to my arduino on rx pin. The goal is to trigger LEDs with the function BlinkM_fadeToHSB(,) depending on midi event. For now, a midi note with velocity>1 trigger one LED board with the 0x09 I2C bus adress. The color of the RGB LED is changed using 3 midi control changes number 7,13 and 14 using the HandleControlChange callback.

I add trouble to handle interruption of the HandleControlChange callback by the MyHandleNoteOn so I’ve added two boolean “interruptors” (not sure how to call them) boolean oklight and boolean oksignal between them to be sure to end the wire transmission before call a new BlinkM_fadeToHSB.

Now I want to multiplex my code to use more than one address on the I2C bus, but I’m not sure this is really scallable.For example, one special midi note could trigger one LED. I feel I should use the BlinkM_fadeToHSB function in the loop only and change it’s arguments in the callback but can’t figure out how to write this.
Does anyone as an idea?

Here is my code:

#include "Wire.h"
#include "BlinkM_funcs.h"

#include <MIDI.h>  // Add Midi Library

#define LED 13    // Arduino Board LED is on Pin 13

byte blinkm_addr = 0x09; // addresse du master controle
int color = 0;
int intensite = 255;
int saturation = 255;
boolean oklight = true; 
boolean oksignal = true;

// Below is my function that will be called by the Midi Library
// when a MIDI NOTE ON message is received.
// It will be passed bytes for Channel, Pitch, and Velocity
void MyHandleNoteOn(byte channel, byte pitch, byte velocity) {
  digitalWrite(LED,HIGH);  //Turn LED on
  if (velocity == 1) {//A NOTE ON message with a velocity = Zero is actualy a NOTE OFF
    digitalWrite(LED,LOW);//Turn LED off

    if (oksignal==true) {
      oklight = false;
      BlinkM_fadeToHSB(blinkm_addr, 0, 0, 0);
  if (velocity > 1) {
  BlinkM_fadeToHSB(blinkm_addr, color, saturation , intensite);
  oklight = true;

void HandleControlChange (byte channel, byte number, byte value){   
    if (number == 7 ){
      intensite = map(value, 0, 127,0, 255);
      if (number == 14 ){
      saturation = map(value, 0, 127,0, 255);
      //BlinkM_fadeToHSB(blinkm_addr, color, saturation, intensite);
      if (number == 13 ){
      color = map(value, 0, 127, 0, 255); 
      //BlinkM_fadeToHSB(blinkm_addr, color, saturation, intensite);
      if (oklight== true){
      oksignal = false;
      BlinkM_fadeToHSB(blinkm_addr, color, saturation , intensite);
      oksignal = true;

void setup() {
  BlinkM_fadeToHSB(blinkm_addr, 43, 0, 255); // instant fade
  pinMode (LED, OUTPUT); // Set Arduino board pin 13 to output
  MIDI.begin(MIDI_CHANNEL_OMNI); // Initialize the Midi Library.
// OMNI sets it to listen to all channels.. MIDI.begin(2) would set it
// to respond to channel 2 notes only.
  MIDI.setHandleNoteOn(MyHandleNoteOn); // This is important!! This command
  // tells the Midi Library which function I want called when a Note ON command
  // is received. in this case it's "MyHandleNoteOn".
  MIDI.setHandleControlChange (HandleControlChange);

void loop() { // Main loop
  MIDI.read(); // Continually check what Midi Commands have been received