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


Java GpioPinPwmOutput类代码示例

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


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

示例1: provisionPwmOutputs

import com.pi4j.io.gpio.GpioPinPwmOutput; //导入依赖的package包/类
private static GpioPinPwmOutput[] provisionPwmOutputs(final PCA9685GpioProvider gpioProvider) {
    GpioController gpio = GpioFactory.getInstance();
    GpioPinPwmOutput myOutputs[] = {
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_00, "Pulse 00"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_01, "Pulse 01"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_02, "Pulse 02"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_03, "Pulse 03"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_04, "Pulse 04"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_05, "Pulse 05"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_06, "Pulse 06"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_07, "Pulse 07"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_08, "Pulse 08"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_09, "Pulse 09"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_10, "Always ON"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_11, "Always OFF"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_12, "Servo pulse MIN"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_13, "Servo pulse NEUTRAL"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_14, "Servo pulse MAX"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_15, "not used")};
    return myOutputs;
}
 
开发者ID:uwigem,项目名称:uwigem2017,代码行数:22,代码来源:PCA9685GpioExample.java

示例2: provisionPwmOutputs

import com.pi4j.io.gpio.GpioPinPwmOutput; //导入依赖的package包/类
private GpioPinPwmOutput[] provisionPwmOutputs(final PCA9685GpioProvider gpioProvider) {
    GpioController gpio = GpioFactory.getInstance();
    GpioPinPwmOutput myOutputs[] = {
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_00, "Servo 00"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_01, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_02, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_03, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_04, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_05, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_06, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_07, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_08, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_09, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_10, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_11, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_12, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_13, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_14, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_15, "not used")};
    return myOutputs;
}
 
开发者ID:uwigem,项目名称:uwigem2017,代码行数:22,代码来源:PCA9685GpioServoExample.java

示例3: switchAnalogPin

import com.pi4j.io.gpio.GpioPinPwmOutput; //导入依赖的package包/类
@Override
public long switchAnalogPin(AnalogPin analogPin, int value)
		throws IOException {
	GpioPinPwmOutput pin = (GpioPinPwmOutput) getOrCreate(
			analogPin.pinNum(), DIGITAL_OUTPUT);
	pin.setMode(PWM_OUTPUT);
	pin.setPwm(value);
	return MessageIdHolders.NO_ID.getId();
}
 
开发者ID:Ardulink,项目名称:Ardulink-2,代码行数:10,代码来源:PiLink.java

示例4: sendPowerPinIntensity

import com.pi4j.io.gpio.GpioPinPwmOutput; //导入依赖的package包/类
private boolean sendPowerPinIntensity(MessageParsedInfo messageParsedInfo) {
	int pinNum    = (Integer)messageParsedInfo.getParsedValues()[0];
	int intensity = (Integer)messageParsedInfo.getParsedValues()[1];
			
	GpioPinPwmOutput  pin = (GpioPinPwmOutput )getPin(pinNum);
	pin.setMode(PinMode.PWM_OUTPUT);
	
	pin.setPwm(intensity);
			
	return true;
}
 
开发者ID:Ardulink,项目名称:Ardulink-1,代码行数:12,代码来源:RaspberryPIConnection.java

示例5: main

import com.pi4j.io.gpio.GpioPinPwmOutput; //导入依赖的package包/类
@SuppressWarnings("resource")
public static void main(String args[]) throws Exception {
    System.out.println("<--Pi4J--> PCA9685 PWM Example ... started.");
    // This would theoretically lead into a resolution of 5 microseconds per step:
    // 4096 Steps (12 Bit)
    // T = 4096 * 0.000005s = 0.02048s
    // f = 1 / T = 48.828125
    BigDecimal frequency = new BigDecimal("48.828");
    // Correction factor: actualFreq / targetFreq
    // e.g. measured actual frequency is: 51.69 Hz
    // Calculate correction factor: 51.65 / 48.828 = 1.0578
    // --> To measure actual frequency set frequency without correction factor(or set to 1)
    BigDecimal frequencyCorrectionFactor = new BigDecimal("1.0578");
    // Create custom PCA9685 GPIO provider
    I2CBus bus = I2CFactory.getInstance(I2CBus.BUS_1);
    final PCA9685GpioProvider provider = new PCA9685GpioProvider(bus, 0x40, frequency, frequencyCorrectionFactor);
    // Define outputs in use for this example
    GpioPinPwmOutput[] myOutputs = provisionPwmOutputs(provider);
    // Reset outputs
    provider.reset();
    //
    // Set various PWM patterns for outputs 0..9
    final int offset = 400;
    final int pulseDuration = 600;
    for (int i = 0; i < 10; i++) {
        Pin pin = PCA9685Pin.ALL[i];
        int onPosition = checkForOverflow(offset * i);
        int offPosition = checkForOverflow(pulseDuration * (i + 1));
        provider.setPwm(pin, onPosition, offPosition);
    }
    // Set full ON
    provider.setAlwaysOn(PCA9685Pin.PWM_10);
    // Set full OFF
    provider.setAlwaysOff(PCA9685Pin.PWM_11);
    // Set 0.9ms pulse (R/C Servo minimum position)
    provider.setPwm(PCA9685Pin.PWM_12, SERVO_DURATION_MIN);
    // Set 1.5ms pulse (R/C Servo neutral position)
    provider.setPwm(PCA9685Pin.PWM_13, SERVO_DURATION_NEUTRAL);
    // Set 2.1ms pulse (R/C Servo maximum position)
    provider.setPwm(PCA9685Pin.PWM_14, SERVO_DURATION_MAX);
    //
    // Show PWM values for outputs 0..14
    for (GpioPinPwmOutput output : myOutputs) {
        int[] onOffValues = provider.getPwmOnOffValues(output.getPin());
        System.out.println(output.getPin().getName() + " (" + output.getName() + "): ON value [" + onOffValues[0] + "], OFF value [" + onOffValues[1] + "]");
    }
    System.out.println("Press <Enter> to terminate...");
    new Scanner(System.in).nextLine();

    System.out.println("Exiting PCA9685GpioExample");
}
 
开发者ID:uwigem,项目名称:uwigem2017,代码行数:52,代码来源:PCA9685GpioExample.java

示例6: main

import com.pi4j.io.gpio.GpioPinPwmOutput; //导入依赖的package包/类
/**
 * @param args the command line arguments
 * @throws InterruptedException
 */
public static void main(String[] args) throws InterruptedException, PlatformAlreadyAssignedException {

    // ####################################################################
    //
    // since we are not using the default Raspberry Pi platform, we should
    // explicitly assign the platform as the BananaPi platform.
    //
    // ####################################################################
    PlatformManager.setPlatform(Platform.BANANAPI);

    // create Pi4J console wrapper/helper
    // (This is a utility class to abstract some of the boilerplate code)
    final Console console = new Console();

    // print program title/header
    console.title("<-- The Pi4J Project -->", "PWM Example");

    // allow for user to exit program using CTRL-C
    console.promptForExit();

    // create GPIO controller instance
    GpioController gpio = GpioFactory.getInstance();

    // ####################################################################
    //
    // When provisioning a pin, use the BananaPiPin class.
    //
    // ####################################################################

    // the BananaPi supports a single hardware PWM pin on GPIO_07
    GpioPinPwmOutput pwm = gpio.provisionPwmOutputPin(BananaPiPin.GPIO_07);

    // set the PWM rate to 500
    pwm.setPwm(500);
    console.println("PWM rate is: " + pwm.getPwm());

    console.println("Press ENTER to set the PWM to a rate of 250");
    System.console().readLine();

    // set the PWM rate to 250
    pwm.setPwm(250);
    console.println("PWM rate is: " + pwm.getPwm());


    console.println("Press ENTER to set the PWM to a rate to 0 (stop PWM)");
    System.console().readLine();

    // set the PWM rate to 0
    pwm.setPwm(0);
    console.println("PWM rate is: " + pwm.getPwm());

    // stop all GPIO activity/threads by shutting down the GPIO controller
    // (this method will forcefully shutdown all GPIO monitoring threads and scheduled tasks)
    gpio.shutdown();
}
 
开发者ID:uwigem,项目名称:uwigem2017,代码行数:60,代码来源:PwmExample.java

示例7: provisionPwmOutputPin

import com.pi4j.io.gpio.GpioPinPwmOutput; //导入依赖的package包/类
@Override
public GpioPinPwmOutput provisionPwmOutputPin(GpioProvider provider, Pin pin, String name) {
    return delegate.provisionPwmOutputPin(provider, pin, name);
}
 
开发者ID:fustinoni-net,项目名称:PiRobotPlatform,代码行数:5,代码来源:BaseRobot.java

示例8: provisionSoftPwmOutputPin

import com.pi4j.io.gpio.GpioPinPwmOutput; //导入依赖的package包/类
@Override
public GpioPinPwmOutput provisionSoftPwmOutputPin(GpioProvider gp, Pin pin, String string, int i) {
    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
 
开发者ID:fustinoni-net,项目名称:PiRobotPlatform,代码行数:5,代码来源:BaseRobot.java

示例9: main

import com.pi4j.io.gpio.GpioPinPwmOutput; //导入依赖的package包/类
@SuppressWarnings("resource")
public static void main(String args[]) throws Exception {
    System.out.println("<--Pi4J--> PCA9685 PWM Example ... started.");
    // This would theoretically lead into a resolution of 5 microseconds per step:
    // 4096 Steps (12 Bit)
    // T = 4096 * 0.000005s = 0.02048s
    // f = 1 / T = 48.828125
    BigDecimal frequency = new BigDecimal("48.828");
    // Correction factor: actualFreq / targetFreq
    // e.g. measured actual frequency is: 51.69 Hz
    // Calculate correction factor: 51.65 / 48.828 = 1.0578
    // --> To measure actual frequency set frequency without correction factor(or set to 1)
    BigDecimal frequencyCorrectionFactor = new BigDecimal("1.0578");
    // Create custom PCA9685 GPIO provider
    I2CBus bus = I2CFactory.getInstance(I2CBus.BUS_1);
    final PCA9685GpioProvider gpioProvider = new PCA9685GpioProvider(bus, 0x40, frequency, frequencyCorrectionFactor);
    // Define outputs in use for this example
    GpioPinPwmOutput[] myOutputs = provisionPwmOutputs(gpioProvider);
    // Reset outputs
    gpioProvider.reset();
    //
    // Set various PWM patterns for outputs 0..9
    final int offset = 400;
    final int pulseDuration = 600;
    for (int i = 0; i < 10; i++) {
        Pin pin = PCA9685Pin.ALL[i];
        int onPosition = checkForOverflow(offset * i);
        int offPosition = checkForOverflow(pulseDuration * (i + 1));
        gpioProvider.setPwm(pin, onPosition, offPosition);
    }
    // Set full ON
    gpioProvider.setAlwaysOn(PCA9685Pin.PWM_10);
    // Set full OFF
    gpioProvider.setAlwaysOff(PCA9685Pin.PWM_11);
    // Set 0.9ms pulse (R/C Servo minimum position) 
    gpioProvider.setPwm(PCA9685Pin.PWM_12, SERVO_DURATION_MIN);
    // Set 1.5ms pulse (R/C Servo neutral position) 
    gpioProvider.setPwm(PCA9685Pin.PWM_13, SERVO_DURATION_NEUTRAL);
    // Set 2.1ms pulse (R/C Servo maximum position) 
    gpioProvider.setPwm(PCA9685Pin.PWM_14, SERVO_DURATION_MAX);
    //
    // Show PWM values for outputs 0..14
    for (GpioPinPwmOutput output : myOutputs) {
        int[] onOffValues = gpioProvider.getPwmOnOffValues(output.getPin());
        System.out.println(output.getPin().getName() + " (" + output.getName() + "): ON value [" + onOffValues[0] + "], OFF value [" + onOffValues[1] + "]");
    }
    System.out.println("Press <Enter> to terminate...");
    new Scanner(System.in).nextLine();
}
 
开发者ID:iot-labs,项目名称:communication,代码行数:50,代码来源:PCA9685GpioExample.java

示例10: ButtonLed

import com.pi4j.io.gpio.GpioPinPwmOutput; //导入依赖的package包/类
public ButtonLed(GpioPinPwmOutput ledPin) {
	this.ledPin = ledPin;
}
 
开发者ID:pierre-muth,项目名称:selfpi,代码行数:4,代码来源:SelfPi.java

示例11: provisionPwmOutputPin

import com.pi4j.io.gpio.GpioPinPwmOutput; //导入依赖的package包/类
public GpioPinPwmOutput provisionPwmOutputPin(GpioProvider provider, Pin pin, String name, int defaultValue) {
return gpioController.provisionPwmOutputPin(provider, pin, name, defaultValue);
   }
 
开发者ID:PoJD,项目名称:hawa,代码行数:4,代码来源:GpioImpl.java


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