[SOLVED] using Arduino libraries in Flow code. Few questions about Flowcode functinalities

For general Flowcode discussion that does not belong in the other sections.
Post Reply
Steve-Matrix
Matrix Staff
Posts: 1509
http://meble-kuchenne.info.pl
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 211 times
Been thanked: 350 times

Re: Few questions about Flowcode functinalities

Post by Steve-Matrix »

To use Arduino libraries, you will need to convert the code to Flowcharts. Some Arduino code can be used directly in C-code icons. These will not simulate in Flowcode. To include simulation, you would need to re-write the library code as a flowchart within Flowcode. And if you wanted this code to be available for multiple projects, then you should create a component.

The "C to Flowchart" feature will convert many types of C code, but not everything. Also, it will not convert C++ specific code. Anything it cannot convert will remain in C-code icons.

ta9reefa
Posts: 2
Joined: Sun Sep 08, 2024 9:18 am
Has thanked: 1 time

Re: Few questions about Flowcode functinalities

Post by ta9reefa »

Thanks Steve! that helped a lot. I've got a few follow up questions if you don't mind
Steve-Matrix wrote:
Mon Jun 16, 2025 11:20 am
To use Arduino libraries, you will need to convert the code to Flowcharts.
Must convert the library code? or the Arduino code? if it's the Arduino code, then is there a Flowcode libraries folder to put the arduino libraries files in?

Steve-Matrix wrote:
Mon Jun 16, 2025 11:20 am
Some Arduino code can be used directly in C-code icons. These will not simulate in Flowcode. To include simulation, you would need to re-write the library code as a flowchart within Flowcode.
ok, simulation necessates implementation in flowcharts.

Steve-Matrix wrote:
Mon Jun 16, 2025 11:20 am
And if you wanted this code to be available for multiple projects, then you should create a component.
Clear.

Steve-Matrix wrote:
Mon Jun 16, 2025 11:20 am
The "C to Flowchart" feature will convert many types of C code, but not everything. Also, it will not convert C++ specific code. Anything it cannot convert will remain in C-code icons.
Clear.


As I understand thus far, to include an Arduino library, I have the following options:
  • Write/implement the library as a flowchart
  • Create a component. Which is the most proper way of doing it
  • Copy the library code (the .h followed by the .cpp file) into a C-code icon. But doesn't this mean the C-code icon would need to compile/run before the main flowchart/macro? otherwise, the library declarations wouldn't work.
  • Use supplementary code option in projects options (I forgot to ask about this one)

To use supplementary code in projects options, would it just work to copy libraries' (.h) files into Definitions and function declarations and copy libraries' (.cpp) files into Function implementations?


Thanks Again!

Steve-Matrix
Matrix Staff
Posts: 1509
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 211 times
Been thanked: 350 times

Re: Few questions about Flowcode functinalities

Post by Steve-Matrix »

"Convert the library code" means you would need to understand what the code is doing and then write it within Flowcode as a flowchart. There's no simple way to make the code work as-is within Flowcode.

The C-to-Flowchart feature can help convert most of the C/C++ code. But it will not convert everything.

A C-code icon is a flowchart icon within your flowchart. You can add C-code statements there.

You can also add C-code to the Supplementary Code boxes. This is usually used for larger blocks of code - e.g. functions that you want to call from within your flowchart. Code here will be ignored during simulation. Typically you could copy the ".h" to the 'declarations' section and the ".c" code to the 'implementations' section.

The code is passed directly to the underlying C compiler and so any non-standard C code in the Arduino library will cause compilation errors. There is some cross-over between C and C++, but they are not the same language. C++ code could contain many features that are not understood by the C compiler.

ta9reefa
Posts: 2
Joined: Sun Sep 08, 2024 9:18 am
Has thanked: 1 time

Re: Few questions about Flowcode functinalities

Post by ta9reefa »

Perfect. Thanks.

Post Reply