本文整理汇总了Java中lejos.hardware.sensor.EV3TouchSensor.getTouchMode方法的典型用法代码示例。如果您正苦于以下问题:Java EV3TouchSensor.getTouchMode方法的具体用法?Java EV3TouchSensor.getTouchMode怎么用?Java EV3TouchSensor.getTouchMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lejos.hardware.sensor.EV3TouchSensor
的用法示例。
在下文中一共展示了EV3TouchSensor.getTouchMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import lejos.hardware.sensor.EV3TouchSensor; //导入方法依赖的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();
}
示例2: SimpleEV3TouchSensor
import lejos.hardware.sensor.EV3TouchSensor; //导入方法依赖的package包/类
public SimpleEV3TouchSensor(Port port) {
delegate = new EV3TouchSensor(port);
logger = SensorMonitorFactory.getLogger(port);
// Touch mode
touchMode = delegate.getTouchMode();
touchSample = new float[touchMode.sampleSize()];
}
示例3: main
import lejos.hardware.sensor.EV3TouchSensor; //导入方法依赖的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();
}