Usage of EmWi macros in the generated C-code

Description:

In some case it is necessary to get information, defined in EmWi macros, in the C-code of your application. This article describes a way how this can be realized.

 

Solution:

In a profile you can define a macro, but macros are not automatically exported as defines in the generated C-code. To get a #define in the generated C-code we recommend the following way:

 

1. Create a macro in the profile where you want to get a #define in the generated code. E.g.: the macro "NTSC" and set its content to "true" or "false" and another macro “MaxNoOfChannels” with content 3000.

 

2. Create a new unit e.g. “Configuration“ and get an "Inline Code"-brick from the Default Gallery into this unit.

 

3. The inline code can be edited in the editor window. There you can implement your #defines dependent on the EmWi macro contents e.g.:

 

$if $NTSC 
  #define CONFIGURATION_NTSC_ENABLED  1 
$else 
  #define CONFIGURATION_NTSC_ENABLED  0 
$endif

#define CONFIGURATION_MAX_NO_OF_CHANNELS $MaxNoOfChannels

 

See also:

FAQ Article: Using a #define from the C-application in EmWi

 

Keywords:

Macro, #define, C-code, Chora

 

Last update on 2010-08-19 by Mario Stefanutti.

Go back