コード例 #1
0
ファイル: Board.java プロジェクト: lcavalie/GoPiGo
  public Board() throws IOException, InterruptedException {
    int busId;

    String type = SystemInfo.getBoardType().name();

    if (type.indexOf("ModelA") > 0) {
      busId = I2CBus.BUS_0;
    } else {
      busId = I2CBus.BUS_1;
    }

    final I2CBus bus = I2CFactory.getInstance(busId);
    device = bus.getDevice(ADDRESS);
  }
コード例 #2
0
  private void init(int address) {

    try {
      // Get I2C bus
      bus = I2CFactory.getInstance(I2CBus.BUS_1); // Depends onthe RasPI version

      if (verbose) {
        System.out.println("Connected to bus. OK.");
      }

      // Get the device itself
      servoDriver = bus.getDevice(address);

      if (verbose) {
        System.out.println("Connected to device. OK.");
      }

      // Reseting
      servoDriver.write(MODE1, (byte) 0x00);
    } catch (IOException e) {
      System.err.println(e.getMessage());
    }

    setPWMFreq(HERTZ); // Set frequency to 60 Hz
  }
コード例 #3
0
  public MCP4725(int address) {
    try {
      // Get i2c bus
      bus = I2CFactory.getInstance(I2CBus.BUS_1); // Depends on the RasPI version
      if (verbose) System.out.println("Connected to bus. OK.");

      // Get device itself
      mcp4725 = bus.getDevice(address);
      if (verbose) System.out.println("Connected to device. OK.");
    } catch (IOException e) {
      System.err.println(e.getMessage());
    }
  }
コード例 #4
0
  public AdafruitLEDBackpack(int bus, int address) throws IOException {

    log.info(String.format("AdafruitLEDBackpack on %d %d", bus, address));

    // create I2C communications bus instance
    i2cbus = I2CFactory.getInstance(bus);

    // create I2C device instance
    device = i2cbus.getDevice(address);

    init7SegmentDisplay();
    initTranslation();
  }