Error with Calling Teensy library from custom library - Teensy ILI9341

Hi

I am newbie to trying to create user/custom libraries. I am currently trying to make a GUI library for some of my students to use, I teach in engineering(I am more in materials) but am certainly not a real programmer. I have made a couple libraries in the past but never tried to call a separate library to use in the one I am creating. I get several errors about redefining, member function with out object, ect. I tried a bunch of different approaches and basically just traded one error for another.

If anyone can take a look the header file, cpp file, and sketch (sketch file should be ok, lol I think). I would really appreciate the help. There are several functions, if you guys can just help me fix the first one I can follow up on all the rest. I am also trying to increase my programming skills/knowledge so if anyone also has some good links or a suggested book, that too would be great.

I am not sure if I should attach the teensy library files I am trying to call or not. If so I will upload. I did not attach because I know the problem is not there, Paul is awsome.

GuiEasy.h (2.61 KB)

GuiEasy.h (2.61 KB)

example_library.ino (2.39 KB)

You attached the header file two times.
You attached the source file zero times.
You attached the error file zero times.

Going to be real hard to help you.

Hi Paul

Lol, well I feel like a real dummy. Thank you for pointing that out, don't know how I missed that. I also did not even think to upload the error file, that was a good suggestion.
So round two. Here is the correct files this time and thank you for taking a look.

GuiEasy.cpp (7.68 KB)

example_library.ino (2.39 KB)

GuiEasy.h (2.61 KB)

Error_file.txt (1.71 KB)

Why is this:

#ifndef ILI9341_t3H
#define ILI9341_t3H

in your GuiEasy.h file?

  public:
    bool s, p;  //act as temp storage, s = status, p = pressed

These fields should NOT be public. You should have, if it is meaningful, methods to get and set these private fields.

ILI9341_t3 tft;

The compiler is saying that you can't declare an instance of the ILI9341_t3 class this way, because the class does not have a no-argument constructor.

The examples that are provided with the library use code like:

#define TFT_CS 10
#define TFT_DC  9
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC);

If the idea is that your class should be aware of an instance of the ILI9341_t3 class defined elsewhere, the line in your GuiEasy.cpp file should be

extern ILI9341_t3 tft;

The
#ifndef ILI9341_t3H
#define ILI9341_t3H
part was from a previous attempt to fix the multiple redefining of of ILI9341_t3 tft. I had seen the idea in some other searches and tried it.

The variables in the public class are just place holders, I also have private versions _s, _p. I just did not include that in this version. (there are actually quite a few more variables and functions to the overall library I am trying to make. This "practice" version was to try to learn how to call an external library from within my library.) With that said, I do appreciate the advise on not allowing those variables to be only public and fully agree with you on that.

Now to the excellent fix. The extern ILI9341_t3 tft; was the idea/command I was trying to get to. That is why I had it defined as ILI9341_t3 tft, in the .cpp file. I was just not aware I needed the extern command first. (toward the other comment, I have it defined ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC); in the .ino file. I read/looked over the examples, .h, and .cpp files that you provided with the original ILI9341_t3 library)

Thank you very much for the help, it is greatly appreciated. That was exactly what I was missing.

Also as a side note, as a professor I love the teensy for our senior design projects, it is a very capable little board. We tried the audio board this year as well and it too is a great add-on. I think you guys do great work, keep it up. We definitely are going to continue to use your products. If you would ever have any interest in doing a collaboration with our senior design class we would love to work with you guys. We are also always on the hunt for any new potential "cool" topics/projects for the students to try, if you have any suggestions I would also be grateful to hear them.

Paul Stoffregen and I may share the same first name, and same first letter in our last names, but we are most definitely not the same person. I'm the taller one.