本文整理汇总了Java中com.pi4j.device.piface.PiFace类的典型用法代码示例。如果您正苦于以下问题:Java PiFace类的具体用法?Java PiFace怎么用?Java PiFace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PiFace类属于com.pi4j.device.piface包,在下文中一共展示了PiFace类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: PiFaceButton
点赞 3
import com.pi4j.device.piface.PiFace; //导入依赖的package包/类
/**
* Constructs a software representation of a PiFace button.
*
* @param piFaceSwitch
* the switch of the PiFace to use.
* @throws IOException
*/
public PiFaceButton(PiFace piface, PiFaceSwitch piFaceSwitch) throws IOException {
// add a listener with the pi4j library to hide the library
piface.getSwitch(piFaceSwitch).addListener(new SwitchListener() {
@Override
public void onStateChange(SwitchStateChangeEvent event) {
if (event.getNewState() == SwitchState.ON) {
setState(ButtonState.ON);
} else {
setState(ButtonState.OFF);
}
}
});
}
开发者ID:SebiGo,
项目名称:BrewControlServer,
代码行数:23,
代码来源:PiFaceButton.java
示例2: main
点赞 2
import com.pi4j.device.piface.PiFace; //导入依赖的package包/类
/**
* The main method for BrewCrontol intended to start the standalone
* BrewControl server
*
* @param argv
* no arguments required, leave empty
* @throws Exception
*/
public static void main(String[] argv) throws Exception {
OperationMode opMode = null;
if (argv.length != 1) {
String modes = "";
for (OperationMode mode : OperationMode.values()) {
modes += mode.getCommandlineOption() + "|";
}
log.error("Please supply mode [" + modes.substring(0, modes.length() - 1) + "]");
return;
} else {
opMode = OperationMode.getModeFromCommandlineOption(argv[0]);
}
// pre set with some useful values
Mashing.getInstance().setName("BrewControl");
Mashing.getInstance().addRest(new Rest("Einmaischen", 57d, 0, Boolean.FALSE));
Mashing.getInstance().addRest(new Rest("Eiweissrast", 55d, 15, Boolean.TRUE));
Mashing.getInstance().addRest(new Rest("Maltoserast", 62d, 50, Boolean.TRUE));
Mashing.getInstance().addRest(new Rest("Verzuckerungsrast", 72d, 1, Boolean.FALSE));
Mashing.getInstance().addRest(new Rest("Abmaischen", 78d, 1, Boolean.FALSE));
Rest start = Mashing.getInstance().getRest();
while (start != null) {
log.info(start.getName() + " at " + start.getTemperature() + "" + PhysicalQuantity.TEMPERATURE.getUnit() + " for " + (start.getDuration())
+ " min (" + ((start.isContinueAutomatically()) ? "" : "don't ") + "continue automatically).");
start = start.getNextRest();
}
startServices();
switch (opMode) {
case SIMULATE:
Actuator a = new FakeActuator(PhysicalQuantity.TEMPERATURE);
Mashing.getInstance().initMashing(new FakeSensor(a), a, new FakeButton(), new VirtualButton());
break;
case GPIO:
SensorDS18B20 s1 = new SensorDS18B20();
s1.calibrate(0, 100, 0);
Mashing.getInstance().initMashing(s1, new GPIOActuator(RaspiPin.GPIO_04, PhysicalQuantity.TEMPERATURE), new VirtualButton(), new GPIOButton(RaspiPin.GPIO_01));
break;
case PIFACE:
final PiFace piface = new PiFaceDevice(PiFace.DEFAULT_ADDRESS, SpiChannel.CS0);
SensorDS18B20 s2 = new SensorDS18B20();
s2.calibrate(0, 100, 0);
Mashing.getInstance().initMashing(s2, new PiFaceRelayActuator(piface, PiFaceRelay.K0, PhysicalQuantity.TEMPERATURE), new VirtualButton(), new PiFaceButton(piface, PiFaceSwitch.S1));
break;
}
}
开发者ID:SebiGo,
项目名称:BrewControlServer,
代码行数:59,
代码来源:BrewControl.java
示例3: PiFaceRelayActuator
点赞 1
import com.pi4j.device.piface.PiFace; //导入依赖的package包/类
/**
* Constructs a new PiFace output connected Actuator.
*
* @param relay
* the PiFace relay the actuator is connected to.
* @param physicalQuantity
* the physical quantity this actuator regulates.
* @throws IOException
* if the supporting library throws an IOException.
*/
public PiFaceRelayActuator(PiFace piface, PiFaceRelay relay, PhysicalQuantity physicalQuantity) throws IOException {
super(physicalQuantity);
this.piface = piface;
this.relay = relay;
}
开发者ID:SebiGo,
项目名称:BrewControlServer,
代码行数:16,
代码来源:PiFaceRelayActuator.java