當前位置: 首頁>>代碼示例>>Java>>正文


Java PeripheralManagerService類代碼示例

本文整理匯總了Java中com.google.android.things.pio.PeripheralManagerService的典型用法代碼示例。如果您正苦於以下問題:Java PeripheralManagerService類的具體用法?Java PeripheralManagerService怎麽用?Java PeripheralManagerService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PeripheralManagerService類屬於com.google.android.things.pio包,在下文中一共展示了PeripheralManagerService類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: UartLowpanModule

import com.google.android.things.pio.PeripheralManagerService; //導入依賴的package包/類
/**
 * Create a new UartLowpanModule.
 *
 * @param lowpanDriverCallback @see {@link LowpanDriverCallback}
 * @param uartName UART port name where the module is attached. Cannot be null.
 * @param baudRate Baud rate used for the module UART.
 * @param hardwareFlowControl hardware flow control setting for uart device
 *        {@link UartDevice#HW_FLOW_CONTROL_NONE},
 *        {@link UartDevice#HW_FLOW_CONTROL_AUTO_RTSCTS}
 *        @see UartDevice#HW_FLOW_CONTROL_NONE}
 *        @see UartDevice#HW_FLOW_CONTROL_AUTO_RTSCTS}
 * @param handler optional {@link Handler} for UartDevice.
 */
public UartLowpanModule(@NonNull LowpanDriverCallback lowpanDriverCallback, String uartName,
                        int baudRate, int hardwareFlowControl,
                        UnexpectedCloseListener unexpectedCloseListener,
                        @NonNull Handler handler) throws IOException {
    mLowpanDriverCallback = lowpanDriverCallback;
    mUartName = uartName;
    mHardwareFlowControl = hardwareFlowControl;
    mHandler = handler;
    mBaudRate = baudRate;
    mUnexpectedCloseListener = unexpectedCloseListener;

    final PeripheralManagerService manager = new PeripheralManagerService();

    resetFrameState();

    mDevice = manager.openUartDevice(mUartName);
    mDevice.setBaudrate(mBaudRate);
    mDevice.setDataSize(8);
    mDevice.setHardwareFlowControl(mHardwareFlowControl);
    mDevice.registerUartDeviceCallback(mUartDeviceCallback, mHandler);
}
 
開發者ID:androidthings,項目名稱:contrib-drivers,代碼行數:35,代碼來源:UartLowpanModule.java

示例2: getBoardVariant

import com.google.android.things.pio.PeripheralManagerService; //導入依賴的package包/類
/**
 * Get board variant.
 *
 * @return Name of the board.
 */
private static String getBoardVariant() {
    if (!sBoardVariant.isEmpty()) {
        return sBoardVariant;
    }
    sBoardVariant = Build.DEVICE;
    // For the edison check the pin prefix
    // to always return Edison Breakout pin name when applicable.
    if (sBoardVariant.equals(DEVICE_EDISON)) {
        PeripheralManagerService pioService = new PeripheralManagerService();
        List<String> gpioList = pioService.getGpioList();
        if (gpioList.size() != 0) {
            String pin = gpioList.get(0);
            if (pin.startsWith("IO")) {
                sBoardVariant = DEVICE_EDISON_ARDUINO;
            }
        }
    }
    return sBoardVariant;
}
 
開發者ID:kevalpatel2106,項目名稱:smartswitch,代碼行數:25,代碼來源:BoardDefaults.java

示例3: getBoardVariant

import com.google.android.things.pio.PeripheralManagerService; //導入依賴的package包/類
private static String getBoardVariant() {
    if (!sBoardVariant.isEmpty()) {
        return sBoardVariant;
    }
    sBoardVariant = Build.DEVICE;
    // For the edison check the pin prefix
    // to always return Edison Breakout pin name when applicable.
    if (sBoardVariant.equals(DEVICE_EDISON)) {
        PeripheralManagerService pioService = new PeripheralManagerService();
        List<String> gpioList = pioService.getGpioList();
        if (gpioList.size() != 0) {
            String pin = gpioList.get(0);
            if (pin.startsWith("IO")) {
                sBoardVariant = DEVICE_EDISON_ARDUINO;
            }
        }
    }
    return sBoardVariant;
}
 
開發者ID:FoxLabMakerSpace,項目名稱:SIGHT-For-the-Blind,代碼行數:20,代碼來源:BoardDefaults.java

示例4: getBoardVariant

import com.google.android.things.pio.PeripheralManagerService; //導入依賴的package包/類
private static String getBoardVariant() {
    if (!sBoardVariant.isEmpty()) {
        return sBoardVariant;
    }
    sBoardVariant = Build.DEVICE;
    // For the edison check the pin prefix
    // to always return Edison Breakout pin name when applicable.
    if (sBoardVariant.equals(DEVICE_EDISON)) {
        final PeripheralManagerService pioService = new PeripheralManagerService();
        final List<String> gpioList = pioService.getGpioList();
        if (gpioList.size() != 0) {
            final String pin = gpioList.get(0);
            if (pin.startsWith("IO")) {
                sBoardVariant = DEVICE_EDISON_ARDUINO;
            }
        }
    }
    return sBoardVariant;
}
 
開發者ID:dennisg,項目名稱:i2c-address-scanner,代碼行數:20,代碼來源:BoardDefaults.java

示例5: initPIO

import com.google.android.things.pio.PeripheralManagerService; //導入依賴的package包/類
/**
 * This method should only be called when running on an Android Things device.
 */
private void initPIO() {
    PeripheralManagerService pioService = new PeripheralManagerService();
    try {
        mReadyLED = pioService.openGpio(BoardDefaults.getGPIOForLED());
        mReadyLED.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
        mButtonDriver = new ButtonInputDriver(
                BoardDefaults.getGPIOForButton(),
                Button.LogicState.PRESSED_WHEN_LOW,
                KeyEvent.KEYCODE_ENTER);
        mButtonDriver.register();
    } catch (IOException e) {
        mButtonDriver = null;
        Log.w(TAG, "Could not open GPIO pins", e);
    }
}
 
開發者ID:androidthings,項目名稱:sample-tensorflow-imageclassifier,代碼行數:19,代碼來源:ImageClassifierActivity.java

示例6: onCreate

import com.google.android.things.pio.PeripheralManagerService; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    PeripheralManagerService service = new PeripheralManagerService();
    Log.d(TAG, "Available GPIO: " + service.getGpioList());

    try {
        // Create GPIO connection.
        mButtonGpio = service.openGpio(BUTTON_PIN_NAME);

        // Configure as an input, trigger events on every change.
        mButtonGpio.setDirection(Gpio.DIRECTION_IN);
        mButtonGpio.setEdgeTriggerType(Gpio.EDGE_BOTH);
        // Value is true when the pin is LOW
        mButtonGpio.setActiveType(Gpio.ACTIVE_LOW);
        // Register the event callback.
        mButtonGpio.registerGpioCallback(mCallback);
    } catch (IOException e) {
        Log.w(TAG, "Error opening GPIO", e);
    }
}
 
開發者ID:googlecodelabs,項目名稱:androidthings-peripherals,代碼行數:23,代碼來源:HomeActivity.java

示例7: onCreate

import com.google.android.things.pio.PeripheralManagerService; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    PeripheralManagerService service = new PeripheralManagerService();
    Log.d(TAG, "Available GPIO: " + service.getGpioList());

    try {
        // Create GPIO connection.
        mButtonGpio = service.openGpio(BUTTON_PIN_NAME);

        // Configure as an input, trigger events on every change.
        mButtonGpio.setDirection(Gpio.DIRECTION_IN);
        mButtonGpio.setEdgeTriggerType(Gpio.EDGE_BOTH);
        // Value is true when the pin is LOW
        mButtonGpio.setActiveType(Gpio.ACTIVE_LOW);
        // Register the event callback.
        mButtonGpio.registerGpioCallback(mCallback);

        mLedGpio = service.openGpio(LED_PIN_NAME);
        // Configure as an output.
        mLedGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
    } catch (IOException e) {
        Log.w(TAG, "Error opening GPIO", e);
    }
}
 
開發者ID:googlecodelabs,項目名稱:androidthings-peripherals,代碼行數:27,代碼來源:HomeActivity.java

示例8: LedControl

import com.google.android.things.pio.PeripheralManagerService; //導入依賴的package包/類
public LedControl(String spiGpio) throws IOException {
    PeripheralManagerService pioService = new PeripheralManagerService();
    spiDevice = pioService.openSpiDevice(spiGpio);
    spiDevice.setMode(SpiDevice.MODE0);
    spiDevice.setFrequency(1000000); // 1MHz
    spiDevice.setBitsPerWord(8); // 8 BPW
    spiDevice.setBitJustification(false); // MSB first

    spiTransfer(OP_DECODEMODE, 0); // decoding: BCD
    setScanLimit(7); // scanlimit: 8 LEDs
    spiTransfer(OP_DISPLAYTEST, 0);

    shutdown(false);
    setIntensity(3);
    clearDisplay();
}
 
開發者ID:Nilhcem,項目名稱:blefun-androidthings,代碼行數:17,代碼來源:LedControl.java

示例9: LSM9DS0

import com.google.android.things.pio.PeripheralManagerService; //導入依賴的package包/類
public LSM9DS0(int gyroAdddress, int xmAddress) throws IOException {
    PeripheralManagerService peripheralManagerService = new PeripheralManagerService();

    // Make sure there is available I2C
    List<String> i2cList = peripheralManagerService.getI2cBusList();
    if (i2cList.isEmpty()) {
        Log.i(TAG, "No I2C available on this device.");
        throw new IOException("I2C interface is require");
    } else {
        Log.i(TAG, "List of available I2C : " + i2cList);
    }

    // Asssumption here to use the first available i2c
    gyro = peripheralManagerService.openI2cDevice(i2cList.get(0), gyroAdddress);
    xm = peripheralManagerService.openI2cDevice(i2cList.get(0), xmAddress);
}
 
開發者ID:hongcheng79,項目名稱:androidthings,代碼行數:17,代碼來源:LSM9DS0.java

示例10: Hmc5883l

import com.google.android.things.pio.PeripheralManagerService; //導入依賴的package包/類
public Hmc5883l(String busName, int slaveAddress) throws IOException {
    try {
        mI2cDevice = new PeripheralManagerService().openI2cDevice(busName, slaveAddress);
    } catch (IOException e) {
        try {
            close();
        } catch (IOException ignored) {
            // ignored
        }

        throw e;
    }

    byte[] id = getId();
    if (id[0] == ID_A && id[1] == ID_B && id[2] == ID_C) {
        Log.i(TAG, "HMC5883L detected!");
    } else {
        throw new IOException("ID registers don't match expected values!");
    }

}
 
開發者ID:m-thu,項目名稱:android-things,代碼行數:22,代碼來源:Hmc5883l.java

示例11: tryToOpenPwm

import com.google.android.things.pio.PeripheralManagerService; //導入依賴的package包/類
/**
 * Tries to open the PWM devices.
 * Currently Android Things doesn't allow to set custom pins for the PWM and the PWR.A53.A
 * is expecting to get it on pin 20 and pin 13. Unfortunately Android uses pin 18 and 13.
 * If you want to use PWM with this board please star this issue:
 * https://issuetracker.google.com/issues/70115494
 */
private boolean tryToOpenPwm(PeripheralManagerService pioService) {
    try {
        mPwmEnB = pioService.openPwm(PWR_A53_A_ENB_PWM);
        mPwmEnA = pioService.openPwm(PWR_A53_A_ENA_PWM);
        return true;
    } catch (IOException e) {
        Log.e(TAG, "Unable to open PWMs, falling back to SoftPwm", e);
        try {
            if (mPwmEnA != null) {
                mPwmEnA.close();
            }
            if (mPwmEnB != null) {
                mPwmEnB.close();
            }
        } catch (IOException ignored) {
            // NO-OP
        }
    }
    return false;
}
 
開發者ID:leinardi,項目名稱:androidthings-kuman-sm9,代碼行數:28,代碼來源:PwrA53A.java

示例12: Controller

import com.google.android.things.pio.PeripheralManagerService; //導入依賴的package包/類
/**
 * Public constructor.
 *
 * @param context instance of caller activity.
 */
public Controller(@NonNull final Context context) {
    mTensorFlowImageClassifier = new TensorFlowImageClassifier(context);

    Handler speechProcessorHandler = ThreadManager.getSpeechHandler();
    speechProcessorHandler.post(new Runnable() {
        @Override
        public void run() {
            new SpeechProcessor(context, Controller.this);
        }
    });

    //Build chassis.
    PeripheralManagerService service = new PeripheralManagerService();
    mChassis = new Chassis.Builder()
            .mountRightMotor(service)
            .mountLeftMotor(service)
            .mountFrontRadar(mFrontRadarObstacleListener)
            .mountBeacon(context)
            .mountCamera(context, this)
            .build();

    //Reset the motion
    stop();
}
 
開發者ID:kevalpatel2106,項目名稱:robo-car,代碼行數:30,代碼來源:Controller.java

示例13: FrontRadar

import com.google.android.things.pio.PeripheralManagerService; //導入依賴的package包/類
/**
 * Public constructor.
 */
public FrontRadar(@NonNull ObstacleAlertListener listener) {
    super();

    //Initialize GPIO
    try {
        PeripheralManagerService service = new PeripheralManagerService();
        Gpio trigPin = service.openGpio(BoardDefaults.getGPIOForFrontRadarTrig());
        Gpio echoPin = service.openGpio(BoardDefaults.getGPIOForFrontEcho());

        mHCSR04Driver = new HCSR04Driver(echoPin, trigPin, this);
    } catch (IOException e) {
        e.printStackTrace();
        throw new GpioInitializationException();
    }

    mListener = listener;
}
 
開發者ID:kevalpatel2106,項目名稱:robo-car,代碼行數:21,代碼來源:FrontRadar.java

示例14: startup

import com.google.android.things.pio.PeripheralManagerService; //導入依賴的package包/類
@Override
public void startup() {
    PeripheralManagerService mPeripheralManagerService = new PeripheralManagerService();

    try {
        mDevice = mPeripheralManagerService.openUartDevice(arduino.getUartDeviceName());
        mDevice.setDataSize(arduino.getDataBits());
        mDevice.setParity(UartDevice.PARITY_NONE);
        mDevice.setStopBits(arduino.getStopBits());
        mDevice.setBaudrate(arduino.getBaudRate());
    } catch (IOException e){
        try {
            close();
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        throw new IllegalStateException("Sensor can't start", e);
    }
}
 
開發者ID:mplacona,項目名稱:arduwrap,代碼行數:20,代碼來源:Dht22Driver.java

示例15: onCreate

import com.google.android.things.pio.PeripheralManagerService; //導入依賴的package包/類
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  OkHttpClient httpClient = new OkHttpClient();
  TwilioClient twilio = new TwilioClient(httpClient);
  GpioEventCallback callback = new GpioEventCallback(twilio);

  try {
    String pinName = BoardDefaults.getGPIOForButton();
    mButtonGpio = new PeripheralManagerService().openGpio(pinName);
    mButtonGpio.setDirection(Gpio.DIRECTION_IN);
    mButtonGpio.setEdgeTriggerType(Gpio.EDGE_BOTH);
    mButtonGpio.registerGpioCallback(callback);
  } catch (IOException e) {
    Log.e(TAG, "Error on PeripheralIO API", e);
  }
}
 
開發者ID:robertoestivill,項目名稱:panic-button,代碼行數:18,代碼來源:PanicButtonActivity.java


注:本文中的com.google.android.things.pio.PeripheralManagerService類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。