当前位置: 首页>>代码示例>>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;未经允许,请勿转载。