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


Java SoftPwm.softPwmCreate方法代码示例

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


在下文中一共展示了SoftPwm.softPwmCreate方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: main

import com.pi4j.wiringpi.SoftPwm; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
	// get a handle to the GPIO controller
	final GpioController gpio = GpioFactory.getInstance();

	// init soft PWM pins
	// softPwmCreate(int pin, int value, int range)
	// the range is set like (min=0 ; max=100)
	SoftPwm.softPwmCreate(MOTOR_1_PIN_A, 0, 100);
	SoftPwm.softPwmCreate(MOTOR_1_PIN_B, 0, 100);
	SoftPwm.softPwmCreate(MOTOR_2_PIN_A, 0, 100);
	SoftPwm.softPwmCreate(MOTOR_2_PIN_B, 0, 100);

	// init GPIO pins
	final GpioPinDigitalOutput motor1pinE = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_06, "m1E");
	final GpioPinDigitalOutput motor2pinE = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_03, "m2E");

	System.out.println("rotate motor 1 clockwise at 15% speed for 2 seconds");
	motor1pinE.high();
	SoftPwm.softPwmWrite(MOTOR_1_PIN_A, 15);

	// wait 2 seconds
	Thread.sleep(2000);

	System.out.println("rotate motor 1 clockwise at 60% speed for 2 seconds");
	SoftPwm.softPwmWrite(MOTOR_1_PIN_A, 60);

	// wait 2 seconds
	Thread.sleep(2000);

	System.out.println("rotate motor 1 clockwise at full speed for 2 seconds");
	SoftPwm.softPwmWrite(MOTOR_1_PIN_A, 100);

	// wait 2 seconds
	Thread.sleep(2000);

	System.out.println("rotate motor 1 in oposite direction at 50% speed for 3 seconds");
	SoftPwm.softPwmWrite(MOTOR_1_PIN_A, 0);
	SoftPwm.softPwmWrite(MOTOR_1_PIN_B, 50);

	// wait 3 seconds
	Thread.sleep(3000);

	// disable motor 1
	SoftPwm.softPwmWrite(MOTOR_1_PIN_B, 0);
	motor1pinE.low();

	System.out.println("rotate motor 2 clockwise at 30% speed for 2 seconds");
	motor2pinE.high();
	SoftPwm.softPwmWrite(MOTOR_2_PIN_A, 30);

	// wait 2 seconds
	Thread.sleep(2000);

	System.out.println("rotate motor 2 in oposite direction at 100% speed for 3 seconds");
	SoftPwm.softPwmWrite(MOTOR_2_PIN_A, 0);
	SoftPwm.softPwmWrite(MOTOR_2_PIN_B, 100);

	// wait 3 seconds
	Thread.sleep(3000);

	// disable motor 2
	SoftPwm.softPwmWrite(MOTOR_2_PIN_B, 0);
	motor2pinE.low();

	gpio.shutdown();
}
 
开发者ID:JavaTutorialNetwork,项目名称:Tutorials,代码行数:67,代码来源:ControlMotorsDirectionAndSpeed.java

示例11: ledInit

import com.pi4j.wiringpi.SoftPwm; //导入方法依赖的package包/类
protected void ledInit(int ledPinA, int ledPinB) {
    SoftPwm.softPwmCreate(ledPinA, 0, 100);
    SoftPwm.softPwmCreate(ledPinB, 0, 100);        
}
 
开发者ID:marcandreuf,项目名称:sunfounder-sensors-raspi-4j,代码行数:5,代码来源:RGB_Base.java


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