Hi, i have a problem, if i use a OLED display by i2c the reading data from the MIDI analog input is very slow, i don't understand why...
There is a procedure for increase MIDI priority or something similar?
P.S. If i use usbMIDI or not use OLED all works fast and fine.
Code:
----------------
#include <MIDI.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#include <Wire.h>
#define OLED_RESET -1
Adafruit_SSD1306 display(OLED_RESET);
byte noteon, numberon;
void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
MIDI.begin(1);
MIDI.turnThruOff();
MIDI.setHandleNoteOn(MyHandleNoteOn);
MIDI.setHandleControlChange(MyCCFunction);
usbMIDI.setHandleNoteOn(MyHandleNoteOn);
usbMIDI.setHandleControlChange(MyCCFunction);}
void loop() {
display.clearDisplay();
while(MIDI.read());
while(usbMIDI.read());
display.setTextSize(1); display.setTextColor(WHITE); display.setCursor(0,23); display.setTextColor(WHITE); display.println(noteon);display.print(numberon);
display.display();
}
void MyHandleNoteOn(byte channel, byte note, byte velocity) {noteon=note;}
void MyCCFunction(byte channel, byte number, byte value) {numberon = number;}
--------
Thank you.
There is a procedure for increase MIDI priority or something similar?
P.S. If i use usbMIDI or not use OLED all works fast and fine.
Code:
----------------
#include <MIDI.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#include <Wire.h>
#define OLED_RESET -1
Adafruit_SSD1306 display(OLED_RESET);
byte noteon, numberon;
void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
MIDI.begin(1);
MIDI.turnThruOff();
MIDI.setHandleNoteOn(MyHandleNoteOn);
MIDI.setHandleControlChange(MyCCFunction);
usbMIDI.setHandleNoteOn(MyHandleNoteOn);
usbMIDI.setHandleControlChange(MyCCFunction);}
void loop() {
display.clearDisplay();
while(MIDI.read());
while(usbMIDI.read());
display.setTextSize(1); display.setTextColor(WHITE); display.setCursor(0,23); display.setTextColor(WHITE); display.println(noteon);display.print(numberon);
display.display();
}
void MyHandleNoteOn(byte channel, byte note, byte velocity) {noteon=note;}
void MyCCFunction(byte channel, byte number, byte value) {numberon = number;}
--------
Thank you.