当前位置: 首页>>代码示例>>Java>>正文


Java PwmOutput类代码示例

本文整理汇总了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;
}
 
开发者ID:jrieke,项目名称:ioiometer,代码行数:39,代码来源:IOIOImpl.java

示例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;
}
 
开发者ID:smartebikes,项目名称:SmartEbikesMonitorSystem,代码行数:39,代码来源:IOIOImpl.java

示例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);
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:6,代码来源:PIOIO.java

示例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);
}
 
开发者ID:flyver,项目名称:Flyver-Apps,代码行数:6,代码来源:IOIOImpl.java

示例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);
}
 
开发者ID:edarn,项目名称:kryp-client,代码行数:6,代码来源:IOIOImpl.java


注:本文中的ioio.lib.api.PwmOutput类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。