Adafruit_CharacterOLED icon indicating copy to clipboard operation
Adafruit_CharacterOLED copied to clipboard

Conflict between MIDI.h and Adafruit_CharacterOLED

Open t0maszduda opened this issue 4 years ago • 1 comments

Hi I've found problem and I can't use RX from MIDI.h library at all TX works.

I tested and I found that this function causes problem of RX pins in all Serial0, 1, 2, 3

void Adafruit_CharacterOLED::waitForReady(void) 
{
  unsigned char busy = 1;
  pinMode(_busy_pin, INPUT);
  digitalWrite(_rs_pin, LOW);	
  digitalWrite(_rw_pin, HIGH);      
  do
  {
  	digitalWrite(_enable_pin, LOW);
  	digitalWrite(_enable_pin, HIGH);

  	delayMicroseconds(10);
  	busy = digitalRead(_busy_pin);
  	digitalWrite(_enable_pin, LOW);

  	pulseEnable();		// get remaining 4 bits, which are not used.
  }
  while(busy);
  
  pinMode(_busy_pin, OUTPUT);
  digitalWrite(_rw_pin, LOW);
}

and this is simple code to check the problem:

#include <MIDI.h>
#include <Adafruit_CharacterOLED.h>
Adafruit_CharacterOLED lcd(OLED_V2, 22, 24, 26, 28, 30, 32, 34);

MIDI_CREATE_DEFAULT_INSTANCE();
bool LED=false;


 void setup()
 {
     MIDI.begin(MIDI_CHANNEL_OMNI);  // Listen to all incoming messages
     MIDI.setHandleNoteOn(MyNoteOnFunction);
     MIDI.setHandleNoteOff(MyNoteOffFunction); 

pinMode(10,OUTPUT);
  
     
 }

 void loop()
 {
     
     // Read incoming messages
     MIDI.read();
     if (LED==true)
     {
      digitalWrite(10,HIGH);//turn on led
     }

}


void MyNoteOnFunction (byte channel, byte note, byte velocity)
{

LED=true;

}

void MyNoteOffFunction (byte channel, byte note, byte velocity)

{

}


}

Standard library LiquidCrystal works correctly and of course it doesn't have that function.

t0maszduda avatar Sep 19 '20 18:09 t0maszduda

The second Arduino works properly! I must check next one. it is strange becouse everything works properly except this issue on that arduino.

t0maszduda avatar Sep 19 '20 20:09 t0maszduda