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
Callback functions
Moderator: Benj
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel