Code Editor
1. Open the Code Editor
- Click the Memu > Tools > Code Editor to open the Code Editor.

- ETStudio provides some examples about the C mini program, you can open them via the Example button in the Code Editor page.
2. Create or Open an exiting C mini Program Project
2.1 Create/Open a new project
From the Code Editor page, click the File > Open Folder... to open the folder selector dialog. And then choise the folder where the C mini Program Project is located or you want to save it to.

2.2 Create a new file(*.c or *.cpp)
- Create a main code file

- From the Code Editor page, click the folder of you project in the left panel to open the file tree, then click create file button and enter the file name to create a .c or .cpp file. And the file will be the main code file of the project.
- The main code file needs to include the
BaseMiniProgram.hheader file, and it must include at least three functions:void PreviewApplicationInitialize(),void MainTest(), andvoid MainTestFinalized().
#include "BaseMiniProgram.h"
#include <stdio.h>
int value = 0;
int step = 1;
uint8_t data[1] = {0x01};
void UpdateSysVar()
{
data[0] += step;
if (data[0] >= 9)
{
step = -1;
}
else if (data[0] <= 1)
{
step = 1;
}
CAN_Tx(1, 0x1F0, 1, data);
}
void PreviewApplicationInitialize()
{
}
void onRX(EM_ReceiveFrame_t const* msg)
{
cnamespace::doubleValue = (double)(msg->data[0])*1.5;
double doubleValue = cnamespace::doubleValue;
char Buffer[200];
snprintf(Buffer,200,"doubleValue = %f",doubleValue);
show_console_message(Buffer);
}
void MainTest()
{
register_MainFunction(100, UpdateSysVar);
register_CANRxEvent(1, 0x1F0, onRX);
}
void MainTestFinalized()
{
} - The main code file needs to include the
2.3 Configure extended include and library path
env_vars.txt:INCLUDE_PATHandLIBRARY_PATHEXTENDED_LIBRARY_PATH=-lcjson -L"<search path of the library files eg. C:\cJSON\lib>" -lws2_32EXTENDED_INCLUDE_PATH=-I"C:\cJSON\include"
3. Edit code
- You can edit the code in the code editor.
- The editor provides function hints during code editing.
4. Build C mini program
4.1 Open the c mini program file (the *.c or *.cpp file) in the code editor.
4.2 From Terminal > Run Task... > click the Build C mini Programe files button in the code editor to build the project.
4.3 If the build is successful, it will output Build successful!.

5. Execute C mini program
note
Before running C mini program, you need to Build C mini program first.
- Open the c mini program file (the
*.cor*.cppfile) in the code editor. - From Terminal > Run Task... > click the Execute C mini Programe files button in the code editor to run the project.

note
You need to click the Start Measurement before running the C mini program.
3. C mini program is running

6. Stop C mini program
From Terminal > Run Task... > click the Stop C mini Programe button in the code editor to stop the C mini program.

7. Programming Help
7.1 APIs
7.2 Examples of the C mini program
- Examples can be found from here

8. Limitations
Do not assign values to global variables by calling C Mini Program API functions. For example, the situation shown below will cause the C Mini Program to fail to run properly:
. You should do it like this:
.




