Since these keywords(?) are not in the Arduino Reference (not orange colour in the IDE) they are in C/C++ language.
Have browsed some tutorials and can understand them until i caught something from Nick Gammon's superb reference website and that is;
// Example state machine reading serial input
// Author: Nick Gammon
// Date: 17 December 2011// the possible states of the state-machine
typedef enum { NONE, GOT_R, GOT_S, GOT_G } states;// current state-machine state
states state = NONE;
From a tutorial, i understand how enum
works;
enum colors_t {black, blue, green, cyan, red, purple, yellow, white};
and that is colors_t
becomes a variable* (of int
type) which can have the values of said colors (being the values of 0,1,2,3,4,5,6,7 - ie. enumerated as such)
*(Not variable but variable type !)
Also i get that typedef
is for creating aliases to existing types like byte, char, int
, etc.
...
OK - i think i get it now after realising that colors_t
is a type, not a variable.
That explains;states state = NONE
to mean define state as a variable of type states
with initial value "NONE"
And then, that means;typedef enum { NONE, GOT_R, GOT_S, GOT_G } states;
declares "states" as a type-alias of "enum{NONE,etc...}" which i'm assuming is implicit as an integer ?
Have i got that right ?