コード例 #1
0
  // ------------------------------------------------------------------------------------------------------------------
  // Helpers
  // ------------------------------------------------------------------------------------------------------------------
  private PCA9685GpioProvider createProvider() throws IOException {
    BigDecimal frequency = PCA9685GpioProvider.ANALOG_SERVO_FREQUENCY;
    BigDecimal frequencyCorrectionFactor = new BigDecimal("1.0578");

    I2CBus bus = I2CFactory.getInstance(I2CBus.BUS_1);
    return new PCA9685GpioProvider(bus, 0x40, frequency, frequencyCorrectionFactor);
  }
コード例 #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();
  }
コード例 #5
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);
  }