Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
264 views
in Technique[技术] by (71.8m points)

c++ - RGBmatrixPanel Library interfering with IRremote Library

I think I have found an error in the RGBmatrixPanel library AKA PxMatrix LED MATRIX Library.

I am using an Arduino Mega connected to a 64x32 .matrix board running PxMatrix version 1.8.1

The library RGBmatrixPanel, or more specifically the function matrix.begin(), which is used to initialise and start the board interferes somehow with the widely used IRremote library.

I have created a Minimal Reproducible Example (below) where this problem can be seen. The infrared receiver works normally as expected but as soon as matrix.begin() is run the infrared receiver stops returning values and instead returns random HEX codes.

Note: the IR receiver is plugged in to pin 3 on the mega Note 2: the code does not actually print anything to the LED board, so it is clear it is a problem with the RGBmatrixPanel Library.

#include <RGBmatrixPanel.h>
#include <IRremote.h>

#define CLK 11
#define OE 9
#define LAT 10
#define A A0
#define B A1
#define C A2
#define D A3

RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false, 64);

int RECV_PIN = 3;
IRrecv receiver(RECV_PIN);
decode_results results;

void setup() {
  Serial.begin(9600);
  //matrix.begin();      //unslash matrix.begin() for the IRreciver to stop working
 receiver.enableIRIn();
}

void loop() {
  if(receiver.decode(&results)) {            
    Serial.println(results.value, HEX);     
    receiver.resume();                      
  } 
}

I would appreciate any help you can provide on this matter, if you need any more info about this problem please let me know.

Thanks in advance, Elliot

question from:https://stackoverflow.com/questions/66064871/rgbmatrixpanel-library-interfering-with-irremote-library

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I am not sure what makes you think that it is an

error in the RGBmatrixPanel library

if there is a conflict with another library. Why is not the IRRemotes's fault?

Actually it is nobody's fault. You'll encounter many such conflicts in your life.

What if two devices have the same i2c address? Who's fault is this? Again, nobody's.

Both libraries are probably using the same timer.

There's only a very limited set of hardware resources. You cannot give each library its exclusive resources. That's just not going to work.

A quick look into the sourcecode of the IRReceiver library suggests that you can change the timer used.

I suggest you give both libraries' code and documentation a thorough read.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...