Hello again everybody!
I'm using callbacks from the MIDI library found here.
There is an issue. I have an SSD1306 i2c OLED using the Adafruit_SSD1306 library that causes my loop to go from ~1ms to >30ms when it is being updated. This interferes greatly with my incoming MIDI clock signal. I can tell because I have MIDI clock simply turning the builtin LED on and off, and when performing an event which updates the OLED (turning a pot), the LED blinking slows significantly.
I've asked on Reddit how to handle this, and the only way that people have concluded to fix this is to alter the Serial library directly in the Arduino code, to have it trigger an interrupt when a MIDI message is received. This seems a bit more complicated than it should be, and I've certainly seen Arduino MIDI projects using an OLED screen elsewhere (i2c, even), so I figured that I would ask here to get a second opinion.
I was told that putting the read() method inside a timer-based ISR would be useless because I would be missing MIDI messages as they arrive. Does this sound true? If it's not true, what frequency should the timer be to receive messages accurately?
In case this helps, I tried optimizing my OLED by only updating a portion of the screen instead of clearing the display and then updating it. There was no noticeable improvement of speed, as a loop still took ~30 millis.
Ultimately, my question is: Is there a way to schedule the MIDI read() method so that it accurately reads incoming messages, if my loop is slow? Thank you!
I'm using callbacks from the MIDI library found here.
There is an issue. I have an SSD1306 i2c OLED using the Adafruit_SSD1306 library that causes my loop to go from ~1ms to >30ms when it is being updated. This interferes greatly with my incoming MIDI clock signal. I can tell because I have MIDI clock simply turning the builtin LED on and off, and when performing an event which updates the OLED (turning a pot), the LED blinking slows significantly.
I've asked on Reddit how to handle this, and the only way that people have concluded to fix this is to alter the Serial library directly in the Arduino code, to have it trigger an interrupt when a MIDI message is received. This seems a bit more complicated than it should be, and I've certainly seen Arduino MIDI projects using an OLED screen elsewhere (i2c, even), so I figured that I would ask here to get a second opinion.
I was told that putting the read() method inside a timer-based ISR would be useless because I would be missing MIDI messages as they arrive. Does this sound true? If it's not true, what frequency should the timer be to receive messages accurately?
In case this helps, I tried optimizing my OLED by only updating a portion of the screen instead of clearing the display and then updating it. There was no noticeable improvement of speed, as a loop still took ~30 millis.
Ultimately, my question is: Is there a way to schedule the MIDI read() method so that it accurately reads incoming messages, if my loop is slow? Thank you!