本文整理汇总了Java中lejos.hardware.sensor.EV3ColorSensor.getRGBMode方法的典型用法代码示例。如果您正苦于以下问题:Java EV3ColorSensor.getRGBMode方法的具体用法?Java EV3ColorSensor.getRGBMode怎么用?Java EV3ColorSensor.getRGBMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lejos.hardware.sensor.EV3ColorSensor
的用法示例。
在下文中一共展示了EV3ColorSensor.getRGBMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import lejos.hardware.sensor.EV3ColorSensor; //导入方法依赖的package包/类
public static void main(String[] args) {
sensor = new EV3ColorSensor(SensorPort.S1);
sensor.setFloodlight(false);
LCD.drawString("Init", 2, 2);
LCD.setAutoRefresh(false);
brightnessSensorMode = sensor.getRGBMode();
float[] sample = new float[brightnessSensorMode.sampleSize()];
while(true) {
brightnessSensorMode.fetchSample(sample, 0);
LCD.refresh();
LCD.clear();
System.out.println("R: " + sample[0] + " G: " + sample[1] + " B: " + sample[2]);
LCD.drawString("R: " + sample[0], 1, 1);
LCD.drawString("G: " + sample[1], 1, 2);
LCD.drawString("B: " + sample[2], 1, 3);
}
}
示例2: main
import lejos.hardware.sensor.EV3ColorSensor; //导入方法依赖的package包/类
public static void main(String[] args) {
final EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
// Color sensor
EV3ColorSensor colorSensor = new EV3ColorSensor(SensorPort.S3);
SensorMode color = colorSensor.getRGBMode();
float[] colorSample = new float[color.sampleSize()];
lcd.drawInt(colorSample.length, 0, 2);
int key;
long startTime = System.currentTimeMillis();
long duration;
do {
duration = System.currentTimeMillis() - startTime;
color.fetchSample(colorSample, 0);
lcd.drawString("" + colorSample[0], 0, 3);
lcd.drawString("" + colorSample[1], 0, 4);
lcd.drawString("" + colorSample[2], 0, 5);
lcd.drawString("" + isReflecting(colorSample), 0, 6);
// key = keys.waitForAnyPress();
} while (duration < 60000);
}
示例3: setupColorSensor
import lejos.hardware.sensor.EV3ColorSensor; //导入方法依赖的package包/类
private void setupColorSensor() {
cSensor = new EV3ColorSensor(ev3.getPort("S2"));
colourSP = cSensor.getRGBMode();
colourSample = new float[colourSP.sampleSize()];
}