本文整理汇总了Java中ioio.lib.api.DigitalOutput.Spec方法的典型用法代码示例。如果您正苦于以下问题:Java DigitalOutput.Spec方法的具体用法?Java DigitalOutput.Spec怎么用?Java DigitalOutput.Spec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ioio.lib.api.DigitalOutput
的用法示例。
在下文中一共展示了DigitalOutput.Spec方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openDigitalOutput
import ioio.lib.api.DigitalOutput; //导入方法依赖的package包/类
@Override
synchronized public DigitalOutput openDigitalOutput(
DigitalOutput.Spec spec, boolean startValue)
throws ConnectionLostException {
checkState();
hardware_.checkValidPin(spec.pin);
checkPinFree(spec.pin);
DigitalOutputImpl result = new DigitalOutputImpl(this, spec.pin, startValue);
addDisconnectListener(result);
openPins_[spec.pin] = true;
try {
protocol_.setPinDigitalOut(spec.pin, startValue, spec.mode);
} catch (IOException e) {
result.close();
throw new ConnectionLostException(e);
}
return result;
}
示例2: openDigitalOutput
import ioio.lib.api.DigitalOutput; //导入方法依赖的package包/类
@Override
synchronized public DigitalOutput openDigitalOutput(
DigitalOutput.Spec spec, boolean startValue)
throws ConnectionLostException {
checkState();
Resource pin = new Resource(ResourceType.PIN, spec.pin);
resourceManager_.alloc(pin);
DigitalOutputImpl result = new DigitalOutputImpl(this, pin, startValue);
addDisconnectListener(result);
try {
protocol_.setPinDigitalOut(spec.pin, startValue, spec.mode);
} catch (IOException e) {
result.close();
throw new ConnectionLostException(e);
}
return result;
}
示例3: openDigitalOutput
import ioio.lib.api.DigitalOutput; //导入方法依赖的package包/类
@Override
synchronized public DigitalOutput openDigitalOutput(
DigitalOutput.Spec spec, boolean startValue)
throws ConnectionLostException {
checkState();
PinFunctionMap.checkValidPin(spec.pin);
checkPinFree(spec.pin);
DigitalOutputImpl result = new DigitalOutputImpl(this, spec.pin, startValue);
addDisconnectListener(result);
openPins_[spec.pin] = true;
try {
protocol_.setPinDigitalOut(spec.pin, startValue, spec.mode);
} catch (IOException e) {
result.close();
throw new ConnectionLostException(e);
}
return result;
}
示例4: openDigitalOutput
import ioio.lib.api.DigitalOutput; //导入方法依赖的package包/类
@Override
synchronized public DigitalOutput openDigitalOutput(
DigitalOutput.Spec spec, boolean startValue)
throws ConnectionLostException {
checkState();
Resource pin = new Resource(ResourceType.PIN, spec.pin);
resourceManager_.alloc(pin);
DigitalOutputImpl result = new DigitalOutputImpl(this, pin, startValue);
addDisconnectListener(result);
try {
protocol_.setPinDigitalOut(spec.pin, startValue, spec.mode);
} catch (IOException e) {
result.close();
throw new ConnectionLostException(e);
}
return result;
}
示例5: openPwmOutput
import ioio.lib.api.DigitalOutput; //导入方法依赖的package包/类
@Override
synchronized public PwmOutput openPwmOutput(DigitalOutput.Spec spec,
int freqHz) throws ConnectionLostException {
checkState();
hardware_.checkSupportsPeripheralOutput(spec.pin);
checkPinFree(spec.pin);
int pwmNum = pwmAllocator_.allocateModule();
int scale = 0;
float baseUs;
int period;
while (true) {
final int clk = 16000000 / IOIOProtocol.PwmScale.values()[scale].scale;
period = clk / freqHz;
if (period <= 65536) {
baseUs = 1000000.0f / clk;
break;
}
if (++scale >= PwmScale.values().length) {
throw new IllegalArgumentException("Frequency too low: "
+ freqHz);
}
}
PwmImpl pwm = new PwmImpl(this, spec.pin, pwmNum, period, baseUs);
addDisconnectListener(pwm);
openPins_[spec.pin] = true;
try {
protocol_.setPinDigitalOut(spec.pin, false, spec.mode);
protocol_.setPinPwm(spec.pin, pwmNum, true);
protocol_.setPwmPeriod(pwmNum, period - 1,
IOIOProtocol.PwmScale.values()[scale]);
} catch (IOException e) {
pwm.close();
throw new ConnectionLostException(e);
}
return pwm;
}
示例6: openSpiMaster
import ioio.lib.api.DigitalOutput; //导入方法依赖的package包/类
@Override
public SpiMaster openSpiMaster(int miso, int mosi, int clk,
int[] slaveSelect, SpiMaster.Rate rate)
throws ConnectionLostException {
DigitalOutput.Spec[] slaveSpecs = new DigitalOutput.Spec[slaveSelect.length];
for (int i = 0; i < slaveSelect.length; ++i) {
slaveSpecs[i] = new DigitalOutput.Spec(slaveSelect[i]);
}
return openSpiMaster(new DigitalInput.Spec(miso, Mode.PULL_UP),
new DigitalOutput.Spec(mosi), new DigitalOutput.Spec(clk),
slaveSpecs, new SpiMaster.Config(rate));
}
示例7: openSpiMaster
import ioio.lib.api.DigitalOutput; //导入方法依赖的package包/类
@Override
public SpiMaster openSpiMaster(int miso, int mosi, int clk,
int[] slaveSelect, SpiMaster.Rate rate)
throws ConnectionLostException {
DigitalOutput.Spec[] slaveSpecs = new DigitalOutput.Spec[slaveSelect.length];
for (int i = 0; i < slaveSelect.length; ++i) {
slaveSpecs[i] = new DigitalOutput.Spec(slaveSelect[i]);
}
return openSpiMaster(new DigitalInput.Spec(miso, Mode.PULL_UP),
new DigitalOutput.Spec(mosi), new DigitalOutput.Spec(clk),
slaveSpecs, new SpiMaster.Config(rate));
}
示例8: ChannelOutCompare
import ioio.lib.api.DigitalOutput; //导入方法依赖的package包/类
protected ChannelOutCompare(DigitalOutput.Spec[] specs) {
specs_ = specs;
oc_ = new Resource(ResourceType.OUTCOMPARE);
ocs_.add(oc_);
for (DigitalOutput.Spec spec : specs) {
ioio_.hardware_.checkSupportsPeripheralOutput(spec.pin);
pins_.add(new Resource(ResourceType.PIN, spec.pin));
}
}
示例9: openPins
import ioio.lib.api.DigitalOutput; //导入方法依赖的package包/类
@Override
public final void openPins() throws ConnectionLostException {
try {
for (DigitalOutput.Spec spec : specs_) {
ioio_.protocol_.setPinDigitalOut(spec.pin, false, spec.mode);
ioio_.protocol_.setPinPwm(spec.pin, oc_.id, true);
}
} catch (IOException e) {
throw new ConnectionLostException(e);
}
}
示例10: openPwmOutput
import ioio.lib.api.DigitalOutput; //导入方法依赖的package包/类
@Override
synchronized public PwmOutput openPwmOutput(DigitalOutput.Spec spec,
int freqHz) throws ConnectionLostException {
checkState();
PinFunctionMap.checkSupportsPeripheralOutput(spec.pin);
checkPinFree(spec.pin);
int pwmNum = pwmAllocator_.allocateModule();
int scale = 0;
float baseUs;
int period;
while (true) {
final int clk = 16000000 / IOIOProtocol.PwmScale.values()[scale].scale;
period = clk / freqHz;
if (period <= 65536) {
baseUs = 1000000.0f / clk;
break;
}
if (++scale >= PwmScale.values().length) {
throw new IllegalArgumentException("Frequency too low: "
+ freqHz);
}
}
PwmImpl pwm = new PwmImpl(this, spec.pin, pwmNum, period, baseUs);
addDisconnectListener(pwm);
openPins_[spec.pin] = true;
try {
protocol_.setPinDigitalOut(spec.pin, false, spec.mode);
protocol_.setPinPwm(spec.pin, pwmNum, true);
protocol_.setPwmPeriod(pwmNum, period - 1,
IOIOProtocol.PwmScale.values()[scale]);
} catch (IOException e) {
pwm.close();
throw new ConnectionLostException(e);
}
return pwm;
}
示例11: ChannelOutCompare
import ioio.lib.api.DigitalOutput; //导入方法依赖的package包/类
protected ChannelOutCompare(DigitalOutput.Spec[] specs) {
specs_ = specs;
oc_ = new Resource(ResourceType.OUTCOMPARE);
ocs_.add(oc_);
for (DigitalOutput.Spec spec : specs) {
ioio_.hardware_.checkSupportsPeripheralOutput(spec.pin);
pins_.add(new Resource(ResourceType.PIN, spec.pin));
}
}
示例12: openPins
import ioio.lib.api.DigitalOutput; //导入方法依赖的package包/类
@Override
public final void openPins() throws ConnectionLostException {
try {
for (DigitalOutput.Spec spec : specs_) {
ioio_.protocol_.setPinDigitalOut(spec.pin, false, spec.mode);
ioio_.protocol_.setPinPwm(spec.pin, oc_.id, true);
}
} catch (IOException e) {
throw new ConnectionLostException(e);
}
}
示例13: openUart
import ioio.lib.api.DigitalOutput; //导入方法依赖的package包/类
@Override
synchronized public Uart openUart(DigitalInput.Spec rx,
DigitalOutput.Spec tx, int baud, Uart.Parity parity,
Uart.StopBits stopbits) throws ConnectionLostException {
checkState();
if (rx != null) {
hardware_.checkSupportsPeripheralInput(rx.pin);
checkPinFree(rx.pin);
}
if (tx != null) {
hardware_.checkSupportsPeripheralOutput(tx.pin);
checkPinFree(tx.pin);
}
int rxPin = rx != null ? rx.pin : INVALID_PIN;
int txPin = tx != null ? tx.pin : INVALID_PIN;
int uartNum = uartAllocator_.allocateModule();
UartImpl uart = new UartImpl(this, txPin, rxPin, uartNum);
addDisconnectListener(uart);
incomingState_.addUartListener(uartNum, uart);
try {
if (rx != null) {
openPins_[rx.pin] = true;
protocol_.setPinDigitalIn(rx.pin, rx.mode);
protocol_.setPinUart(rx.pin, uartNum, false, true);
}
if (tx != null) {
openPins_[tx.pin] = true;
protocol_.setPinDigitalOut(tx.pin, true, tx.mode);
protocol_.setPinUart(tx.pin, uartNum, true, true);
}
boolean speed4x = true;
int rate = Math.round(4000000.0f / baud) - 1;
if (rate > 65535) {
speed4x = false;
rate = Math.round(1000000.0f / baud) - 1;
}
protocol_.uartConfigure(uartNum, rate, speed4x, stopbits, parity);
} catch (IOException e) {
uart.close();
throw new ConnectionLostException(e);
}
return uart;
}
示例14: openUart
import ioio.lib.api.DigitalOutput; //导入方法依赖的package包/类
@Override
synchronized public Uart openUart(DigitalInput.Spec rx,
DigitalOutput.Spec tx, int baud, Uart.Parity parity,
Uart.StopBits stopbits) throws ConnectionLostException {
checkState();
if (rx != null) {
hardware_.checkSupportsPeripheralInput(rx.pin);
}
if (tx != null) {
hardware_.checkSupportsPeripheralOutput(tx.pin);
}
Resource rxPin = rx != null ? new Resource(ResourceType.PIN, rx.pin)
: null;
Resource txPin = tx != null ? new Resource(ResourceType.PIN, tx.pin)
: null;
Resource uart = new Resource(ResourceType.UART);
resourceManager_.alloc(rxPin, txPin, uart);
UartImpl result = new UartImpl(this, txPin, rxPin, uart);
addDisconnectListener(result);
incomingState_.addUartListener(uart.id, result);
try {
if (rx != null) {
protocol_.setPinDigitalIn(rx.pin, rx.mode);
protocol_.setPinUart(rx.pin, uart.id, false, true);
}
if (tx != null) {
protocol_.setPinDigitalOut(tx.pin, true, tx.mode);
protocol_.setPinUart(tx.pin, uart.id, true, true);
}
boolean speed4x = true;
int rate = Math.round(4000000.0f / baud) - 1;
if (rate > 65535) {
speed4x = false;
rate = Math.round(1000000.0f / baud) - 1;
}
protocol_.uartConfigure(uart.id, rate, speed4x, stopbits, parity);
} catch (IOException e) {
result.close();
throw new ConnectionLostException(e);
}
return result;
}
示例15: openUart
import ioio.lib.api.DigitalOutput; //导入方法依赖的package包/类
@Override
synchronized public Uart openUart(DigitalInput.Spec rx,
DigitalOutput.Spec tx, int baud, Uart.Parity parity,
Uart.StopBits stopbits) throws ConnectionLostException {
checkState();
if (rx != null) {
PinFunctionMap.checkSupportsPeripheralInput(rx.pin);
checkPinFree(rx.pin);
}
if (tx != null) {
PinFunctionMap.checkSupportsPeripheralOutput(tx.pin);
checkPinFree(tx.pin);
}
int rxPin = rx != null ? rx.pin : INVALID_PIN;
int txPin = tx != null ? tx.pin : INVALID_PIN;
int uartNum = uartAllocator_.allocateModule();
UartImpl uart = new UartImpl(this, txPin, rxPin, uartNum);
addDisconnectListener(uart);
incomingState_.addUartListener(uartNum, uart);
try {
if (rx != null) {
openPins_[rx.pin] = true;
protocol_.setPinDigitalIn(rx.pin, rx.mode);
protocol_.setPinUart(rx.pin, uartNum, false, true);
}
if (tx != null) {
openPins_[tx.pin] = true;
protocol_.setPinDigitalOut(tx.pin, true, tx.mode);
protocol_.setPinUart(tx.pin, uartNum, true, true);
}
boolean speed4x = true;
int rate = Math.round(4000000.0f / baud) - 1;
if (rate > 65535) {
speed4x = false;
rate = Math.round(1000000.0f / baud) - 1;
}
protocol_.uartConfigure(uartNum, rate, speed4x, stopbits, parity);
} catch (IOException e) {
uart.close();
throw new ConnectionLostException(e);
}
return uart;
}