Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 00:33 04 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Guest Book : CMM2 add functionality

Author Message
gwboyd
Newbie

Joined: 05/08/2020
Location: Australia
Posts: 3
Posted: 04:50am 05 Aug 2020
Copy link to clipboard 
Print this post

This question must surely have been answered somewhere in the forum but I cannot find it so I will ask it here. If one wants to add a function to the firmware on the CMM2 (it is clearly stated that this is easy to do) what are the actual steps involved?? The section that describes this on the website follows :

Adding Functionality

MMBasic has a simple mechanism for adding functionality that is both elegant and efficient. This allows the easy addition of new commands, functions and operators.

For example, let us say that you want to implement a function that returns a special value generated by your hardware.

In one file you would define the C function to perform the operation:

     void fun_myfun(void) {
         fret = (float)special_data_to_return;
     }

And in another file you insert the definition of your function into the function table.  This links the function name in BASIC ("MyFunction") with the C function (fun_myfun):

     { "MyFunction",    T_FNA | T_NBR,    0,   fun_myfun },

MMBasic will do the rest and in your BASIC program you can use the function like any other:

     PRINT MyFunction/100

This mechanism also applies to commands and even to arithmetic and string operators (ie, +, -, /, etc).
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024