blinkm maxm and midi, programming advices needed!

So I've added two boolean “tokens“ between the midiNoteOn and midiControlChange callbacks and it works! It thus wait the return of the function before being able to lauch a new transmission. Not sure it's the most elegant wait to do it but as for now it's a good start.

#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_begin();
  BlinkM_stopScript(blinkm_addr);
  BlinkM_fadeToHSB(blinkm_addr, 43, 0, 255); // instant fade
  BlinkM_setFadeSpeed(blinkm_addr,255);
 
  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 
}