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


Java I2CFactory.UnsupportedBusNumberException方法代码示例

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


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

示例1: main

import com.pi4j.io.i2c.I2CFactory; //导入方法依赖的package包/类
public static void main(String[] args) 
        throws IOException, I2CFactory.UnsupportedBusNumberException, 
        InterruptedException {
    
    // Connect to I2C bus 1
    I2CBus i2c = I2CFactory.getInstance(I2CBus.BUS_1);
    
    // Create device object
    I2CDevice device = i2c.getDevice(PCF8574P_ADDRESS);
    
    while(true) {
        device.write((byte)0x40,(byte)0);
        Thread.sleep(1000);
        device.write((byte)0x40,(byte)1);
    }
}
 
开发者ID:uwigem,项目名称:uwigem2017,代码行数:17,代码来源:PFC8574P.java

示例2: PumpDiagGuiSingle

import com.pi4j.io.i2c.I2CFactory; //导入方法依赖的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

示例3: RgbSensor

import com.pi4j.io.i2c.I2CFactory; //导入方法依赖的package包/类
public RgbSensor()
        throws IOException, I2CFactory.UnsupportedBusNumberException {

    // Get the I2C Bus 
    this.i2cBus = I2CFactory.getInstance(I2CBus.BUS_1);

    // Get device
    this.device = i2cBus.getDevice(ADDR_DEFAULT);

    // Initialize device
    this.readU8(0x44);

    // Enable device
    this.write8(TCS34725_ENABLE, (byte) TCS34725_ENABLE_PON);
    waitfor(10);
    this.write8(TCS34725_ENABLE, (byte) (TCS34725_ENABLE_PON | TCS34725_ENABLE_AEN));
}
 
开发者ID:uwigem,项目名称:uwigem2017,代码行数:18,代码来源:RgbSensor.java

示例4: create

import com.pi4j.io.i2c.I2CFactory; //导入方法依赖的package包/类
@Override
public RpiBaseMotor create(RpiMotor motor) {
	RpiDevice device = (RpiDevice) motor;
	try {
		device.setBus(I2CFactory.getInstance(BUS_NUMBER));
		device.setDevice(motor.getAddress());
	} catch (IOException | I2CFactory.UnsupportedBusNumberException e) {
		throw new RpiMotorException("wrong: ", e);
	}
	SimpleLoggingUtil.debug(getClass(), "port= " + ((RpiBaseMotor) device).getPort());
	return (RpiBaseMotor) device;
}
 
开发者ID:Robo4J,项目名称:robo4j-rpi-ard-tank-example,代码行数:13,代码来源:RpiMotorProvider.java

示例5: McpOutputController

import com.pi4j.io.i2c.I2CFactory; //导入方法依赖的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

示例6: main

import com.pi4j.io.i2c.I2CFactory; //导入方法依赖的package包/类
/**
 * Alter these values to change device operation
 *
 * @param args
 * @throws java.io.IOException
 * @throws com.pi4j.io.i2c.I2CFactory.UnsupportedBusNumberException
 * @throws java.lang.InterruptedException
 */
// Device addresses 0x29, 0x39, 0x49 are possible by setting addr pin to
// GND, Floating, and +3.3V respectively
public static void main(String[] args)
        throws IOException, I2CFactory.UnsupportedBusNumberException, InterruptedException {
    // Set up the I2C libraries
    I2CBus I2C_BUS;
    I2CDevice TSL2561;

    // Get i2c I2C_BUS
    // Number depends on RasPI version
    I2C_BUS = I2CFactory.getInstance(I2CBus.BUS_1);

    System.out.println("Connected to bus. OK.");

    // Get device itself
    TSL2561 = I2C_BUS.getDevice(TSL2561_ADDR);
    System.out.println("Connected to device.");

    System.out.println("Device ID: " + TSL2561.read(TSL2561_REG_ID));

    // Initialize device by issuing command with data value 0x03        
    TSL2561.write(TSL2561_REG_CONTROL, TSL2561_POWER_UP);

    while (true) {
        System.out.println("Waiting...");
        Thread.sleep(500);

        byte d0L = (byte) TSL2561.read((byte) (TCS34725_COMMAND_BIT | DATA_0_LOW));
        byte d0H = (byte) TSL2561.read((byte) (TCS34725_COMMAND_BIT | DATA_0_HIGH));
        byte d1L = (byte) TSL2561.read((byte) (TCS34725_COMMAND_BIT | DATA_1_LOW));
        byte d1H = (byte) TSL2561.read((byte) (TCS34725_COMMAND_BIT | DATA_1_HIGH));

        if (VERBOSE) {
            System.out.println("Data 0: " + bytesToInt(d0H, d0L));
            System.out.println("Data 1: " + bytesToInt(d1H, d1L));
        }
    }
}
 
开发者ID:uwigem,项目名称:uwigem2017,代码行数:47,代码来源:TSL2561_First_Test.java

示例7: addMcp

import com.pi4j.io.i2c.I2CFactory; //导入方法依赖的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

示例8: LuxSensor

import com.pi4j.io.i2c.I2CFactory; //导入方法依赖的package包/类
/**
 * 
 * @param addr I2C hardware address of the device. For us that's 0x39
 * @throws IOException If there is a hardware I/O error
 * @throws com.pi4j.io.i2c.I2CFactory.UnsupportedBusNumberException If bus number is invalid
 * @throws InterruptedException If thread fails to sleep.
 */
public LuxSensor(byte addr)
        throws IOException, I2CFactory.UnsupportedBusNumberException, InterruptedException {
    // Get i2c i2cBus
    // Number depends on RasPI version
    i2cBus = I2CFactory.getInstance(I2CBus.BUS_1);

    // Get device itself
    TSL2561 = i2cBus.getDevice(addr);

    // Initialize device by issuing command with data value 0x03        
    TSL2561.write(TSL2561_REG_CONTROL, TSL2561_POWER_UP);

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

示例9: Controller

import com.pi4j.io.i2c.I2CFactory; //导入方法依赖的package包/类
/**
 * Constructor.
 *
 * @param gpsIn the GPS device inputstream
 * @param screenOut the display device outputstream
 * @param screenIn the display device inputstream
 * @param depthfinderIn the depthfinder device inputstream
 * @param useKeyboardInput true if keyboard input is to be used
 * @param coordinates true if positions are to be displayed as x,y
 * coordinates, other latitude/longitude format will be used.
 * @param displayDepth true is depth is to be displayed, other altitude will
 * be shown
 * @param knots true if speed is to be displayed in knots, other metres/sec
 * will be used
 */
public Controller(FileInputStream gpsIn, FileOutputStream screenOut, FileInputStream screenIn, FileInputStream depthfinderIn,
        boolean useKeyboardInput, boolean coordinates, boolean displayDepth, boolean knots) {
    super("Controller", Command.CLOSE, 6);
    useManualDepth = depthfinderIn == null;
    MDTService.enableShutdownHandler();
    Reporting.registerControl("Controller", 'c');
    try {
        RecorderSessionWriter.createAndStart();
        RecorderRecordWriter.createAndStart();
        recorder = new Recorder();
        //
        SerialTFTDisplayOutputThread.createAndStart(screenOut, screenIn);
        view = new View(screenOut, screenIn, coordinates, displayDepth, knots);
        //
        GPSReader.createAndStart(gpsIn);
        //
        if (useManualDepth) {
            ManualDepthListener.createAndStart();
        } else {
            DepthFinderReader.createAndStart(depthfinderIn);
        }
        //
        if (useKeyboardInput) {
            KeyboardListener.createAndStart();
        } else {
            IrListener.createAndStart();
        }
    } catch (IOException | I2CFactory.UnsupportedBusNumberException e) {
        MDTService.reportExceptionAndExit(e, Exitcode.EXIT_PROGFAIL);
    }
}
 
开发者ID:The-Retired-Programmer,项目名称:gpssurvey,代码行数:47,代码来源:Controller.java

示例10: IrListener

import com.pi4j.io.i2c.I2CFactory; //导入方法依赖的package包/类
private IrListener() throws IOException, I2CFactory.UnsupportedBusNumberException {
    super("IR Listener", Command.CLOSE);
    Reporting.registerControl("IR Listener", 'i');
    gpio = GpioFactory.getInstance();
    i2cInt = gpio.provisionDigitalInputPin(RaspiPin.GPIO_07, "I2C interrupt");
    i2cInt.setShutdownOptions(true);
    I2CBus bus = I2CFactory.getInstance(I2CBus.BUS_1);
    device = bus.getDevice(0x60);
}
 
开发者ID:The-Retired-Programmer,项目名称:gpssurvey,代码行数:10,代码来源:IrListener.java

示例11: PumpDiagGui

import com.pi4j.io.i2c.I2CFactory; //导入方法依赖的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

示例12: MainWindow

import com.pi4j.io.i2c.I2CFactory; //导入方法依赖的package包/类
public MainWindow() throws IOException, I2CFactory.UnsupportedBusNumberException, InterruptedException {
    initComponents();
    gpio = GpioFactory.getInstance(); // Singleton instance
    
    // We should put these instantiations and init in a try/catch
    // block so that it doesn't crash the app when there's something
    // wrong with the I/O hardware.
    // mcpProviderOne = new MCP23017GpioProvider(I2CBus.BUS_1, 0x27);
    // mcpProviderTwo = new MCP23017GpioProvider(I2CBus.BUS_1, 0x26);
    // Initialize syringe pumps
    // initPumps();
    
    colorRead = new RgbSensor();
    tempRead = new TempSensor();
    lightRead = new LuxSensor();
    instructionsLabel.setVisible(false);
    calibrateStartButton.setVisible(false);
    calibrateCancelButton.setVisible(false);
    colorCalibrateConfirmLabel.setVisible(false);
    DecimalFormat d = new DecimalFormat("#.#######");
   
    
    

    Timer actionTime = new Timer(300, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            double tempNum;
            double humidityNum;
            double lightNum;
            try {
                RgbSensor.ColorReading color;
                color = colorRead.getNormalizedReading();
                Color colorPanelBackground = new Color(color.getRed(), color.getGreen(), color.getBlue());
                colorPanel.setBackground(colorPanelBackground);
                colorStringLabel.setText(color.getRed() + "," + color.getGreen() + "," + color.getBlue());
                huePanel.setBackground(colorRead.readingToHue(color));
                Color brightnessPanelColor = new Color(color.getClear(), color.getClear(), color.getClear());
                brightnessPanel.setBackground(brightnessPanelColor);

                tempNum = tempRead.getReading(TempSensor.MEASURE.CELSIUS);
                tempNumLabel.setText(d.format(tempNum));

                humidityNum = tempRead.getHumidity();
                humidityNumLabel.setText(d.format(humidityNum));

                if (lightRead.getReading() < .00035) {
                    lightNum = lightRead.getReading();
                    lightNumLabel.setText("0");
                } else {
                    lightNum = lightRead.getReading();
                    lightNumLabel.setText(d.format(lightNum));
                }
                if (isRecording == true) {
                    csvFileWrite.write(color.getRed() + "." + color.getGreen() + "." + color.getBlue() + "," + lightNum + "," + tempNum + "," + humidityNum);
                    csvFileWrite.write("\r\n");
                }
            } catch (Exception ex) {
                Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
    actionTime.start();

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

示例13: createAndStart

import com.pi4j.io.i2c.I2CFactory; //导入方法依赖的package包/类
/**
 * Create listening thread and start it.
 * 
 * @throws IOException if problems
 * @throws com.pi4j.io.i2c.I2CFactory.UnsupportedBusNumberException if problem with definition
 */
public static void createAndStart() throws IOException, I2CFactory.UnsupportedBusNumberException {
    IrListener thread = new IrListener();
    thread.start();
    thread.sendMessage(Command.START);
}
 
开发者ID:The-Retired-Programmer,项目名称:gpssurvey,代码行数:12,代码来源:IrListener.java


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