本文整理汇总了Java中ioio.lib.api.PwmOutput类的典型用法代码示例。如果您正苦于以下问题:Java PwmOutput类的具体用法?Java PwmOutput怎么用?Java PwmOutput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PwmOutput类属于ioio.lib.api包,在下文中一共展示了PwmOutput类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openPwmOutput
import ioio.lib.api.PwmOutput; //导入依赖的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;
}
示例2: openPwmOutput
import ioio.lib.api.PwmOutput; //导入依赖的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;
}
示例3: openPWMOutput
import ioio.lib.api.PwmOutput; //导入依赖的package包/类
@ProtoMethod(description = "", example = "")
@ProtoMethodParam(params = {"pinNumber", "frequency"})
public PwmOutput openPWMOutput(int pinNum, int freq) throws ConnectionLostException {
return mIoio.openPwmOutput(pinNum, freq);
}
示例4: openPwmOutput
import ioio.lib.api.PwmOutput; //导入依赖的package包/类
@Override
public PwmOutput openPwmOutput(int pin, int freqHz)
throws ConnectionLostException {
return openPwmOutput(new DigitalOutput.Spec(pin), freqHz);
}
示例5: openPwmOutput
import ioio.lib.api.PwmOutput; //导入依赖的package包/类
@Override
public PwmOutput openPwmOutput(int pin, int freqHz)
throws ConnectionLostException {
return openPwmOutput(new DigitalOutput.Spec(pin), freqHz);
}