Project assembly, state machines and bug prevention

Are you growing tired of scrolling through your too large .ino file?
Are you experiencing more bugs than you'd like to?
Do you have difficulty coding rather complex processes?

Than I have something for you. I can let your computer take over some of your tasks so you don't even get to create sooo many bugs :wink:

I also have a neat easy-for-the-eye state machine structure for you which is designed specifically to code the most complex processes with ease. The best part is that the skeleton of this state-machine is generated for you.

You can go from this:

To this:

In a newly assembled folder:

In a few seconds by running this simple script:

And from this point on you only have to fill in the state functions and perhaps a round robin tasks or two.

IO is maintained in one single file and is outfitted with MCP23017 integration. All initialization is done for you. You cannot ever forget to type the pinMode instruction in the setup anymore. There will also be updates for atleast PCA9685 pwm drivers, a debounce module and software serial integration and perhaps 75hc595 shift registers as well!

Timers are maintained in one separate file as well. All timers are just 8 bit, they count down to zero and they have a configurable interval base. Give a state a timeout? wait a certain time between states? All can be done.

Structure to handle your round robin tasks?

extern void processRoundRobinTasks(void) {
	static unsigned char taskCounter = 0;

// HIGH PRIORITY ROUND ROBIN TASKS
	readSerialBus();

// LOW PRIORITY ROUND ROBIN TASKS
	taskCounter ++;
	switch(taskCounter) {
		default: taskCounter = 0;

		case 0:
		/* fill in a task */
		break;

		case 1:
		/* fill in a task */
		break; 
	}
}

Is in Place! Just fill in your round robin tasks.

I also offer you a new system to handle your own custom libraries. The assemble scripts asks you which of your 'modules' is to be copied to your new folder. If you like, you may even alter the scripts yourself to setup an automated initialization of your modules. Let the computer #include your code for you and let the computer place xxx.begin(); for you. It can be done!

If you'd like to know more, please read this readme file. There are also more markdown files for you with more detailed explanations.

Enjoy,

Bas

Cool, but this probably belongs in the Exhibition/Gallery forum.

It sounds as if you have put a lot of effort into this but I don't think your description does it justice. Your opening sentence is "I made some tooling to help set up new project folders." Why would I, or anyone need "tooling" to do that?

I think your project is about far more than folders but your description does not convey (to me, at least) why anyone would want to use this or how one would go about using it. At this stage it just sounds like something more that I would have to learn in order to do things I can already do.

What sort of people do you envisage as your target market?

Perhaps an introductory video on YouTube could illustrate how to set up your system and allow people to see the benefits of it without needing to study code or install anything.

...R

Robin2:
Why would I, or anyone need "tooling" to do that?

Why do it yourself, if your computer can do it for you?

Valid question however. The simple answers are 'convenience' and 'speed'. The more elaborate answer and reason why this exists is 'bug prevention'. The scripts automate certain tasks for us. By letting the computer do as much as possible we have to do as few tasks as possible therefor there are fewer things we can either forget or screw up. That is my theory atleast.

One of things it does, is generating the IO files. These files come with an init function which initializes all pinModes() for you. So you cannot forget to type the pinMode instruction in the setup anymore and thus a possible change on a small bug is prevented. (+ you have integrated MCP23017 functionality).

You also need to bear in mind that you can augment the scripts yourself. For Instance I am going to use the updateIO script to use PCA9685 pwm driver. But also think of a virtual serial port or debounce IO (<= almost finished). Than in the file io.tab you can handle IO for a software serial port, regular IO, debounced IO, MCP23017 IO, PCA9685 12 bit pwm outputs.

The scripts allow you to do as much work as possible with as few as possible keystrokes.

Robin2:
Perhaps an introductory video on YouTube could illustrate how to set up your system and allow people to see the benefits of it without needing to study code or install anything.
...R

That is a very good idea, I was thinking of the very same thing last night. Can you recommend a good software tool for recording? I think that the lightning speed with which I can set up the projects are also interesting

The most powerful feature is the state-machine generation. This is where this project started. That gameExample for instance needed about 15 minutes of actual coding. Every State, follow-up state and state function is assembled and placed for you. Every state is clearly devided in 3 sections (entry, on and exit). And every section is a relative small part. Splitting the code in such small parts also helps a great deal with preventing bugs.

This code structure has proven at work and it really helps a lot to code (and documentate) the most complex processes.

Robin2:
What sort of people do you envisage as your target market?

Slightly experienced programmers who:

  • have forgotten to type a pinMode instruction once
  • are troubled by a too large .ino file
  • experience difficulties with coding complex processes
  • could use an awesome code structure :wink:

Robin2:
At this stage it just sounds like something more that I would have to learn in order to do things I can already do

Well the idea was that people who would read this also would read the readme.md of the link. If people are not tempted to do that I can better change the OP.

The readme explains in more details. There are just 3 things you actually have to do. The hardest part: Make atleast 1 yEd state diagram. The program is simple, you can master it in 3 minutes propably. I have however included one demo state diagram which you can use instead.

Step 2 is optionally and require you to fill in IO

Step 3 is double clicking the 'assembleProject.py' script and enter a name. The scripts also asks you if you want to copy some of the modules in the module directory. But to do this is optionally.

In fact Step 1 is also optionally. The assembleProject script also functions without a state-machine. You will still have timers, IO, mcp23017 functionality, round robin tasks and any hand picked modules to you available. So you can just run git clone/download zip and double click 'assembleProject.py'.

bask185:
Slightly experienced programmers who:

  • have forgotten to type a pinMode instruction once
  • are troubled by a too large .ino file
  • experience difficulties with coding complex processes
  • could use an awesome code structure :wink:

Its great to see that you have a clear idea about your market.

Now, the next thing from a "marketing" point of view is to write the first two (three at most) sentences of your introductory spiel that gets those people to recognize that they are the intended audience and to say "Wow I must try this".

...R

@Robin thnx for the tips, I think I totally got your point and I changed the OP entirely. I added pictures as well.

bask185:
@Robin thnx for the tips, I think I totally got your point and I changed the OP entirely. I added pictures as well.

It reads much better now, but, unfortunately a lot of the discussion in Replies #2 to #4 no longer make sense because the original text of the Original Post has been deleted. (However in this case I don't think it would have been practical to retain the original text)

...R