• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SoftPwm类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.pi4j.wiringpi.SoftPwm的典型用法代码示例。如果您正苦于以下问题:Java SoftPwm类的具体用法?Java SoftPwm怎么用?Java SoftPwm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SoftPwm类属于com.pi4j.wiringpi包,在下文中一共展示了SoftPwm类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: main

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {

        // initialize wiringPi library
        com.pi4j.wiringpi.Gpio.wiringPiSetup();

        // create soft-pwm pins (min=0 ; max=100)
        SoftPwm.softPwmCreate(1, 0, 100);

        // continuous loop
        while (true) {
            // fade LED to fully ON
            for (int i = 0; i <= 100; i++) {
                SoftPwm.softPwmWrite(1, i);
                Thread.sleep(100);
            }

            // fade LED to fully OFF
            for (int i = 100; i >= 0; i--) {
                SoftPwm.softPwmWrite(1, i);
                Thread.sleep(100);
            }
        }

        // make sure to stop software PWM driver/thread if you done with it.
        //SoftPwm.softPwmStop(1);
    }
 
开发者ID:uwigem,项目名称:uwigem2017,代码行数:27,代码来源:WiringPiSoftPWMExample.java


示例2: moveForward

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
@Override
public synchronized void moveForward (int speed){

    if (!forward){
        SoftPwm.softPwmWrite( backwardPin.getAddress(), 0 );
        try {
            Thread.sleep(50);
        } catch (InterruptedException ex) {
            ;
        }
    }

    SoftPwm.softPwmWrite( forwardPin.getAddress(), speed );
    this.speed = speed;
    forward = true;
}
 
开发者ID:fustinoni-net,项目名称:PiRobotPlatform,代码行数:17,代码来源:MotorImpl.java


示例3: moveBackward

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
@Override
public synchronized void moveBackward (int speed){

    if (forward){
        SoftPwm.softPwmWrite( forwardPin.getAddress(), 0 );
        try {
            Thread.sleep(50);
        } catch (InterruptedException ex) {
            ;
        }
    }

    SoftPwm.softPwmWrite( backwardPin.getAddress(), speed );

    this.speed = speed;
    forward = false;
}
 
开发者ID:fustinoni-net,项目名称:PiRobotPlatform,代码行数:18,代码来源:MotorImpl.java


示例4: main

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
    
    // initialize wiringPi library
    com.pi4j.wiringpi.Gpio.wiringPiSetup();

    // create soft-pwm pins (min=0 ; max=100)
    SoftPwm.softPwmCreate(1, 0, 100);

    // continuous loop
    while (true) {            
        // fade LED to fully ON
        for (int i = 0; i <= 100; i++) {
            SoftPwm.softPwmWrite(1, i);
            Thread.sleep(100);
        }

        // fade LED to fully OFF
        for (int i = 100; i >= 0; i--) {
            SoftPwm.softPwmWrite(1, i);
            Thread.sleep(100);
        }
    }
}
 
开发者ID:iot-labs,项目名称:communication,代码行数:24,代码来源:WiringPiSoftPWMExample.java


示例5: MotorImpl

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
public MotorImpl(final RobotGPIO pi2goGPIO, final Pin forwardPin, final Pin backwardPin) {
       forward = true;
       speed = 0;
       this.forwardPin = forwardPin;
       this.backwardPin = backwardPin;
       SoftPwm.softPwmCreate( forwardPin.getAddress(), 0, 100 );
SoftPwm.softPwmCreate( backwardPin.getAddress(), 0, 100 );
   }
 
开发者ID:fustinoni-net,项目名称:PiRobotPlatform,代码行数:9,代码来源:MotorImpl.java


示例6: stop

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
@Override
public synchronized  void stop(){
    SoftPwm.softPwmWrite( forwardPin.getAddress(), 0 );
    SoftPwm.softPwmWrite( backwardPin.getAddress(), 0 );
    this.speed = 0;
    
    try {
        Thread.sleep(50);
    } catch (InterruptedException ex) {
        ;
    }
}
 
开发者ID:fustinoni-net,项目名称:PiRobotPlatform,代码行数:13,代码来源:MotorImpl.java


示例7: WiringPiPwmOutputDevice

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
WiringPiPwmOutputDevice(String key, DeviceFactoryInterface deviceFactory, PwmType pwmType,
		int range, int gpio, float initialValue) throws RuntimeIOException {
	super(key, deviceFactory);
	
	this.pwmType = pwmType;
	this.gpio = gpio;
	this.value = initialValue;
	this.range = range;
	
	switch (pwmType) {
	case HARDWARE:
		if (GpioUtil.isExported(gpio)) {
			GpioUtil.setDirection(gpio, GpioUtil.DIRECTION_OUT);
		} else {
			GpioUtil.export(gpio, GpioUtil.DIRECTION_OUT);
		}
		Gpio.pinMode(gpio, Gpio.PWM_OUTPUT);
		// Have to call this after setting the pin mode! Yuck
		Gpio.pwmSetMode(Gpio.PWM_MODE_MS);
		Gpio.pwmWrite(gpio, Math.round(initialValue * range));
		break;
	case SOFTWARE:
		int status = SoftPwm.softPwmCreate(gpio, Math.round(initialValue * range), range);
		if (status != 0) {
			throw new RuntimeIOException("Error setting up software controlled PWM GPIO on BCM pin " +
					gpio + ", status=" + status);
		}
		break;
	}
}
 
开发者ID:mattjlewis,项目名称:diozero,代码行数:31,代码来源:WiringPiPwmOutputDevice.java


示例8: closeDevice

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
@Override
protected void closeDevice() throws RuntimeIOException {
	Logger.debug("closeDevice()");
	switch (pwmType) {
	case HARDWARE:
		GpioUtil.unexport(gpio);
	case SOFTWARE:
		SoftPwm.softPwmStop(gpio);
		GpioUtil.unexport(gpio);
		break;
	default:
	}
}
 
开发者ID:mattjlewis,项目名称:diozero,代码行数:14,代码来源:WiringPiPwmOutputDevice.java


示例9: setValue

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
@Override
public void setValue(float value) throws RuntimeIOException {
	this.value = value;
	int dc = (int) Math.floor(value * range);
	switch (pwmType) {
	case HARDWARE:
		Logger.info("setValue({}), range={}, dc={}", Float.valueOf(value), Integer.valueOf(range), Integer.valueOf(dc));
		Gpio.pwmWrite(gpio, dc);
		break;
	case SOFTWARE:
	default:
		SoftPwm.softPwmWrite(gpio, dc);
		break;
	}
}
 
开发者ID:mattjlewis,项目名称:diozero,代码行数:16,代码来源:WiringPiPwmOutputDevice.java


示例10: Pi4jPwmOutputDevice

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
Pi4jPwmOutputDevice(String key, DeviceFactoryInterface deviceFactory, GpioController gpioController,
		PwmType pwmType, int gpio, float initialValue, int range) throws RuntimeIOException {
	super(key, deviceFactory);
	
	this.pwmType = pwmType;
	this.gpio = gpio;
	this.value = initialValue;
	this.range = range;
	
	//pin = RaspiBcmPin.getPinByAddress(gpio);
	//pin.getSupportedPinModes().contains(PinMode.PWM_OUTPUT);
	
	switch (pwmType) {
	case HARDWARE:
		//pwmOutputPin = gpioController.provisionPwmOutputPin(pin, "PWM output for BCM GPIO " + gpio,
		//		Math.round(value * range));
		Gpio.pinMode(gpio, Gpio.PWM_OUTPUT);
		// Have to call this after setting the pin mode! Yuck
		Gpio.pwmSetMode(Gpio.PWM_MODE_MS);
		Gpio.pwmWrite(gpio, Math.round(initialValue * range));
		break;
	case SOFTWARE:
		//pwmOutputPin = gpioController.provisionSoftPwmOutputPin(
		//		pin, "PWM output for BCM GPIO " + gpio, Math.round(initialValue * range));
		int status = SoftPwm.softPwmCreate(gpio, Math.round(initialValue * range), range);
		if (status != 0) {
			throw new RuntimeIOException("Error setting up software controlled PWM GPIO on BCM pin " +
					gpio + ", status=" + status);
		}
	}
}
 
开发者ID:mattjlewis,项目名称:diozero,代码行数:32,代码来源:Pi4jPwmOutputDevice.java


示例11: closeDevice

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
@Override
protected void closeDevice() {
	Logger.debug("closeDevice()");
	//GpioFactory.getInstance().unprovisionPin(pwmOutputPin);
	switch (pwmType) {
	case HARDWARE:
		GpioUtil.unexport(gpio);
	case SOFTWARE:
		SoftPwm.softPwmStop(gpio);
		GpioUtil.unexport(gpio);
		break;
	default:
	}
}
 
开发者ID:mattjlewis,项目名称:diozero,代码行数:15,代码来源:Pi4jPwmOutputDevice.java


示例12: setValue

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
@Override
public void setValue(float value) throws RuntimeIOException {
	this.value = value;
	switch (pwmType) {
	case HARDWARE:
		Logger.info("Pi4j Hardware PWM write " + (Math.round(value * range)));
		Gpio.pwmWrite(gpio, Math.round(value * range));
		break;
	case SOFTWARE:
		SoftPwm.softPwmWrite(gpio, Math.round(value * range));
		break;
	}
}
 
开发者ID:mattjlewis,项目名称:diozero,代码行数:14,代码来源:Pi4jPwmOutputDevice.java


示例13: testPWM

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
public void testPWM() {
	try {

		// initialize wiringPi library
		com.pi4j.wiringpi.Gpio.wiringPiSetup();

		// create soft-pwm pins (min=0 ; max=100)
		SoftPwm.softPwmCreate(1, 0, 100);

		// continuous loop
		while (true) {
			// fade LED to fully ON
			for (int i = 0; i <= 100; i++) {
				SoftPwm.softPwmWrite(1, i);
				Thread.sleep(100);
			}

			// fade LED to fully OFF
			for (int i = 100; i >= 0; i--) {
				SoftPwm.softPwmWrite(1, i);
				Thread.sleep(100);
			}
		}
	} catch (Exception e) {

	}
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:28,代码来源:RasPi.java


示例14: penUp

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
public synchronized void penUp(){
	if (isPenDown){
		SoftPwm.softPwmWrite(properties.getPenPinNumber(), properties.getPenUpPowerLevel());
		Gpio.delayMicroseconds(properties.getPenUpPeriodInMilliseconds()*1000);
		SoftPwm.softPwmWrite(properties.getPenPinNumber(), properties.getPenUpHoldPowerLevel());
		isPenDown=false;
	}
}
 
开发者ID:MHAVLOVICK,项目名称:Sketchy,代码行数:9,代码来源:RaspberryPISolenoidController.java


示例15: penDown

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
public synchronized void penDown(){
	if (!isPenDown){
		SoftPwm.softPwmWrite(properties.getPenPinNumber(), 0); // off
		Gpio.delayMicroseconds(properties.getPenDownPeriodInMilliseconds()*1000);
		isPenDown=true;
	}
}
 
开发者ID:MHAVLOVICK,项目名称:Sketchy,代码行数:8,代码来源:RaspberryPISolenoidController.java


示例16: tearDownPins

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
private synchronized void tearDownPins(){
	SoftPwm.softPwmWrite(properties.getPenPinNumber(), 0);
	// Set pinMode to Output to reset/PWM Pin so it doesn't fail if setup again
	Gpio.pinMode(properties.getPenPinNumber(), Gpio.OUTPUT);
	Gpio.digitalWrite(properties.getLeftMotorEnablePinNumber(), false); // turn off old pin
	Gpio.digitalWrite(properties.getLeftMotorDirectionPinNumber(), false); // turn off old pin			
	Gpio.digitalWrite(properties.getLeftMotorStepPinNumber(), false); // turn off old pin	
	Gpio.digitalWrite(properties.getRightMotorEnablePinNumber(), false); // turn off old pin
	Gpio.digitalWrite(properties.getRightMotorDirectionPinNumber(), false); // turn off old pin			
	Gpio.digitalWrite(properties.getRightMotorStepPinNumber(), false); // turn off old pin	
}
 
开发者ID:MHAVLOVICK,项目名称:Sketchy,代码行数:12,代码来源:RaspberryPISolenoidController.java


示例17: verifySetup

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
@Test
@Category(FastTest.class)
public void verifySetup(){
    sketch.setup(NO_ARGS);
    
    PowerMockito.verifyStatic();
    Gpio.wiringPiSetup();
    
    PowerMockito.verifyStatic();
    SoftPwm.softPwmCreate(LEDPINRED, 0, 100);
    PowerMockito.verifyStatic();
    SoftPwm.softPwmCreate(LEDPINYELLOW, 0, 100);
}
 
开发者ID:marcandreuf,项目名称:sunfounder-sensors-raspi-4j,代码行数:14,代码来源:Ex05_DoubleColorLedTest.java


示例18: verifySetup

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
@Test
@Category(FastTest.class)
public void verifySetup(){
    sketch.setup(NO_ARGS);
    
    PowerMockito.verifyStatic();
    Gpio.wiringPiSetup();
    
    PowerMockito.verifyStatic();
    SoftPwm.softPwmCreate(LEDPINRED, 0, 100);
    PowerMockito.verifyStatic();
    SoftPwm.softPwmCreate(LEDPINGREEN, 0, 100);
    PowerMockito.verifyStatic();
    SoftPwm.softPwmCreate(LEDPINBLUE, 0, 100);        
}
 
开发者ID:marcandreuf,项目名称:sunfounder-sensors-raspi-4j,代码行数:16,代码来源:Ex04_RGBTest.java


示例19: turnOffLedBeforeFinishSketch

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
@Test
@Category(SlowTest.class)
public void turnOffLedBeforeFinishSketch() throws InterruptedException{
    sketch.setup(NO_ARGS);
    sketch.setSketchInterruption();
    sketch.loop();
    
    PowerMockito.verifyStatic(atLeast(1));
    SoftPwm.softPwmWrite(LEDPINRED, 0);
    PowerMockito.verifyStatic(atLeast(1));
    SoftPwm.softPwmWrite(LEDPINGREEN, 0);
    PowerMockito.verifyStatic(atLeast(1));
    SoftPwm.softPwmWrite(LEDPINBLUE, 0);
}
 
开发者ID:marcandreuf,项目名称:sunfounder-sensors-raspi-4j,代码行数:15,代码来源:Ex04_RGBTest.java


示例20: testPWM

import com.pi4j.wiringpi.SoftPwm; //导入依赖的package包/类
public void testPWM() {
  try {

    // initialize wiringPi library
    com.pi4j.wiringpi.Gpio.wiringPiSetup();

    // create soft-pwm pins (min=0 ; max=100)
    SoftPwm.softPwmCreate(1, 0, 100);

    // continuous loop
    while (true) {
      // fade LED to fully ON
      for (int i = 0; i <= 100; i++) {
        SoftPwm.softPwmWrite(1, i);
        Thread.sleep(100);
      }

      // fade LED to fully OFF
      for (int i = 100; i >= 0; i--) {
        SoftPwm.softPwmWrite(1, i);
        Thread.sleep(100);
      }
    }
  } catch (Exception e) {

  }
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:28,代码来源:RasPi.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DexBackedFieldReference类代码示例发布时间:2022-05-22
下一篇:
Java Op类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap