Sub routine component creation

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
cruzxia
Posts: 88
Joined: Wed Jan 04, 2006 7:34 am
Been thanked: 8 times
Contact:

Sub routine component creation

Post by cruzxia »

I have been trying out V6.
I have a few questions.

1. I want to use the component creator to create a sub routine that I can call as a component.
I don't need any graphics or simulation for this component.

Here is the simplest component
Component Name: Count
Input parameters: int A, int B
Return value: int C
Coding: C = A + B ;

The component creation examples all seem to focus on the graphical side, is there a simple way to create this component?
(obviously I would then expand that into creating a more complex set of component routines.)

2. Custom coding a Cal_component
Is it possible to custom code sections of a component?
For example converting the ST7565 LCD display from parallel to serial interface.
I would need to re write the write data routine.
Is it possible to access the hidden routines of a Cal component to customise them for your project?

Regards
cruzxia

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: Sub routine component creation

Post by Jordy101091 »

Hi,

I think it possible what you are trying to accomplish.
For your first suggestion:

My personal opinion is that such a component would be unnecessary Because you can do this in a calculation box.
But he proof me wrong :)

For your second suggestion:
This can also be done using flowcode, you can use the GLCD base component and build you're own component from there.
If you need any help with this, I'm willing to help you.

Regards jordy
the will to learn, should not be stopped by any price

cruzxia
Posts: 88
Joined: Wed Jan 04, 2006 7:34 am
Been thanked: 8 times
Contact:

Re: Sub routine component creation

Post by cruzxia »

Thanks for the reply.
The C=A+B is just an example in its simplest form.

I already written code (in C or Assembler) for various components I have created.
In V5 I made custom components, I can call them from any project, except you can only have 2, so it requires swopping the files out.
I was hoping to import or recreate my list of components in V6.

I tend to use Flowcode as a fast writing platform, with a fair bit of embedded C code, as a result I don't use the simulator or graphics much, as they skip the C code anyway.
So I am mainly interested in making my component library portable, so I can just drag it into a new project and start using it.

Thanks for the offer on the GLCD coding, I don't need that right now, I was just wondering if it is possible to do with the CAL components.

Regards

Cruzxia

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: Sub routine component creation

Post by Jordy101091 »

I think is shouldn't be a problem to convert your flowcode v5 component to version 6.
I would be happy to assist you with the conversion of your component.

Let me know what you think about it.

Regards jordy
the will to learn, should not be stopped by any price

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: Sub routine component creation

Post by JonnyW »

Hi. There is a blog written here:

http://matrixmultimedia.com/blog/?p=146

This shows an example of how to link C code into Flowcode. Note that there are other ways (you do not necessarily need to use Supplementary code) but is as good a way as any.

Cheers,

Jonny

cruzxia
Posts: 88
Joined: Wed Jan 04, 2006 7:34 am
Been thanked: 8 times
Contact:

Re: Sub routine component creation

Post by cruzxia »

Hi

I had a chance to make a few test components, It seems to work nicely once I figured out how it all worked.
I do have one more question regarding the blog instructions.
Instead of placing all the C code in the supplementary code section, as shown in the blog. Wold it work if you created multiple C code macros for each subroutine, just put the global definitions in the supplementary code.
Then rename the local variables FCL_variable_name and then exported it as a component.
This would make reediting of the component a little easier perhaps.
I would have tested this for myself, but the demo is limited to 4 lines of C code.

Cruzxia

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: Sub routine component creation

Post by JonnyW »

Hi.

Yes, there are a few alternatives:
  • Add a #include for your external source code in supplementary code
  • Add the C code into a Flowcode macro
  • Re-write the C code as flowcharts (this way it will simulate as well)
  • Embed all the code in supplementary code
  • Inject directly into the code at compile time using events
There will be more creative (i.e. needlessly fancy) ways as well, I'm sure.

PS: The 4-line limitation is a bug, some code left over from v5. The supplementary defines section can hold everything you need and is not restricted. It is also exportable as part of a component, whereas the function section is ignored on component export.

Cheers,

Jonny

Post Reply