4 // Sample for C++ and LEJOS-OSEK
\r
6 // Written 20-jan-2008 by rwk
\r
8 // Copyright 2007, 2008 by Takashi Chikamasa and Robert W. Kramer
\r
12 #include <TouchSensor.h>
\r
15 // To properly interface with LEJOS-OSEK, we need to use C linkage between our
\r
16 // code and LEJOS-OSEK
\r
21 #include "ecrobot_interface.h"
\r
23 // Port configration for Sensor and Motor
\r
25 Motor motor(NXT_PORT_C);
\r
26 TouchSensor touch(NXT_PORT_S4);
\r
29 // Main task (thread) declarations
\r
31 // You need one DeclareTask( ) per task/thread
\r
34 DeclareTask(MotorTask);
\r
35 DeclareTask(TouchTask);
\r
38 // User tasks go here.
\r
41 enum { FORWARD,STOP };
\r
43 int robotAction = STOP;
\r
48 if (robotAction == FORWARD)
\r
53 else if (robotAction == STOP)
\r
59 // your task should end like this unless it's a one-shot task
\r
70 if (touch.isPressed())
\r
72 robotAction = FORWARD;
\r
80 // your task should end like this unless it's a one-shot task
\r