Hello, I'm writing a library that includes three classes (nunchuck, i2cmaster, and servo), and I'm not sure how to include them. Do I declare them in my .h file or .cpp file, or even the sketch? If I include the header files of the three classes, do I have to include them in the sketch? Is there a guide that I can follow?
You should look at the existing libraries and see how they do it, thats the way i learned it, sometimes just altering examples and seeing what happens helps learning
also i think in the arduino playground there is a simple tutorial that can be searched up
Do I declare them in my .h file or .cpp file, or even the sketch?
You declare classes in a .h file.
You define classes in a .cpp file, and include the definition of the class (the .h file) in the source file.
In the sketch, you need to include all header files that any class-to-be-used also includes. If you don't, the header files, and related source files, will not be copied to the build folder, so the build will fail.
I am working on a big project/sketch and modifying the code/sketch severely.
Someone has suggested I use a "button class" which allows you options on how long the button is pressed to give different results.
Short, med, long holds.
As I know little about how things work, do I just "include" the class - still don't know how to do that - and it all just "works"?
Or do I have to look through the code and find any button calls and "replace" them with calls to the new class?
The sketch I am working on has a "wait_on_escape" call which is like a "wait for button press" but with no delay, and gets the value of the button pressed.
So I'm guessing I only (bad choice of word there?) have to modify the "wait_on_escape" function to call the class?