It might be useful to educate Arduino programmers on the use of a Structure inside the Arduino IDE especially if they are saving important data to the EEPROM. You could highlight the use of .PUT and .GET to save and retrieve those structures from EEPROM to RAM.
Here is one I defined recently.
typedef struct gps {
float rlatf;
float rlonf;
float guideHeading;
int baseRox;
int roverGGA;
int roverGST;
int roverGSV;
int roverZDA;
int dirB;
};
gps gpsVar{0.0f, 0.0f, 90.0f,0,0,0,0,0,1};//declare a variable as the gps structure and preset values
gpsVar.dirB = 1; //simple use of a Structure Variable
EEPROM.put(0, gpsVar); //save the variable to EEPROM
EEPROM.get( 0, gpsVar );//retrieve the variable from EEPROM
Thank you Ljbeng:
Im always interested in coding and structures I know nothing about. I definitely will explore further. So much to learn and apply.
Best,
Anibal
As a hobby programmer I always found it easier to learn something new by using it in applications like I guess the EEPROM example above. Before using structures I used to rely on parallel arrays even though I had used structures (which I called records) in Assembler. In BASIC a structure is called a TYPE. It is just a way of grouping a block of different data types under a single label where an item in that group is then accessed via the dot notation.
http://www.cplusplus.com/doc/tutorial/structures/
Also you can have a structure as a member of a structure also. I do stay away from unions though.
I never got comfortable with pointers until I read "C pointers and dynamic memory management"
So once you get a good grasp on C grab on of the more advanced books.
It might be useful to educate Arduino programmers on the use of a Structure inside the Arduino IDE especially if they are saving important data to the EEPROM. You could highlight the use of .PUT and .GET to save and retrieve those structures from EEPROM to RAM.
Here is one I defined recently.
[snip]
Structures, which are POD (Plain Old Data) types in C, are actually considered classes in C++.
These objects are very useful in programming, and we have actually discussed them being used to write to EEPROM (and other things), here in the past. IMHO, learning how to create and use ones own objects (in any language), opens up an entire new world in ones programming skill-set. It's very difficult to get people to understand the benefits, but once you know how, you'll never look back.
Cheers.