your application requires the math-function log(). As explained in the preceding answer, you have the possibility to invoke the stdlib function log() directly from native code. This approach is fully sufficient to use the function log() at the runtime in the target device. It is however not sufficient to use the function log() during the prototyping (when you test the application or a GUI component in Embedded Wizard Studio). The reason, Chora implements actually only few of the most important math functions. log() as well as log10() don't belong to this set.
What can we do?
One possibility would be to implement the log or log10 algorithm in Chora. This is not an easy task. Another approach is to provide the missing functionality in so-called Intrinsic Module. With Intrinsic Modules it is possible to extend the functionality of the Prototyping Environment. From technical point of view, an Intrinsic Module is an ordinary Windows DLL (dynamically loadable library), which Embedded Wizard can load automatically when you start the Prototyper. Once loaded, the C functions implemented in the Intrinsic Module are exposed to Chora and can be invoked when you test the application in Embedded Wizard Studio.
For the convenience of all readers of this thread I have prepared such Intrinsic Module and a simple Embedded Wizard project demonstrating its usage.
1. Please download and unzip the following file:
2. Once unziped, you can open the Embedded Wizard project extmath_test.ewp. Please note, the project has been created with version 9.20.
3. As you see, the example consists of a single, simple GUI component:
4. Start the Prototyper by pressing the keys Ctrl+F5.
5. In the Prototyper window you can now press the push buttons Call Log10 and Call Log. This causes the corresponding onButton1 or onButton2 slot method to be called. These slot methods, in turn, invoke the math methods Log10 or Log. For test purpose the functions are called with 0.5 as parameter. The outputs appear in the Log window:
6. Now, take a look at the implementation of the Log10 method. This method implement the operation log10:
As you see this method distinguishes between two cases. The first $if condition is true when the code is executed in Prototyping Environment (when you test the application in Embedded Wizard Studio). This code invokes a function named extmath_log10(). This function is implemented in the above introduced Intrinsic Module.
Please take a look in the directory containing the example. You see there a file named ExtMath.ewi. This is the Intrinsic Module I have provided for you. That this Intrinsic Module is in use can be seen in Log window just in the moment when you start the Prototyping for the application:
The second $if condition in the method Log10 is used when the code is executed in target device. In such case the method simply invokes the STDLIB math function log10().
To use the functionality in your project:
6. Copy the Intrinsic Module ExtMath.ewi to the directory of your own project.
7. Copy the desired method Log10 or Log to the component where you need to use the log operation.
8. Within the component, invoke the Log10 or Log methods where you want the log value to be calculated.
I hope it helps you further.