// RobotMonitor.java // // A program that displays robot state on the LCD screen. // // Simon Parsons // 17th October // // Based on Davide Grossi's RobotMonitor.java import java.lang.Thread; import lejos.nxt.*; public class RobotMonitor extends Thread{ private int delay; public StandardRobot robot; // Make the monitor a daemon and set the robot it monitors and the delay public RobotMonitor(StandardRobot r, int d){ this.setDaemon(true); delay = d; robot = r; } // The monitor writes various bits of robot state to the screen, then // sleeps. public void run(){ while(true){ LCD.clear(); LCD.drawString("LBump = "+robot.isLeftBumpPressed(), 0, 0); LCD.drawString("RBump = "+robot.isRightBumpPressed(), 0, 1); LCD.drawString("Ultra = "+robot.getUSenseRange(), 0, 2); LCD.drawString("Colour = "+robot.getCSenseColor(), 0, 3); try{ sleep(delay); } catch(Exception e){ // We have no exception handling ; } } } }