C/C++ Question How wrap IRRemote Library

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

in the process of attempting to wrap attached IRRemote Library - see rIRRemote.h and cpp.
Started with class IRrecv first but got stuck :(
In IRremote.h the IRrecv class hass following definition, which is not clear how to wrap.
B4X:
    public:
        IRrecv (int recvpin) ;
        IRrecv (int recvpin, int blinkpin);
...

defined in IRremote.cpp as
B4X:
IRrecv::IRrecv (int recvpin)
{
    irparams.recvpin = recvpin;
    irparams.blinkflag = 0;
}
...

Any help / hints appreciated.
 

Attachments

  • rIRRemote.zip
    35.9 KB · Views: 424

rwblinn

Well-Known Member
Licensed User
Longtime User
That helped a lot = got the constructors wrapped and compiled without error - using rSoftwareSerial example.

Next which I have not found a solution, is how to wrap:
B4X:
int decode (decode_results *results) ;
where decode_results is a class.

Any hints here?
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Thanks again for help. Made progress and able to receive data when pressing the remote control - BUT only the first 2 times after pressing on the Remote Control to Turn Pin 13 On / Off.
B4X:
1-IRReceive: 16724175
2-IRReceive: 16718055

In the B4R Code added a Looper to listen to IR data coming in via sub IRReceive.
When data comes in, the value is checked to turn pin 13 on or off. when done IRRecv.Resume is called.
BUT after two times nothing happens anymore?
Could there be a clash between the Looper and the IRRecv.Resume call? or is the logic of handling decode value wrong.

Attached: Wrapped Library (receive part) and B4R test code.
 

Attachments

  • B4RHowToIRRecv.zip
    37.6 KB · Views: 442

rwblinn

Well-Known Member
Licensed User
Longtime User
Some progress made.

B4R Code: Added a Delay(150) in the Looper, working (almost = sometimes need to press twice to see a reaction on the LED) OK.

Using ::Serial is a good helper.

In addition found a new IRRemote Lib based on the IRRemote Lib I have been using.
This new lib is able to handle interrupts better - which might solve the problem facing as mentioned earlier.
Will explore further - means wrap IRLib.
 
Last edited:

atiaust

Active Member
Licensed User
Longtime User
Hi,

When I try to use
java -jar B4Rh2xml <path to h file> <output file>
to wrap a library I get the following error message

Error: unable to access jarfile B4Rh2xml

I have tried putting B4Rh2xml.jar in multiple locations. No Luck.

Any ideas as to what I am doing wrong.

Thanks
 

atiaust

Active Member
Licensed User
Longtime User
You should have started a new thread for this question.

You should use:
B4X:
java -jar B4RH2xml.jar <path to h file> <output file>
Sorry. Realised should have created new thread after I had posted.
Will try as suggested.
 
Top