本文整理汇总了Java中lejos.hardware.BrickFinder类的典型用法代码示例。如果您正苦于以下问题:Java BrickFinder类的具体用法?Java BrickFinder怎么用?Java BrickFinder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BrickFinder类属于lejos.hardware包,在下文中一共展示了BrickFinder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import lejos.hardware.BrickFinder; //导入依赖的package包/类
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
// File root = new File(".");
// String[] files = root.list();
// for(int i = 0; i < files.length; i++)
// lcd.drawString(files[i], 0, i);
Audio audio = ev3.getAudio();
audio.playSample(new File("hackathon.wav"), 100);
LCD.drawString("Enter to Exit", 0, 2);
Button.ENTER.waitForPressAndRelease();
// audio.playNote(Audio.XYLOPHONE, 420, 500);
// audio.playNote(Audio.XYLOPHONE, 510, 500);
// audio.playNote(Audio.XYLOPHONE, 420, 500);
// audio.playNote(Audio.XYLOPHONE, 640, 500);
// audio.playNote(Audio.XYLOPHONE, 220, 500);
// keys.waitForAnyPress();
}
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:25,代码来源:AudioDemo02.java
示例2: main
import lejos.hardware.BrickFinder; //导入依赖的package包/类
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
Motor.B.setSpeed(720);// 2 RPM
Motor.C.setSpeed(720);
Motor.B.forward();
Motor.C.forward();
Delay.msDelay(1000);
Motor.B.stop();
Motor.C.stop();
Motor.B.rotateTo(360);
Motor.B.rotate(-720, true);
while (Motor.B.isMoving())
Thread.yield();
int angle = Motor.B.getTachoCount(); // should be -360
LCD.drawInt(angle, 0, 0);
keys.waitForAnyEvent();
}
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:22,代码来源:MotorDemo02.java
示例3: main
import lejos.hardware.BrickFinder; //导入依赖的package包/类
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
EV3TouchSensor touchSensor = new EV3TouchSensor(SensorPort.S1);
SensorMode touch = touchSensor.getTouchMode();
float[] sample = new float[touch.sampleSize()];
RegulatedMotor m = new EV3LargeRegulatedMotor(MotorPort.A);
m.resetTachoCount();
m.rotateTo(320, true);
// int angle = m.getTachoCount(); // should be -360
// lcd.drawInt(angle, 0, 0);
// keys.waitForAnyPress();
// m.rotateTo(-100, true);
// do{
// touch.fetchSample(sample, 0);
// } while (sample[0] == 0);
while (m.isMoving())
Thread.yield();
m.stop();
int angle = m.getTachoCount(); // should be < -100
lcd.drawInt(angle, 0, 1);
// keys.waitForAnyPress();
}
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:32,代码来源:MotorDemo03.java
示例4: main
import lejos.hardware.BrickFinder; //导入依赖的package包/类
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
RegulatedMotor m = new EV3LargeRegulatedMotor(MotorPort.A);
m.resetTachoCount();
m.rotateTo(-40);
int angle = m.getTachoCount(); // should be 760
lcd.drawInt(angle, 0, 0);
// keys.waitForAnyPress();
// m.rotateTo(0);
// angle = m.getTachoCount(); // should be 0
// lcd.drawInt(angle, 0, 1);
// keys.waitForAnyPress(); // wait for a button press
m.close();
}
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:21,代码来源:MotorDemo01.java
示例5: main
import lejos.hardware.BrickFinder; //导入依赖的package包/类
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
// lcd.drawString("Hello Trayan", 4, 2);
// lcd.drawString("from leJOS", 4, 3);
// Move forward
RegulatedMotor mB = new EV3LargeRegulatedMotor(MotorPort.B);
RegulatedMotor mC = new EV3LargeRegulatedMotor(MotorPort.C);
mB.synchronizeWith(new RegulatedMotor[] { mC });
mB.startSynchronization();
mB.forward();
mC.forward();
mB.endSynchronization();
Delay.msDelay(3000);
mB.startSynchronization();
mB.stop();
mC.stop();
mB.endSynchronization();
// keys.waitForAnyPress(5000);
}
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:27,代码来源:MoveRobot.java
示例6: main
import lejos.hardware.BrickFinder; //导入依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
GraphicsLCD g = BrickFinder.getDefault().getGraphicsLCD();
final int SW = g.getWidth();
final int SH = g.getHeight();
Button.LEDPattern(4);
Sound.beepSequenceUp();
g.setFont(Font.getDefaultFont());
g.drawString("Lejos EV3 Gradle", SW/2, SH/2, GraphicsLCD.BASELINE|GraphicsLCD.HCENTER);
Button.LEDPattern(3);
Delay.msDelay(4000);
Button.LEDPattern(5);
g.clear();
g.refresh();
Sound.beepSequence();
Delay.msDelay(500);
Button.LEDPattern(0);
}
开发者ID:jornfranke,项目名称:lejos-ev3-example,代码行数:21,代码来源:RobotApplication.java
示例7: getEv3Host
import lejos.hardware.BrickFinder; //导入依赖的package包/类
private String getEv3Host() {
Logger logger = getLogger();
LejosEv3PluginExtension ev3 = getEv3PluginExtension();
String host;
if (ev3.discoverBrickEnabled()) {
BrickInfo brick;
try {
brick = BrickFinder.discover()[0];
} catch (IOException e) {
throw new GradleException("Error on discovering bricks", e);
}
logger.info("Found brick " + brick.getName() + " at " + brick.getIPAddress());
host = brick.getIPAddress();
} else {
if (ev3.getHost() == null) {
throw new GradleException("Please set property ev3.host");
}
host = ev3.getHost();
}
return host;
}
开发者ID:mindstorms-cop,项目名称:lejos-ev3-gradle-plugin,代码行数:22,代码来源:Ev3DeployTask.java
示例8: updateClockWhileEnterIsDown
import lejos.hardware.BrickFinder; //导入依赖的package包/类
private void updateClockWhileEnterIsDown(final Runnable action) {
LCD.clear();
final TextLCD timeLCD = BrickFinder.getDefault().getTextLCD(
Font.getLargeFont());
final ScheduledExecutorService executor = Executors
.newSingleThreadScheduledExecutor();
executor.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
action.run();
timeLCD.clear();
Ev3Utils.displayLargeText(timeLCD, clock.getTime().toString());
}
}, 0, 500, TimeUnit.MILLISECONDS);
Ev3Utils.waitTillEnterIsDown();
executor.shutdown();
try {
executor.awaitTermination(1, TimeUnit.SECONDS);
} catch (InterruptedException e) {
throw new RuntimeInterruptedException(e);
}
timeLCD.clear();
}
开发者ID:rafalmag,项目名称:EV3-projects,代码行数:26,代码来源:ClockSettingMenuController.java
示例9: Megatron
import lejos.hardware.BrickFinder; //导入依赖的package包/类
public Megatron() {
ev3 = BrickFinder.getDefault();
setupPilot();
setupColorSensor();
getColorName();
setupUltrasonicSensor();
setupServer();
stoppingThread = new StoppingThread(this);
stoppingThread.start();
while (true) {
try {
String command = input.readLine();
System.out.println("Command: " + command);
if (command.equals("get(color)")) {
pilot.travel(-MOVE_BACK_DISTANCE);
String theColor = getColorName();
pilot.travel(MOVE_BACK_DISTANCE);
if (theColor.equals(BLUE) || theColor.equals(RED) || theColor.equals(GREEN))
Sound.beep();
output.println(theColor);
} else if (command.equals("get(occupied)")) {
output.println(getOccupiedInfo());
} else if (command.startsWith("move")) {
String[] parameters = getParameters(command);
output.println(moveRelatively(parameters[0],parameters[1]));
firstStepFinished = true;
} else if (command.equals("end")) {
doCelebration();
output.println(DONE);
}
output.flush();
} catch (IOException e) {
}
}
}
开发者ID:JINKEHE,项目名称:Rescue-Victims,代码行数:36,代码来源:Megatron.java
示例10: main
import lejos.hardware.BrickFinder; //导入依赖的package包/类
public static void main(String[] args) {
brick = BrickFinder.getDefault();
GraphicsLCD g = brick.getGraphicsLCD();
Key enter = brick.getKey("Escape");
String[] sensorName = new String[4];
p[0] = brick.getPort("S1");
p[1] = brick.getPort("S2");
p[2] = brick.getPort("S3");
p[3] = brick.getPort("S4");
while ( enter.isUp() ) {
uDetected = false;
for ( int i = 0; i < sensorName.length; i++ ) {
sensorName[i] = getSensorName(i);
}
g.clear();
g.drawString("ESCAPE to quit", 0, 100, 0, true);
g.setFont(Font.getSmallFont());
g.drawString("B.", 165, 105, 0);
g.setFont(Font.getDefaultFont());
for ( int i = 0; i < sensorName.length; i++ ) {
g.drawString("Port " + (i + 1) + ": " + sensorName[i], 0, i * 20 + 20, 0);
}
if ( !uDetected ) {
Delay.msDelay(100);
}
}
}
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:30,代码来源:SensorTest.java
示例11: main
import lejos.hardware.BrickFinder; //导入依赖的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);
}
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:28,代码来源:ColorSensorTest.java
示例12: main
import lejos.hardware.BrickFinder; //导入依赖的package包/类
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
// lcd.drawString("Hello Trayan", 4, 2);
// lcd.drawString("from leJOS", 4, 3);
// Open clow
RegulatedMotor mA = new EV3LargeRegulatedMotor(MotorPort.A);
while (true) {
mA.resetTachoCount();
lcd.drawString("Up - Close", 4, 2);
lcd.drawString("Down - Open", 4, 3);
lcd.drawString("Escape - Exit", 4, 4);
// Simple menu
keys.waitForAnyPress(60000);
int maRotation = 0;
if (Button.DOWN.isDown()) {
maRotation = -620;
} else if (Button.UP.isDown()) {
maRotation = 620;
}
if (Button.ESCAPE.isDown()) {
System.exit(0);
}
mA.rotateTo(maRotation, false);
int count = mA.getTachoCount();
lcd.drawString("Tacho: " + count, 0, 2);
}
}
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:36,代码来源:MoveClaw.java
示例13: main
import lejos.hardware.BrickFinder; //导入依赖的package包/类
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
lcd.drawString("Hello Trayan", 4, 2);
lcd.drawString("from leJOS", 4, 3);
keys.waitForAnyPress(50000);
}
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:11,代码来源:HelloWorld.java
示例14: main
import lejos.hardware.BrickFinder; //导入依赖的package包/类
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
Audio audio = ev3.getAudio();
audio.setVolume(10);
audio.playNote(Audio.XYLOPHONE, 420, 500);
audio.playNote(Audio.XYLOPHONE, 510, 500);
audio.playNote(Audio.XYLOPHONE, 420, 500);
audio.playNote(Audio.XYLOPHONE, 640, 500);
audio.playNote(Audio.XYLOPHONE, 220, 500);
}
开发者ID:iproduct,项目名称:course-social-robotics,代码行数:16,代码来源:AudioDemo01.java
示例15: getDefault
import lejos.hardware.BrickFinder; //导入依赖的package包/类
/**
* Get the default desktop instance of local brick.
*/
public static Desktop getDefault() {
if(desktop == null)
desktop = new Desktop(BrickFinder.getDefault());
return desktop;
}
开发者ID:MisaZhu,项目名称:EV3GUI.leJOS,代码行数:10,代码来源:Desktop.java
示例16: stopApp
import lejos.hardware.BrickFinder; //导入依赖的package包/类
private void stopApp() {
clock.stop();
Button.LEDPattern(0);
LCD.clear();
Ev3Utils.displayLargeText(
BrickFinder.getDefault().getTextLCD(Font.getLargeFont()),
"Bye!");
log.info("bye");
}
开发者ID:rafalmag,项目名称:EV3-projects,代码行数:10,代码来源:MainWithMenu.java
示例17: displayTime
import lejos.hardware.BrickFinder; //导入依赖的package包/类
/**
* Displays time and waits for any button to be pressed.
*/
private void displayTime() {
TextLCD timeLCD = BrickFinder.getDefault().getTextLCD(
Font.getLargeFont());
LCD.clear();
do {
Ev3Utils.displayLargeText(timeLCD, clock.getTime().toString());
} while (Button.waitForAnyPress(TIMEOUT_MS) == 0);
timeLCD.clear();
}
开发者ID:rafalmag,项目名称:EV3-projects,代码行数:13,代码来源:MainMenuController.java
示例18: toolException
import lejos.hardware.BrickFinder; //导入依赖的package包/类
private void toolException(Throwable t) {
Sound.buzz();
TextLCD lcd = BrickFinder.getDefault().getTextLCD(Font.getSmallFont());
int offset = 0;
// Get rid of invocation exception
if ( t.getCause() != null ) {
t = t.getCause();
}
while ( true ) {
lcd.clear();
lcd.drawString("Tool exception:", offset, 1);
lcd.drawString(t.getClass().getName(), offset, 3);
if ( t.getMessage() != null ) {
lcd.drawString(t.getMessage(), offset, 4);
}
if ( t.getCause() != null ) {
lcd.drawString("Caused by:", offset, 5);
lcd.drawString(t.getCause().toString(), offset, 6);
}
StackTraceElement[] trace = t.getStackTrace();
for ( int i = 0; i < 7 && i < trace.length; i++ ) {
lcd.drawString(trace[i].toString(), offset, 8 + i);
}
lcd.refresh();
int id = Button.waitForAnyEvent();
if ( id == Button.ID_ESCAPE ) {
break;
}
if ( id == Button.ID_LEFT ) {
offset += 5;
}
if ( id == Button.ID_RIGHT ) {
offset -= 5;
}
if ( offset > 0 ) {
offset = 0;
}
}
lcd.clear();
}
开发者ID:OpenRoberta,项目名称:robertalab-ev3lejos-v0,代码行数:44,代码来源:GraphicStartup.java
示例19: main
import lejos.hardware.BrickFinder; //导入依赖的package包/类
public static void main(String[] args) {
EV3 ev3 = (EV3) BrickFinder.getLocal();
TextLCD lcd = ev3.getTextLCD();
Keys keys = ev3.getKeys();
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,代码行数:46,代码来源:MotorDemo06.java
示例20: main
import lejos.hardware.BrickFinder; //导入依赖的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
注:本文中的lejos.hardware.BrickFinder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论