passivate() method in Light doesn't work

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: imaqine, 99jonathan, roger

New User
Posts: 1
Joined: Sat May 26, 2007 9:31 pm

passivate() method in Light doesn't work

Postby darthc0da » Tue Jun 12, 2007 7:24 pm

Code: Select all

import icommand.platform.nxt.Light;
import icommand.platform.nxt.Sensor;
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.util.LinkedList;
import java.util.Timer;
import java.util.TimerTask;

public class DDWD extends Applet {
   private Light lightsensor;
   private LinkedList dataLightOff;
   private LinkedList dataLightOn;
   public void init() {
      final Graphics g = getGraphics();
      lightsensor = new Light(Sensor.S1);
      dataLightOff = new LinkedList();
      dataLightOn = new LinkedList();
      System.out.println("setting up queue's and sensors");
      for(int i = 0; i < 100; i ++){
         dataLightOff.add(new Integer(0));
         dataLightOn.add(new Integer(0));
      int delay = 1000; // delay for 5 sec.
      int period = 100; // repeat every sec.
      Timer timer = new Timer();
      System.out.println("starting timertask");
      timer.scheduleAtFixedRate(new TimerTask() {
         public void run() {
            System.out.println(dataLightOff.getLast() + "," + dataLightOn.getLast());
            for(int i = 0; i < 99; i ++){
            try {
            } catch (InterruptedException e) {
            dataLightOff.add(new Integer(lightsensor.getLightPercent()));
            try {
            } catch (InterruptedException e) {
            dataLightOn.add(new Integer(lightsensor.getLightPercent()));
      }, delay, period);

That's my code. The light never turns off. Anyone know what's going on? Does the passivate() method just not work?

Posts: 381
Joined: Fri Jun 01, 2007 4:31 am
Location: Berkeley, CA

passivate() method in Light doesn't work

Postby roger » Tue Jun 12, 2007 7:53 pm

because the passivate() is only implemented for the RCX style light sensors.
See the API for the LightSensor class. It uses setFloodlight(boolean floodlight)


Return to “NXJ Software”

Who is online

Users browsing this forum: gloomyandy and 3 guests