本文整理汇总了Java中lejos.hardware.port.Port.open方法的典型用法代码示例。如果您正苦于以下问题:Java Port.open方法的具体用法?Java Port.open怎么用?Java Port.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lejos.hardware.port.Port
的用法示例。
在下文中一共展示了Port.open方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resetMotors
import lejos.hardware.port.Port; //导入方法依赖的package包/类
/**
* Reset all motors to zero power and float state
* and reset tacho counts
*/
public static void resetMotors() {
for ( String portName : new String[] {
"A",
"B",
"C",
"D"
} ) {
Port p = LocalEV3.get().getPort(portName);
TachoMotorPort mp = p.open(TachoMotorPort.class);
mp.controlMotor(0, BasicMotorPort.FLOAT);
mp.resetTachoCount();
mp.close();
}
}
示例2: I2CSensor
import lejos.hardware.port.Port; //导入方法依赖的package包/类
/**
* Create the sensor using the specified port. Configure the hardware as required.
* @param port port the sensor is attached to
* @param address I2C address
* @param type type of I2C sensor
*/
public I2CSensor(Port port, int address, int type)
{
this(port.open(I2CPort.class), address);
releaseOnClose(this.port);
// Set the EV3 pins up.
if (type == TYPE_LOWSPEED_9V)
this.port.setPinMode(EV3SensorConstants.CMD_SET | EV3SensorConstants.CMD_PIN1);
else
this.port.setPinMode(EV3SensorConstants.CMD_SET);
}
示例3: NXTRegulatedMotor
import lejos.hardware.port.Port; //导入方法依赖的package包/类
/**
* Use this constructor to assign a variable of type motor connected to a particular port.
* @param port to which this motor is connected
*/
public NXTRegulatedMotor(Port port)
{
this(port.open(TachoMotorPort.class));
releaseOnClose(tachoPort);
}
示例4: RCXMotor
import lejos.hardware.port.Port; //导入方法依赖的package包/类
public RCXMotor(Port port)
{
this(port.open(BasicMotorPort.class));
releaseOnClose(this.port);
}
示例5: UARTSensor
import lejos.hardware.port.Port; //导入方法依赖的package包/类
/**
* Create the sensor object and switch to the selected mode
* @param port The port the sensor is attached to.
* @param mode Operating mode for the sensor.
*/
public UARTSensor(Port port, int mode)
{
this(port.open(UARTPort.class), mode);
releaseOnClose(this.port);
}
示例6: AnalogSensor
import lejos.hardware.port.Port; //导入方法依赖的package包/类
public AnalogSensor(Port p)
{
this(p.open(AnalogPort.class));
releaseOnClose(this.port);
}
示例7: NXTMotor
import lejos.hardware.port.Port; //导入方法依赖的package包/类
/**
* Create an instance of a NXTMotor using the specified motor port and
* PWM operating mode.
* @param port The motor port that the motor will be attached to.
* @param PWMMode see {@link lejos.hardware.port.BasicMotorPort#PWM_FLOAT} and see {@link lejos.hardware.port.BasicMotorPort#PWM_BRAKE}
*/
public NXTMotor(Port port, int PWMMode)
{
this(port.open(TachoMotorPort.class), PWMMode);
releaseOnClose(this.port);
}