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


Java MCP23017GpioProvider类代码示例

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


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

示例1: PumpDiagGuiSingle

import com.pi4j.gpio.extension.mcp.MCP23017GpioProvider; //导入依赖的package包/类
/**
 * Creates new form MainWindow
 *
 * @throws com.pi4j.io.i2c.I2CFactory.UnsupportedBusNumberException
 * @throws java.io.IOException
 */
public PumpDiagGuiSingle() throws I2CFactory.UnsupportedBusNumberException, IOException, IOException, InterruptedException {
    gpio = GpioFactory.getInstance(); // Singleton instance
    mcpProvider = new MCP23017GpioProvider(I2CBus.BUS_1, 0x23);

    // Provision direction control pins as outputs
    System.out.println("Provisioning direction pin");
    dir = gpio.provisionDigitalOutputPin(mcpProvider, MCP23017Pin.GPIO_A7, "Direction", PinState.LOW);

    // Provision step control pins as outputs
    System.out.println("Provisioning step pin");
    step = gpio.provisionDigitalOutputPin(mcpProvider, MCP23017Pin.GPIO_A6, "Step", PinState.LOW);

    // Provision enable pins as outputs. 
    // Note that the pin state "high" means the pump is disabled;
    // the enable pump on the chip is inverted.
    System.out.println("Provisioning enable pin");
    enable = gpio.provisionDigitalOutputPin(mcpProvider, MCP23017Pin.GPIO_A5, "~Enable", PinState.HIGH);
}
 
开发者ID:uwigem,项目名称:uwigem2017,代码行数:25,代码来源:PumpDiagGuiSingle.java

示例2: McpOutputController

import com.pi4j.gpio.extension.mcp.MCP23017GpioProvider; //导入依赖的package包/类
public McpOutputController(int addr) {

        // Basic required setup
        this.gpioCtrl = GpioFactory.getInstance();
        try {
            this.provider = new MCP23017GpioProvider(I2CBus.BUS_1, addr);
        } catch (I2CFactory.UnsupportedBusNumberException | IOException ex) {
            Logger.getLogger(McpOutputController.class.getName()).log(Level.SEVERE, null, ex);
        }

        // Initialize all pins to output
        this.initPins();
    }
 
开发者ID:uwigem,项目名称:uwigem2017,代码行数:14,代码来源:McpOutputController.java

示例3: addMcp

import com.pi4j.gpio.extension.mcp.MCP23017GpioProvider; //导入依赖的package包/类
/**
 * Add a new MCP23017 GPIO expander chip to the manager. This allows the
 * assignment of 16 additional GPIO pins.
 *
 * Note that each chip assigned must have a different address.
 *
 * @param address The I2C address of the chip, in the range 0x20 to 0x27
 * @throws I2CFactory.UnsupportedBusNumberException If the bus # is invalid.
 * @throws IOException If the chip can't be communicated with.
 */
public void addMcp(int bus, int address)
        throws I2CFactory.UnsupportedBusNumberException, IOException {
    GpioProvider provider = new MCP23017GpioProvider(bus, address);
    for (Pin mcpPin : MCP23017Pin.ALL) {
        String name = mcpPin.getName() + " " + Integer.toHexString(address);
        NamedPin newPin = new NamedPin(name, mcpPin, provider);
        this.availablePins.add(newPin);
    }

}
 
开发者ID:uwigem,项目名称:uwigem2017,代码行数:21,代码来源:GpioManager.java

示例4: getMCP23017Provider

import com.pi4j.gpio.extension.mcp.MCP23017GpioProvider; //导入依赖的package包/类
public GpioProvider getMCP23017Provider(int address) {
try {
    return new MCP23017GpioProvider(newRasPI() ? I2CBus.BUS_1 : I2CBus.BUS_0, address);
} catch (IOException | UnsatisfiedLinkError e) {
    LOG.error("Unable to locate MCP23017 at address " + String.format("0x%x", address) + ", using default provider instead.", e);
    return gpio().getDefaultProvider();
}
   }
 
开发者ID:PoJD,项目名称:hawa,代码行数:9,代码来源:RpiConfig.java

示例5: main

import com.pi4j.gpio.extension.mcp.MCP23017GpioProvider; //导入依赖的package包/类
public static void main(String args[]) throws InterruptedException, UnsupportedBusNumberException, IOException {

        System.out.println("<--Pi4J--> MCP23017 GPIO Example ... started.");

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

        // create custom MCP23017 GPIO provider
        final MCP23017GpioProvider provider = new MCP23017GpioProvider(I2CBus.BUS_1, 0x21);

        // provision gpio input pins from MCP23017
        GpioPinDigitalInput myInputs[] = {
                gpio.provisionDigitalInputPin(provider, MCP23017Pin.GPIO_A0, "MyInput-A0", PinPullResistance.PULL_UP),
                gpio.provisionDigitalInputPin(provider, MCP23017Pin.GPIO_A1, "MyInput-A1", PinPullResistance.PULL_UP),
                gpio.provisionDigitalInputPin(provider, MCP23017Pin.GPIO_A2, "MyInput-A2", PinPullResistance.PULL_UP),
                gpio.provisionDigitalInputPin(provider, MCP23017Pin.GPIO_A3, "MyInput-A3", PinPullResistance.PULL_UP),
                gpio.provisionDigitalInputPin(provider, MCP23017Pin.GPIO_A4, "MyInput-A4", PinPullResistance.PULL_UP),
                gpio.provisionDigitalInputPin(provider, MCP23017Pin.GPIO_A5, "MyInput-A5", PinPullResistance.PULL_UP),
                gpio.provisionDigitalInputPin(provider, MCP23017Pin.GPIO_A6, "MyInput-A6", PinPullResistance.PULL_UP),
                gpio.provisionDigitalInputPin(provider, MCP23017Pin.GPIO_A7, "MyInput-A7", PinPullResistance.PULL_UP),
            };

        // create and register gpio pin listener
        gpio.addListener(new GpioPinListenerDigital() {
            @Override
            public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
                // display pin state on console
                System.out.println(" --> GPIO PIN STATE CHANGE: " + event.getPin() + " = "
                        + event.getState());
            }
        }, myInputs);

        // provision gpio output pins and make sure they are all LOW at startup
        GpioPinDigitalOutput myOutputs[] = {
            gpio.provisionDigitalOutputPin(provider, MCP23017Pin.GPIO_B0, "MyOutput-B0", PinState.LOW),
            gpio.provisionDigitalOutputPin(provider, MCP23017Pin.GPIO_B1, "MyOutput-B1", PinState.LOW),
            gpio.provisionDigitalOutputPin(provider, MCP23017Pin.GPIO_B2, "MyOutput-B2", PinState.LOW),
            gpio.provisionDigitalOutputPin(provider, MCP23017Pin.GPIO_B3, "MyOutput-B3", PinState.LOW),
            gpio.provisionDigitalOutputPin(provider, MCP23017Pin.GPIO_B4, "MyOutput-B4", PinState.LOW),
            gpio.provisionDigitalOutputPin(provider, MCP23017Pin.GPIO_B5, "MyOutput-B5", PinState.LOW),
            gpio.provisionDigitalOutputPin(provider, MCP23017Pin.GPIO_B6, "MyOutput-B6", PinState.LOW),
            gpio.provisionDigitalOutputPin(provider, MCP23017Pin.GPIO_B7, "MyOutput-B7", PinState.LOW)
          };

        // keep program running for 20 seconds
        for (int count = 0; count < 10; count++) {
            gpio.setState(true, myOutputs);
            Thread.sleep(1000);
            gpio.setState(false, myOutputs);
            Thread.sleep(1000);
        }

        // 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();

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

示例6: MCP23017_Control

import com.pi4j.gpio.extension.mcp.MCP23017GpioProvider; //导入依赖的package包/类
public MCP23017_Control(int address) throws UnsupportedBusNumberException, IOException {
    this.gpio = GpioFactory.getInstance();
    this.provider = new MCP23017GpioProvider(I2CBus.BUS_1, address);
    
}
 
开发者ID:uwigem,项目名称:uwigem2017,代码行数:6,代码来源:MCP23017_Control.java

示例7: main

import com.pi4j.gpio.extension.mcp.MCP23017GpioProvider; //导入依赖的package包/类
public static void main(String args[]) throws InterruptedException, UnsupportedBusNumberException, IOException {

        System.out.println("<--Pi4J--> MCP23017 GPIO Example ... started.");

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

        // create custom MCP23017 GPIO provider
        final MCP23017GpioProvider provider = new MCP23017GpioProvider(I2CBus.BUS_1, 0x20);
        
        
        
        

        // provision gpio input pins from MCP23017
        GpioPinDigitalInput myInputs[] = {
                gpio.provisionDigitalInputPin(provider, MCP23017Pin.GPIO_A0, "MyInput-A0", PinPullResistance.OFF),
                gpio.provisionDigitalInputPin(provider, MCP23017Pin.GPIO_A1, "MyInput-A1", PinPullResistance.OFF),
                gpio.provisionDigitalInputPin(provider, MCP23017Pin.GPIO_A2, "MyInput-A2", PinPullResistance.OFF),
                gpio.provisionDigitalInputPin(provider, MCP23017Pin.GPIO_A3, "MyInput-A3", PinPullResistance.OFF),
                gpio.provisionDigitalInputPin(provider, MCP23017Pin.GPIO_A4, "MyInput-A4", PinPullResistance.OFF),
                gpio.provisionDigitalInputPin(provider, MCP23017Pin.GPIO_A5, "MyInput-A5", PinPullResistance.OFF),
                gpio.provisionDigitalInputPin(provider, MCP23017Pin.GPIO_A6, "MyInput-A6", PinPullResistance.OFF),
                gpio.provisionDigitalInputPin(provider, MCP23017Pin.GPIO_A7, "MyInput-A7", PinPullResistance.OFF),
            };

        // create and register gpio pin listener
        gpio.addListener(new GpioPinListenerDigital() {
            @Override
            public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
                // display pin state on console
                System.out.println(" --> GPIO PIN STATE CHANGE: " + event.getPin() + " = "
                        + event.getState());
            }
        }, myInputs);

        // provision gpio output pins and make sure they are all LOW at startup
        GpioPinDigitalOutput myOutputs[] = {
            gpio.provisionDigitalOutputPin(provider, MCP23017Pin.GPIO_B0, "MyOutput-B0", PinState.LOW),
            gpio.provisionDigitalOutputPin(provider, MCP23017Pin.GPIO_B1, "MyOutput-B1", PinState.LOW),
            gpio.provisionDigitalOutputPin(provider, MCP23017Pin.GPIO_B2, "MyOutput-B2", PinState.LOW),
            gpio.provisionDigitalOutputPin(provider, MCP23017Pin.GPIO_B3, "MyOutput-B3", PinState.LOW),
            gpio.provisionDigitalOutputPin(provider, MCP23017Pin.GPIO_B4, "MyOutput-B4", PinState.LOW),
            gpio.provisionDigitalOutputPin(provider, MCP23017Pin.GPIO_B5, "MyOutput-B5", PinState.LOW),
            gpio.provisionDigitalOutputPin(provider, MCP23017Pin.GPIO_B6, "MyOutput-B6", PinState.LOW),
            gpio.provisionDigitalOutputPin(provider, MCP23017Pin.GPIO_B7, "MyOutput-B7", PinState.LOW)
          };
        
        

        // keep program running for 20 seconds
        for (int count = 0; count < 1000; count++) {
            gpio.setState(true, myOutputs);
            Thread.sleep(1000);
            gpio.setState(false, myOutputs);
            Thread.sleep(1000);
        }

        // 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();

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

示例8: PumpDiagGui

import com.pi4j.gpio.extension.mcp.MCP23017GpioProvider; //导入依赖的package包/类
/**
 * Creates new form MainWindow
 * @throws com.pi4j.io.i2c.I2CFactory.UnsupportedBusNumberException
 * @throws java.io.IOException
 */
public PumpDiagGui() throws I2CFactory.UnsupportedBusNumberException, IOException, IOException {
    gpio = GpioFactory.getInstance(); // Singleton instance
    mcpProviderOne = new MCP23017GpioProvider(I2CBus.BUS_1, 0x27);
    //mcpProviderTwo = new MCP23017GpioProvider(I2CBus.BUS_1, 0x23);

    // Provision direction control pins as outputs
    GpioPinDigitalOutput dir1 = gpio.provisionDigitalOutputPin(mcpProviderOne, MCP23017Pin.GPIO_A7, "Pump 1 Direction", PinState.LOW);
    GpioPinDigitalOutput dir2 = gpio.provisionDigitalOutputPin(mcpProviderOne, MCP23017Pin.GPIO_B0, "Pump 2 Direction", PinState.LOW);
    GpioPinDigitalOutput dir3 = gpio.provisionDigitalOutputPin(mcpProviderOne, MCP23017Pin.GPIO_A4, "Pump 3 Direction", PinState.LOW);

    // Provision step control pins as outputs
    GpioPinDigitalOutput step1 = gpio.provisionDigitalOutputPin(mcpProviderOne, MCP23017Pin.GPIO_A6, "Pump 1 Step", PinState.LOW);
    GpioPinDigitalOutput step2 = gpio.provisionDigitalOutputPin(mcpProviderOne, MCP23017Pin.GPIO_B1, "Pump 2 Step", PinState.LOW);
    GpioPinDigitalOutput step3 = gpio.provisionDigitalOutputPin(mcpProviderOne, MCP23017Pin.GPIO_A3, "Pump 3 Step", PinState.LOW);

    // Provision enable pins as outputs. 
    // Note that the pin state "high" means the pump is disabled;
    // the enable pump on the chip is inverted.
    GpioPinDigitalOutput enable1 = gpio.provisionDigitalOutputPin(mcpProviderOne, MCP23017Pin.GPIO_A5, "Pump 1 ~Enable", PinState.HIGH);
    GpioPinDigitalOutput enable2 = gpio.provisionDigitalOutputPin(mcpProviderOne, MCP23017Pin.GPIO_B7, "Pump 2 ~Enable", PinState.HIGH);
    GpioPinDigitalOutput enable3 = gpio.provisionDigitalOutputPin(mcpProviderOne, MCP23017Pin.GPIO_A2, "Pump 3 ~Enable", PinState.HIGH);

    // Provision end-stop pins as inputs. 
    // These pins tell the pump when the syringe
    // is in its MINIMUM possible position (empty).
    GpioPinDigitalInput min1 = gpio.provisionDigitalInputPin(RaspiPin.GPIO_07, "Pump 1 Min (BCM 4)", PinPullResistance.PULL_UP);
    GpioPinDigitalInput min2 = gpio.provisionDigitalInputPin(RaspiPin.GPIO_00, "Pump 2 Min (BCM 17)", PinPullResistance.PULL_UP);
    GpioPinDigitalInput min3 = gpio.provisionDigitalInputPin(RaspiPin.GPIO_02, "Pump 3 Min (BCM 27)", PinPullResistance.PULL_UP);

    // Provision end-stop pins as inputs.
    // These pins tell the pump when the syringe
    // is in its MAXIMUM possible position (full).
    GpioPinDigitalInput max1 = gpio.provisionDigitalInputPin(RaspiPin.GPIO_27, "Pump 1 Max (BCM 16)", PinPullResistance.PULL_UP);
    GpioPinDigitalInput max2 = gpio.provisionDigitalInputPin(RaspiPin.GPIO_28, "Pump 2 Max (BCM 20)", PinPullResistance.PULL_UP);
    GpioPinDigitalInput max3 = gpio.provisionDigitalInputPin(RaspiPin.GPIO_29, "Pump 3 Max (BCM 21)", PinPullResistance.PULL_UP);

    pump1 = new SyringePump(step1, dir1, enable1, min1, max1);
    pump2 = new SyringePump(step2, dir2, enable2, min2, max2);
    pump3 = new SyringePump(step3, dir3, enable3, min3, max3);

    pump1.setStepDelay(1);
    pump2.setStepDelay(1);
    pump3.setStepDelay(1);
    
   
    
    initComponents();

}
 
开发者ID:uwigem,项目名称:uwigem2017,代码行数:55,代码来源:PumpDiagGui.java

示例9: main

import com.pi4j.gpio.extension.mcp.MCP23017GpioProvider; //导入依赖的package包/类
public static void main(String args[]) throws InterruptedException, IOException {
    
    System.out.println("<--Pi4J--> MCP23017 GPIO Example ... started.");
    
    // create gpio controller
    final GpioController gpio = GpioFactory.getInstance();
    
    // create custom MCP23017 GPIO provider
    final MCP23017GpioProvider gpioProvider = new MCP23017GpioProvider(I2CBus.BUS_1, 0x21);
    
    // provision gpio input pins from MCP23017
    GpioPinDigitalInput myInputs[] = {
            gpio.provisionDigitalInputPin(gpioProvider, MCP23017Pin.GPIO_A0, "MyInput-A0", PinPullResistance.PULL_UP),
            gpio.provisionDigitalInputPin(gpioProvider, MCP23017Pin.GPIO_A1, "MyInput-A1", PinPullResistance.PULL_UP),
            gpio.provisionDigitalInputPin(gpioProvider, MCP23017Pin.GPIO_A2, "MyInput-A2", PinPullResistance.PULL_UP),
            gpio.provisionDigitalInputPin(gpioProvider, MCP23017Pin.GPIO_A3, "MyInput-A3", PinPullResistance.PULL_UP),
            gpio.provisionDigitalInputPin(gpioProvider, MCP23017Pin.GPIO_A4, "MyInput-A4", PinPullResistance.PULL_UP),
            gpio.provisionDigitalInputPin(gpioProvider, MCP23017Pin.GPIO_A5, "MyInput-A5", PinPullResistance.PULL_UP),
            gpio.provisionDigitalInputPin(gpioProvider, MCP23017Pin.GPIO_A6, "MyInput-A6", PinPullResistance.PULL_UP),
            gpio.provisionDigitalInputPin(gpioProvider, MCP23017Pin.GPIO_A7, "MyInput-A7", PinPullResistance.PULL_UP),
        };
    
    // create and register gpio pin listener
    gpio.addListener(new GpioPinListenerDigital() {
        @Override
        public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
            // display pin state on console
            System.out.println(" --> GPIO PIN STATE CHANGE: " + event.getPin() + " = "
                    + event.getState());
        }
    }, myInputs);
    
    // provision gpio output pins and make sure they are all LOW at startup
    GpioPinDigitalOutput myOutputs[] = { 
        gpio.provisionDigitalOutputPin(gpioProvider, MCP23017Pin.GPIO_B0, "MyOutput-B0", PinState.LOW),
        gpio.provisionDigitalOutputPin(gpioProvider, MCP23017Pin.GPIO_B1, "MyOutput-B1", PinState.LOW),
        gpio.provisionDigitalOutputPin(gpioProvider, MCP23017Pin.GPIO_B2, "MyOutput-B2", PinState.LOW),
        gpio.provisionDigitalOutputPin(gpioProvider, MCP23017Pin.GPIO_B3, "MyOutput-B3", PinState.LOW),
        gpio.provisionDigitalOutputPin(gpioProvider, MCP23017Pin.GPIO_B4, "MyOutput-B4", PinState.LOW),
        gpio.provisionDigitalOutputPin(gpioProvider, MCP23017Pin.GPIO_B5, "MyOutput-B5", PinState.LOW),
        gpio.provisionDigitalOutputPin(gpioProvider, MCP23017Pin.GPIO_B6, "MyOutput-B6", PinState.LOW),
        gpio.provisionDigitalOutputPin(gpioProvider, MCP23017Pin.GPIO_B7, "MyOutput-B7", PinState.LOW)
      };
    
    // keep program running for 20 seconds
    for (int count = 0; count < 10; count++) {
        gpio.setState(true, myOutputs);
        Thread.sleep(1000);
        gpio.setState(false, myOutputs);
        Thread.sleep(1000);
    }
    
    // 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:iot-labs,项目名称:communication,代码行数:57,代码来源:MCP23017GpioExample.java

示例10: Mcp23017PinStateHolder

import com.pi4j.gpio.extension.mcp.MCP23017GpioProvider; //导入依赖的package包/类
public Mcp23017PinStateHolder(MCP23017GpioProvider mcpProvider, Thing thing) {
    this.mcpProvider = mcpProvider;
    this.thing = thing;
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:5,代码来源:Mcp23017PinStateHolder.java


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