However, If I run my program with LCD Debug, the sensor always has a blue light and is ready to scan a color. it will return the color instantly, and never seems to crash. Here is my code:
Code: Select all
Port p = LocalEV3.get().getPort("S1");
SensorModes sm = new EV3ColorSensor(p);
SensorMode colorSensor = sm.getMode("ColorID");
int sampleSize = colorSensor.sampleSize();
float samples = new float[sampleSize];
float color = samples;
screenGraphics.drawString(String.valueOf(color), screenWidth/2, screenHeight/2, GraphicsLCD.BASELINE|GraphicsLCD.HCENTER);
int but = Button.waitForAnyPress(2);
if (but == Button.ID_ESCAPE) break; }
Is there a way to keep the sensor ready in normal mode? Why does it make a difference?
Edit: changed code, but still inconsistent behaviour. Also, I sometimes get a socket exception: too many files open. This is reproducible with colortest sample program.