noob with questions regarding libraries

So I took the menu backend library example and combined it with another example and got the data out to a different screen. I then tried to combine the button debounce example included, to allow for button based navigation in the menu, instead of serial console comands. I never did get it to work.

So even though I was able to hack together the other examples and get them to work, I don't really know enough about libraries and how they are setup to realize thier potential.

So I read the tutorial for the libraries and it did help a little. I did not save the code to post as it was not serious work, just trying to learn a little.


The libraries just give you a set of features to use.
You still have to write the code that calls out the features.
For example, I call out these 4 libraries:
// bring in the library(s)
#include <VirtualWire.h> // Wireless transmitter/receiver library
#include <Keypad.h> // Matrix Keypad library
#include <avr/sleep.h> // powerdown library
#include <avr/interrupt.h> // interrupts library

I then copied the demos for each, updtaing the keypad for the pins I had connected, writing an ISR for the interrupt I used, defining what had to happen and which sleep mode to go into, and creating the data that virtualwire was to send out.
The library alone just gives you features you can use, you have to come up with how you use them.

Ok then I gue the only way to really learn the library functions would be to read the cpp code and be able to understand what it does.

So along those lines, I need to modify a library to change the pin that is used in it. I cant open the .cpp file in audrino. The text is all garbled in notepad, most are not. I copied the code from github and pasted it into audrino and it was one long line. So I took the time to go through it putting in the line breaks. I did learn alot about the library and its functions, I think, but I was still not able to save it as a cpp. Oh and should it actually compile in library format?

I have read the tutorial on libraries, but it just tells what to put in the .h and .cpp files, not how to generate it? Or save it as one. I am sure I am missing something stupidly fundimental.

I will also revisit the menu code looking foer answers.



I cant open the .cpp file in audrino.

I'm getting more and more annoyed with the limitations the Arduino IDE imposes and thus more and more compelled to eventually move away from it to a more fully functioned IDE as my Arduino programs get more complicated. Arduino has some particularly annoying quirks when dealing with multi-file projects in particular.

That being said, you have a couple options for simply viewing .cpp and/or .h files. If you copy them into any existing sketch folder (perhaps just create a simple sketch for this explicit purpose), when you open that .pde, all other source code files in that folder will also be opened as additional tabs in that sketch. Alternatively, I also use Notepad++ for quick viewing of individual source code files when I just want to peruse other peoples code quickly and easily.

The whole copying them to the ketch folder solved the issues for me. I was able to change the pin number in the library and the sketch now seems to run fine, and I see the proper signals on the pin defined.


Like I said It almost seems stupid simple. So what to create a new .cpp file create a new blank in an editor and put that in the sketch folder. or create a new tab and name it what you want? Put in the code and save? Anyway, on with the good fight.