Custom Libraries

Okay everyone. I have an issue.

I am trying to write my own custom library. The functions within this library are dependent on a 3rd party library: IRremote.h

I need to know how to include this library within my .cpp and .h files.

I know this is not a lot of information- but I have failed to find a thread that provides an answer.

Header:

ifndef Actions_h

define Actions_h

include "Arduino.h"

include "IRremote.h"

class Actions{ my functions };

endif

CPP

include "Actions.h"

include "Arduino.h"

include "IRremote.h"

my code goes here

This general structure fails every time. For example: when I attempt to make an object to the IRremote.h class like this:

decode_results results;

The IDE flips out.

I have never known the IDE to "flip out". It produces error messages. Probably, it didn't like this

class Actions{
       my functions
};

I'm sorry. I think you misunderstood. I didn't provide the functions. I know they work. I have made a prototype in just a regular sketch.

Didn't feel the need to type them again. I'll provide an example of the errors.

Jaren:
I’m sorry. I think you misunderstood. I didn’t provide the functions. I know they work. I have made a prototype in just a regular sketch.

Didn’t feel the need to type them again. I’ll provide an example of the errors.

So you were asking us to debug some code, but decided to show us some different code instead? How much sense does that make? NONE! Post the code you need help with. Post the errors you got. With anything less than that this is just an exercise in futility and a waste of the time of people who were nice enough to try to help you for free. Don’t abuse them for trying to be nice to you.

BTW: You know that any libraries included in your .h files must also be included from the .ino right? That's one of the many quirks of the Arduino IDE and how it builds code.

Here is an example:

This code compiles and does what I wish.

When I add an object for the IRremote library- it fails.

stuff.ino (102 Bytes)

Actions.cpp (242 Bytes)

Actions.h (183 Bytes)

Jaren: When I add an object for the IRremote library- it fails.

Define "fails"

Jaren: This code compiles and does what I wish.

This may surprise you, but I can't debug the code that doesn't work by looking at the code that does work. I would have thought that was pretty obvious.

Okay Delta_G with the answer:

BTW: You know that any libraries included in your .h files must also be included from the .ino right? That's one of the many quirks of the Arduino IDE and how it builds code.

Thankyou very much!

I am sorry to have confused you guys. I was just trying to figure out how to include a library within a library. I seem to have figured it out now.

I was not including IRremote.h in the main sketch. Now that I have- there seems to be no issues. I was not aware that you had to include the library(s) in the .h, .cpp, and .ino file.

Jaren: Okay Delta_G with the answer:

Thankyou very much!

I am sorry to have confused you guys. I was just trying to figure out how to include a library within a library. I seem to have figured it out now.

I was not including IRremote.h in the main sketch. Now that I have- there seems to be no issues. I was not aware that you had to include the library(s) in the .h, .cpp, and .ino file.

Had you started out with your actual code and actual error messages, this could have been answered on reply #1 and you wouldn't have wasted all of this time.