Callback functions

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

Moderator: Benj

Post Reply
mnf
Valued Contributor
Valued Contributor
Posts: 1208
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times

Callback functions

Post by mnf »

Is there a way to create a callback function in Flowcode?

I would like to create a macro that passes control to a separate macro to display instructions to the user. The macro itself will be 'generic' and ideally incorporated into a component in time - the method of instructing the user could vary widely (flash an LED or display a message on a LCD etc)

So - I'd like to pass a macro's 'address' to the routine as ?? Handle - DisplayInstructions() ?? where the routine will then call DisplayInstructions(1), DisplayInstructions(2) etc

(Just like callback function parameters in C)

Martin

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Callback functions

Post by Benj »

Hi Martin,

I think the answer is not really, but there is a way to do something similar.

If you look at the GLCD Textfield component or Bitmap Drawer components they can be used with any graphical LCD.

This was done by creating a dummy GLCD component with the functions we need and then calling these dummy functions in the component. We then use the System.RedirectMacros API call to redirect the calls to the dummy component to the real GLCD component. For the redirect to work correctly the function names, parameters and returns must be a perfect match with the dummy component. This will work well for the simulation but for the download you will be fixed to a single redirect.

I'm not sure if this helps you so another way might be to use the supplementary code window in the project options to create a C function and then you can use this with pointers in your project using C code icons. Please note that this approach will not simulate.

A further way might be to use a lookup table component to specify the content, for example values 0-127 could be ascii codes to display on a LCD, 128 onwards could have special meanings such as wait for input or control the LCD cursor position. You could then use multiple LUT components and create a component that allows you to set the values in the LUTs and control which LUT is executed. This way is probably the most work as you would have to write the parser to do what you need it to do but this will simulate and download correctly.

Post Reply