Skip to main content

How to use Real-Time ?

Posted in

You need to include the lejos.realtime.* package in your program.

You can also include others packages to allow any of the standard lejos classes to be used in the program.

For example :

  1. import lejos.charset.*;
  2. import lejos.nxt.LCD;
  3. import lejos.nxt.comm.*;
  4. import lejos.io.*;
  5. import lejos.realtime.*;
  6. import lejos.util.*;
  7. import lejos.nxt.*;
  8. import java.lang.*;

Here is an example to create a RealTimeThread :

  1. RealtimeThread t2 = new RealtimeThread(new PriorityParameters(19),new PeriodicParameters(
  2. new RelativeTime(0,0), //start
  3. new RelativeTime(3000,0), // period
  4. new RelativeTime(2000,0), // cost
  5. new RelativeTime(3000,0), null, null)) { // deadline
  6.  
  7. public void run() {
  8. do{
  9.  
  10. }while(waitForNextPeriod());
  11. }
  12. };

Take a look to the API for more details.