   // Reading MIDI messages,
 
   MIDI.read();
-  
+
   byte data = MIDI.getData1();
-  
-  if(MIDI.getType() == 0xD0){ //metering?
-    if(data != 0){
+  byte data2 = MIDI.getData2();
+
+/*
+  if (MIDI.getType() == 0xD0) { //metering?
+    if (data != 0) {
       handleMetering(data);
-    }   
-  }
-  
+    }
+  }
+  */
+   if (MIDI.getType() == 0x90) { //select?
+    if (data != 0 && data == 0x18) {
+      currentDisp = 0;
+    } 
+    else if(data != 0 && data == 0x19){
+      currentDisp = 1;
+    }
+    else if(data != 0 && data == 0x1A){
+      currentDisp = 2;
+    }
+    refreshLCD();
+   }
 }
 
 

  display.clearDisplay();
  display.drawPixel(10, 10, WHITE);
  display.display();
}

/**

   LCD message should be processed here
*/
void handleScribble(byte *sysEx, unsigned buffSize) {

  
  byte offset = sysEx[6];
  byte *ptr = sysEx + 7;
  // Start to get the display to update (0->7)
  int displayId = getDisplayId(sysEx);

  // Get position on the display
  if (offset >= 0x00 && offset < 0x07) {
    oledDisplays[displayId].offsetl1 = offset;
    memcpy(oledDisplays[displayId].displayLine1, ptr, 7); // get next 7 bytes (skip the 0xF7 EOSysEx)
  }
  if (offset >= 0x38 && offset <= 0x3E) { //38->6C second line
    //second line
    oledDisplays[displayId].offsetl2 = offset;
    memcpy(oledDisplays[displayId].displayLine2, ptr, 7); // get next 7 bytes (skip the 0xF7 EOSysEx)
  }
  
   
    
  

}

void refreshLCD(){
  /*
   display.clearDisplay();
  //first line (+ display number)
  display.setCursor(0, 0);
  display.setTextSize(1);
  display.print(currentDisp + 1);
  display.setCursor(CH_WID *2, 0);
  display.setTextSize(2);
  //display.print(oledDisplays[currentDisp].offsetl1);
  for (int16_t i = 0; i < 7; i ++) {
    display.write(oledDisplays[currentDisp].displayLine1[i]); //write to convert Byte as char
  }
  
  //second line
  display.setTextSize(2);
  display.setCursor(0, CH_HEI * 2);
  //display.print(oledDisplays[currentDisp].offsetl2);
  display.setCursor(DP_WID_MID - (3 * CH_WID * 2), display.getCursorY()); // Center text on OLED
  for (int16_t i = 0; i < 7; i ++) {
    display.write(oledDisplays[currentDisp].displayLine2[i]); //write to convert Byte as char
  }
  display.display();
  //*/
}




void handleMetering(byte data) {
  int fullScale = DP_WID;

  byte chan = data & 0xf0; // from 0 to 7
  //TODO handle multiple displays

  byte level = data & 0x0f; // 0-> 0% , C-> 100%
  int meterVal = (level * fullScale) / 0x0C;

  display.clearDisplay();
  display.setCursor(0, 0);

  for (int16_t i = 0; i < meterVal; i += 1) {
    display.drawLine(display.getCursorX() + i, display.getCursorY(), display.getCursorX() + i, display.getCursorY() + CH_HEI, WHITE);
  }

  // Set Overload
  if (level == 0x0E) {
    overload = true;
  }
  // unset Overload
  if (level == 0x0F) {
    overload = false;
  }
  if (overload) {
    display.setTextSize(1);
    display.println(" ");
    display.print("OVERLOAD!!!!!"); //set overload
  }

  delay(50);
  display.display();
}


