@ work I develloped a python script to generate state machine files using a graphic representation as source. I also made scripts to generate some extra stuff such as a file for timers, round robin tasks, IO lists and their descriptions and the xxx.ino is also generated.
I want to make a stripped version of this project generator for the hobby community. The idea is that you first create basic state machine in a porgram called 'yEd', use the script to create the source codes. Then you must assemble the IO files. At work we had a .c and a .h files because our IO have to have descriptions to display on a monitor. And after all files are generated the rest of the project is to be assembled. As software timers are implemented you only have to fill in the state machine and it's states.
The syntax of the state machine looks as follows:
State(startKraken) {
nextState(turn2kraken, 0); }
State(turn2kraken) {
nextState(stop4kraken, 0); }
State(stop4kraken) {
nextState(krakenOut, 0); }
State(krakenOut) {
if(clusterIndex == (clusterAmount - 1)) nextState(Kraken_IDLE, 40); // conditions to be filled in
else nextState(turn2kraken, 40); }
It is just a fraction of the function. It is a switch case with a clever written macro.
With more macros I managed to let a single state look like:
State(turn2kraken) {
entryState{
}
onState{
if(condition) exit = true;
}
exitState {
return true;
}
}
This is just a part of the 'magic'
It is my believe that everybody who speaks english may understand what the code in my format supposes to do.
There is one thing I have to know about arduino IDE.
The work project has 2 sub-folders in the program's directory. One sub folder is called "modules" and contains our machine's unique source and header files. The other sub folder is for the basic stuff which every machine has; basic functions, io lists, timer software. This is stuff which is not to be altered.
We compile stuff with a compiler to which I must tell which files the compiler must compile. When we start a new project, we just generate what we need and copy the entire content of the basic stuffs and the modules.
That means we that we also copy modules we do not need, we simply tell the compiler not to compile these files.
When I put files in the main program's directory for arduino. Arduino seems to compile every thing?
I was wondering how this precisely works. Does arduino look at the #includes in the files? to know what to compile and what not? Or does the IDE simply compile every .ccp it can find in the main folder? and in all the sub folders?