本文整理汇总了Java中com.qualcomm.robotcore.hardware.LightSensor类的典型用法代码示例。如果您正苦于以下问题:Java LightSensor类的具体用法?Java LightSensor怎么用?Java LightSensor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LightSensor类属于com.qualcomm.robotcore.hardware包,在下文中一共展示了LightSensor类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDeviceMaps
import com.qualcomm.robotcore.hardware.LightSensor; //导入依赖的package包/类
/**
* Move the propriety {@link HardwareMap.DeviceMapping} to our {@link DeviceMap} for our
* internal use
*/
private void createDeviceMaps() {
fullMap.checkedPut(DcMotorController.class, new DeviceMap<>(basicMap.dcMotorController));
fullMap.checkedPut(DcMotor.class, new DeviceMap<>(basicMap.dcMotor));
fullMap.checkedPut(ServoController.class, new DeviceMap<>(basicMap.servoController));
fullMap.checkedPut(Servo.class, new DeviceMap<>(basicMap.servo));
fullMap.checkedPut(LegacyModule.class, new DeviceMap<>(basicMap.legacyModule));
fullMap.checkedPut(TouchSensorMultiplexer.class, new DeviceMap<>(basicMap.touchSensorMultiplexer));
fullMap.checkedPut(DeviceInterfaceModule.class, new DeviceMap<>(basicMap.deviceInterfaceModule));
fullMap.checkedPut(AnalogInput.class, new DeviceMap<>(basicMap.analogInput));
fullMap.checkedPut(DigitalChannel.class, new DeviceMap<>(basicMap.digitalChannel));
fullMap.checkedPut(OpticalDistanceSensor.class, new DeviceMap<>(basicMap.opticalDistanceSensor));
fullMap.checkedPut(TouchSensor.class, new DeviceMap<>(basicMap.touchSensor));
fullMap.checkedPut(PWMOutput.class, new DeviceMap<>(basicMap.pwmOutput));
fullMap.checkedPut(I2cDevice.class, new DeviceMap<>(basicMap.i2cDevice));
fullMap.checkedPut(AnalogOutput.class, new DeviceMap<>(basicMap.analogOutput));
fullMap.checkedPut(ColorSensor.class, new DeviceMap<>(basicMap.colorSensor));
fullMap.checkedPut(LED.class, new DeviceMap<>(basicMap.led));
fullMap.checkedPut(AccelerationSensor.class, new DeviceMap<>(basicMap.accelerationSensor));
fullMap.checkedPut(CompassSensor.class, new DeviceMap<>(basicMap.compassSensor));
fullMap.checkedPut(GyroSensor.class, new DeviceMap<>(basicMap.gyroSensor));
fullMap.checkedPut(IrSeekerSensor.class, new DeviceMap<>(basicMap.irSeekerSensor));
fullMap.checkedPut(LightSensor.class, new DeviceMap<>(basicMap.lightSensor));
fullMap.checkedPut(UltrasonicSensor.class, new DeviceMap<>(basicMap.ultrasonicSensor));
fullMap.checkedPut(VoltageSensor.class, new DeviceMap<>(basicMap.voltageSensor));
LinkedHashMultimap<DcMotorController, DcMotor> multimap = LinkedHashMultimap.create();
for (DcMotor motor : dcMotors()) {
multimap.put(motor.getController(), motor);
}
}
示例2: runOpMode
import com.qualcomm.robotcore.hardware.LightSensor; //导入依赖的package包/类
@Override
public void runOpMode() {
// bPrevState and bCurrState represent the previous and current state of the button.
boolean bPrevState = false;
boolean bCurrState = false;
// bLedOn represents the state of the LED.
boolean bLedOn = true;
// get a reference to our Light Sensor object.
lightSensor = hardwareMap.get(LightSensor.class, "sensor_light");
// Set the LED state in the beginning.
lightSensor.enableLed(bLedOn);
// wait for the start button to be pressed.
waitForStart();
// while the op mode is active, loop and read the light levels.
// Note we use opModeIsActive() as our loop condition because it is an interruptible method.
while (opModeIsActive()) {
// check the status of the x button .
bCurrState = gamepad1.x;
// check for button state transitions.
if ((bCurrState == true) && (bCurrState != bPrevState)) {
// button is transitioning to a pressed state. Toggle LED
bLedOn = !bLedOn;
lightSensor.enableLed(bLedOn);
}
// update previous state variable.
bPrevState = bCurrState;
// send the info back to driver station using telemetry function.
telemetry.addData("LED", bLedOn ? "On" : "Off");
telemetry.addData("Raw", lightSensor.getRawLightDetected());
telemetry.addData("Normal", lightSensor.getLightDetected());
telemetry.update();
}
}
示例3: mapNxtLightSensor
import com.qualcomm.robotcore.hardware.LightSensor; //导入依赖的package包/类
private void mapNxtLightSensor(HardwareMap map, DeviceManager deviceMgr, LegacyModule legacyModule, DeviceConfiguration devConf) {
if (!devConf.isEnabled()) return;
LightSensor light = deviceMgr.createNxtLightSensor(legacyModule, devConf.getPort());
map.lightSensor.put(devConf.getName(), light);
}
示例4: lightSensors
import com.qualcomm.robotcore.hardware.LightSensor; //导入依赖的package包/类
/**
* Returns a {@link DeviceMap<LightSensor>} for use to access Light Sensor hardware
*
* @return a DeviceMap to use for access to representations of Light Sensors
* @see DeviceMap
* @see LightSensor
*/
public DeviceMap<LightSensor> lightSensors() {
return fullMap.checkedGet(LightSensor.class);
}