This article is automatically translated from Russian by Google Translator.
Text programming for LEGO NXT is done in C using macros and functions from the ECRobot library.
The general structure of the program:
First you connect the header files used in the program (standard C header files and ECRobot header files).
Then the constants and variables used in the program are declared.
These are followed by the functions ecrobot_device_initialize
and ecrobot_device_terminate
. The first one is called when the program starts and the second one when it stops. They usually initialize and deinitialize sensors, encoders, and other robot devices. The random number generator is initialized in ecrobot_device_initialize
by default.
This is followed by the description of the user_1ms_isr_type2
function, which is called every millisecond.
Then comes the description of the task, which is executed when the program starts: TASK (OSEK_Task_Number_0)
. This is where most of the programming is done.
Full description of functions in English available for programming.
The code generated by TRIK Studio itself can be used as examples.