本文整理汇总了Java中lejos.robotics.Color类的典型用法代码示例。如果您正苦于以下问题:Java Color类的具体用法?Java Color怎么用?Java Color使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Color类属于lejos.robotics包,在下文中一共展示了Color类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import lejos.robotics.Color; //导入依赖的package包/类
public static void main(final String[] args) {
LOG.info("Starting robot");
setupShutdownHooks();
clearLCD();
lcd.setFont(new Font(MONOSPACED, PLAIN, 10));
lcd.setColor(Color.BLACK);
lcd.drawString("Hello Lego!", 10, 10, 0);
lcd.refresh();
LOG.info("Hello Lego!");
Button.waitForAnyPress();
final AtomicBoolean paused = new AtomicBoolean(false);
setupRobotControlListeners(paused);
final Behavior[] behaviors = { new DriveForwardBehavior(paused, leftMotor, rightMotor),
new FindRedBehavior(colorSensor, leftMotor, rightMotor, paused),
new BackOffBehavior(irSensor, leftMotor, rightMotor, paused) };
final Arbitrator arbitrator = new Arbitrator(behaviors);
LOG.info("Launching behaviors");
arbitrator.go();
LOG.warn("Arbitrator quit.");
clearLCD();
LOG.info("Shutting down.");
}
开发者ID:jweijers,项目名称:EV3-robots,代码行数:24,代码来源:App.java
示例2: ColorSensor
import lejos.robotics.Color; //导入依赖的package包/类
ColorSensor(Port port) {
colorId = Observable.using(
() -> createSensor(port),
sensor -> new Sampler(() -> sensor.getColorIDMode()).sample(),
sensor -> closeSensor(sensor)
)
.share()
.map(sample -> sample.values[sample.offset])
.map(ColorId::colorId)
.distinctUntilChanged();
this.color = Observable.using(
() -> createSensor(port),
sensor -> new Sampler(() -> sensor.getRGBMode()).sample(),
sensor -> closeSensor(sensor)
)
.share()
.map(sample -> new Color(
Math.round(sample.values[sample.offset]),
Math.round(sample.values[sample.offset + 1]),
Math.round(sample.values[sample.offset + 2])))
.distinctUntilChanged(color ->
"r: " + color.getRed() +
", g: " + color.getGreen() +
", b: " + color.getBlue() );
}
开发者ID:bdeneuter,项目名称:rx-mindstorms,代码行数:27,代码来源:ColorSensor.java
示例3: setFloodlight
import lejos.robotics.Color; //导入依赖的package包/类
/** {@inheritDoc}
*/
@Override
public boolean setFloodlight(int color)
{
String mode;
switch (color) {
case Color.BLUE:
mode = COL_AMBIENT;
break;
case Color.WHITE:
mode = COL_COLOR;
break;
case Color.RED:
mode = COL_REFLECT;
break;
case Color.NONE:
mode = COL_RESET;
break;
default:
// TODO: Should we ignore a wrong color or throw an exception?
throw new IllegalArgumentException("Invalid color specified");
}
switchMode(mode, SWITCH_DELAY);
return true;
}
开发者ID:ev3dev-lang-java,项目名称:ev3dev-lang-java,代码行数:27,代码来源:EV3ColorSensor.java
示例4: setFloodlight
import lejos.robotics.Color; //导入依赖的package包/类
/** {@inheritDoc}
*/
@Override
public boolean setFloodlight(int color)
{
int mode;
switch (color)
{
case Color.BLUE:
mode = COL_AMBIENT;
break;
case Color.WHITE:
mode = COL_COLOR;
break;
case Color.RED:
mode = COL_REFLECT;
break;
default:
// TODO: Should we ignore a wrong color or throw an exception?
throw new IllegalArgumentException("Invalid color specified");
}
switchMode(mode, SWITCH_DELAY);
// TODO Auto-generated method stub
return true;
}
开发者ID:SnakeSVx,项目名称:ev3,代码行数:26,代码来源:EV3ColorSensor.java
示例5: getColors
import lejos.robotics.Color; //导入依赖的package包/类
/**
* Get a list of all supported colors for the Mindstorms EV3 Color Sensor
* @return
*/
private String[] getColors() {
Field[] names = Color.class.getFields();
String[] list = new String[names.length];
for (int i = 0; i < list.length; i++) {
list[i] = names[i].getName();
}
return list;
}
开发者ID:magnusbae,项目名称:HelloBrick,代码行数:13,代码来源:EV3Helper.java
示例6: setFloodlight
import lejos.robotics.Color; //导入依赖的package包/类
public boolean setFloodlight(int color) {
if(color == Color.RED) {
setFloodlight(true);
return true;
} else if (color == Color.NONE) {
setFloodlight(false);
return true;
} else return false;
}
开发者ID:SnakeSVx,项目名称:ev3,代码行数:10,代码来源:NXTLightSensor.java
示例7: getColorID
import lejos.robotics.Color; //导入依赖的package包/类
/** {@inheritDoc}
*/
@Override
public int getColorID()
{
setFloodlight(Color.WHITE);
return colorMap[port.getByte()];
}
开发者ID:SnakeSVx,项目名称:ev3,代码行数:9,代码来源:EV3ColorSensor.java
示例8: convertColorToString
import lejos.robotics.Color; //导入依赖的package包/类
public static String convertColorToString(int colorID) {
switch (colorID) {
case Color.BLACK:
return "Black";
case Color.BLUE:
return "Blue";
case Color.CYAN:
return "Cyan";
case Color.DARK_GRAY:
return "Dark Gray";
case Color.GRAY:
return "Gray";
case Color.GREEN:
return "Green";
case Color.LIGHT_GRAY:
return "Light Gray";
case Color.MAGENTA:
return "Magenta";
case Color.NONE:
return "No Color";
case Color.ORANGE:
return "Orange";
case Color.PINK:
return "Pink";
case Color.RED:
return "Red";
case Color.WHITE:
return "White";
case Color.YELLOW:
return "Yellow";
default:
return "No Color";
}
}
开发者ID:tkr65536,项目名称:Remote-Debugger,代码行数:35,代码来源:TypeConverter.java
示例9: continueSearch
import lejos.robotics.Color; //导入依赖的package包/类
private boolean continueSearch() {
colorSampler.fetchSample(sample, 0);
final boolean takeControl = Color.RED != (int) sample[0] && !paused.get();
LOG.info("Continue search: {}", takeControl);
return takeControl;
}
开发者ID:jweijers,项目名称:EV3-robots,代码行数:7,代码来源:FindRedBehavior.java
示例10: takeControl
import lejos.robotics.Color; //导入依赖的package包/类
@Override
public boolean takeControl() {
colorSampler.fetchSample(sample, 0);
return Color.RED == (int) sample[0] && !paused.get();
}
开发者ID:jweijers,项目名称:EV3-robots,代码行数:6,代码来源:BeepOnRedBehavior.java
示例11: clearLCD
import lejos.robotics.Color; //导入依赖的package包/类
public static void clearLCD() {
lcd.setColor(Color.WHITE);
lcd.fillRect(0, 0, lcd.getWidth(), lcd.getHeight());
lcd.refresh();
}
开发者ID:jweijers,项目名称:EV3-robots,代码行数:6,代码来源:App.java
示例12: LineDetectors
import lejos.robotics.Color; //导入依赖的package包/类
public LineDetectors() {
this.leftSensor = new ColorSensor(SensorPort.S4, Color.RED);
this.rightSensor = new ColorSensor(SensorPort.S3, Color.RED);
this.lastDetectLeft = this.lastDetectRight = 0;
this.stopped = false;
}
开发者ID:yoann-dufresne,项目名称:AFIA_Robots,代码行数:7,代码来源:LineDetectors.java
示例13: main
import lejos.robotics.Color; //导入依赖的package包/类
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
EV3ColorSensor colorSensor = new EV3ColorSensor(SensorPort.S3);
SensorMode color = colorSensor.getColorIDMode();
float[] sample = new float[color.sampleSize()];
color.fetchSample(sample, 0);
int colorId = (int)sample[0];
String colorName = "";
switch(colorId){
case Color.NONE: colorName = "NONE"; break;
case Color.BLACK: colorName = "BLACK"; break;
case Color.BLUE: colorName = "BLUE"; break;
case Color.GREEN: colorName = "GREEN"; break;
case Color.YELLOW: colorName = "YELLOW"; break;
case Color.RED: colorName = "RED"; break;
case Color.WHITE: colorName = "WHITE"; break;
case Color.BROWN: colorName = "BROWN"; break;
}
lcd.drawString(colorId + " - " + colorName, 0, 0);
keys.waitForAnyPress();
// EV3TouchSensor touchSensor = new EV3TouchSensor(SensorPort.S1);
// SensorMode touch = touchSensor.getTouchMode();
// float[] sample = new float[touch.sampleSize()];
//
// RegulatedMotor mA = new EV3LargeRegulatedMotor(MotorPort.A);
// RegulatedMotor mB = new EV3LargeRegulatedMotor(MotorPort.B);
// RegulatedMotor mC = new EV3LargeRegulatedMotor(MotorPort.C);
// mA.resetTachoCount();
// mB.resetTachoCount();
// mC.resetTachoCount();
//
// mA.rotateTo(760);
// int angle = mA.getTachoCount(); // should be -360
// lcd.drawInt(angle, 0, 0);
// keys.waitForAnyPress();
//
// mB.setSpeed(720);// 2 RPM
// mC.setSpeed(720);
// mB.forward();
// mC.forward();
// Delay.msDelay(1000);
// mB.stop();
// mC.stop();
// mB.rotateTo(360);
// mB.rotate(-720, true);
// while (mB.isMoving())
// Thread.yield();
// angle = mB.getTachoCount();
// lcd.drawInt(angle, 0, 1);
//
// mA.rotateTo(-100, true);
// do{
// touch.fetchSample(sample, 0);
// } while (mA.isMoving() && sample[0] == 0);
// mA.stop();
//
// angle = mA.getTachoCount(); // should be -360
// lcd.drawInt(angle, 0, 2);
// keys.waitForAnyPress();
}
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:65,代码来源:MotorDemo04.java
示例14: getColorID
import lejos.robotics.Color; //导入依赖的package包/类
/** {@inheritDoc}
*/
@Override
public int getColorID() {
setFloodlight(Color.WHITE);
return 0; //colorMap[ports.getByte()];
}
开发者ID:ev3dev-lang-java,项目名称:ev3dev-lang-java,代码行数:8,代码来源:EV3ColorSensor.java
示例15: isFloodlightOn
import lejos.robotics.Color; //导入依赖的package包/类
/** {@inheritDoc}
*/
@Override
public boolean isFloodlightOn()
{
return lightColor[currentMode+1] != Color.NONE;
}
开发者ID:ev3dev-lang-java,项目名称:ev3dev-lang-java,代码行数:8,代码来源:EV3ColorSensor.java
示例16: isNoColor
import lejos.robotics.Color; //导入依赖的package包/类
@ScriptApi
public boolean isNoColor() {
return value == Color.NONE;
}
开发者ID:jbenech,项目名称:gnikrap,代码行数:5,代码来源:SimpleEV3ColorSensor.java
示例17: isBlack
import lejos.robotics.Color; //导入依赖的package包/类
@ScriptApi
public boolean isBlack() {
return value == Color.BLACK;
}
开发者ID:jbenech,项目名称:gnikrap,代码行数:5,代码来源:SimpleEV3ColorSensor.java
示例18: isBlue
import lejos.robotics.Color; //导入依赖的package包/类
@ScriptApi
public boolean isBlue() {
return value == Color.BLUE;
}
开发者ID:jbenech,项目名称:gnikrap,代码行数:5,代码来源:SimpleEV3ColorSensor.java
示例19: isGreen
import lejos.robotics.Color; //导入依赖的package包/类
@ScriptApi
public boolean isGreen() {
return value == Color.GREEN;
}
开发者ID:jbenech,项目名称:gnikrap,代码行数:5,代码来源:SimpleEV3ColorSensor.java
示例20: isYellow
import lejos.robotics.Color; //导入依赖的package包/类
@ScriptApi
public boolean isYellow() {
return value == Color.YELLOW;
}
开发者ID:jbenech,项目名称:gnikrap,代码行数:5,代码来源:SimpleEV3ColorSensor.java
注:本文中的lejos.robotics.Color类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论