by others in my programs. I refer of course to all these .h and .cpp files.
I have no idea how to read them or even how they relate to my program when my programs call them.
Is there a primer somewhere that will explain what is going on?
For example when I see something like
WiFiClient client; so what is that doing? Does the h or cpp file MUST be called that, or something inside only?
And suppose I want to see what sort of facilities are available in these programs, how do I read them. I double click and that nothing and then I open with textedit and still, there is not much documentation in the programs either.
If you want functionality of a library you have to include it's header file(s). That's the way to link it and make your program aware you want to use it. And when you compile your program, only the parts of the library you actually use are included in the program uploaded to the Arduino.
If it's a very good library it comes with documentation. Wether it's online or in the doc folder of the library. They also come with examples which show how to use it.
Lesser libraries don't include documentation or only in the source files (.h or .cpp). And yeah, then it's a pain to see what you can all do or you ahve to rely fully on the examples.
The main Arduino code is C, by C i mean a programming language named C. The .cpp and .h files you are seeing is C++ which is another language based on C.
WiFiClient client
is creating an object of the class WiFiClient, which from what you say probably means nothing to you, and :: is called a scope operator which is used to access members of an object.
I am not going to write a super long post explaining the very most basic concepts of C++ so instead i shall point you to a very good website i used in the past and still as a reference to this day, it does lack some new C++ stuff like lambdas, list and such but again that well ahead of your current level of understanding.
The Arduino IDE does not support every C++ aspect so if you really want to learn C++ use Visual Studio Community edition with all the C++ extensions and then follow this tutorial learncpp
KawasakiZx10r:
The main Arduino code is C, by C i mean a programming language named C.
I don't know what you mean by "main Arduino code". The .ino files of Arduino sketches are compiled as C++ after some minor preprocessing. There is some C in the Arduino core library, but there is even more C++.
I don't see how there is any room to disagree with what I said. It's indisputable fact that the .ino files of the sketch undergo some minor preprocessing and then are compiled as C++.
Dembe:
And suppose I want to see what sort of facilities are available in these programs, how do I read them. I double click and that nothing and then I open with textedit and still, there is not much documentation in the programs either.
There are other IDEs available (for example Eclipse / Sloeber) that allow you to directly trace definitions and function calls across multiple files and into Arduino libraries. This gives you total access to all source code.
But ........
I don't even understand the :: thing I see often.
I suspect (as already suggested) that you need to do a lot of homework before worrying about how library code is written.
WiFiClient client; so what is that doing? Does the h or cpp file MUST be called that, or something inside only?
It would be a big help if you post a complete short program that illustrates what you don't understand.
Think about thes lines of code
int myAge = 23;
int yourAge;
The first line create a variable of the type int and gives it the value 23.
The second line creates another variable of the type int but does not give it a value.
The line
WiFiClient client;
is like the second of my examples. It creates a variable of the type WiFiClient and give it the name client
The #include line tells the compiler to include an external file so that it knows where to look for the code for WifiClient (or whatever)
I like writing my own code as well. Everyone else's is just too complicated.
But...
A) You want your Arduino to do things.
B) Library files tell it HOW to do things.
So in reality, you will always be writing code that just ties different chunks of library code together.
Its a lot like Legos. You want to build something out if Legos? What kinds of Legos you have to work with?
The .cpp files are the Legos.
The .h files tell you & the compiler what kind of Legos are available for you to play with. You don't have to use all of them.