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


Java PeripheralManagerService.openSpiDevice方法代碼示例

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


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

示例1: 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

示例2: LedControl

import com.google.android.things.pio.PeripheralManagerService; //導入方法依賴的package包/類
public LedControl(String spiGpio, int numDevices) 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

    maxDevices = numDevices;
    if (numDevices < 1 || numDevices > 8) {
        maxDevices = 8;
    }

    for (int i = 0; i < maxDevices; i++) {
        spiTransfer(i, OP_DISPLAYTEST, 0);
        setScanLimit(i, 7); // scanlimit: 8 LEDs
        spiTransfer(i, OP_DECODEMODE, 0); // decoding: BCD
        clearDisplay(i);
        // we go into shutdown-mode on startup
        shutdown(i, true);
    }
}
 
開發者ID:Nilhcem,項目名稱:ledcontrol-androidthings,代碼行數:23,代碼來源:LedControl.java

示例3: Apa102

import com.google.android.things.pio.PeripheralManagerService; //導入方法依賴的package包/類
/**
 * Create a new Apa102 driver.
 *
 * @param spiBusPort Name of the SPI bus
 * @param ledMode The {@link Mode} indicating the red/green/blue byte ordering for the device.
 * @param direction The {@link Direction} or the led strip.
 */
public Apa102(String spiBusPort, Mode ledMode, Direction direction) throws IOException {
    mLedMode = ledMode;
    mDirection = direction;
    PeripheralManagerService pioService = new PeripheralManagerService();
    mDevice = pioService.openSpiDevice(spiBusPort);
    try {
        configure(mDevice);
    } catch (IOException|RuntimeException e) {
        try {
            close();
        } catch (IOException|RuntimeException ignored) {
        }
        throw e;
    }
}
 
開發者ID:androidthings,項目名稱:contrib-drivers,代碼行數:23,代碼來源:Apa102.java

示例4: TM1838Driver

import com.google.android.things.pio.PeripheralManagerService; //導入方法依賴的package包/類
/**
 * Setup and initialize object using SPI device (MOSI pulled up to MISO by 1K resistor)
 * @param spiDeviceName
 * @param brightness desired display brightness 0-7
 * @throws IOException
 */
public TM1838Driver(@NonNull String spiDeviceName, int brightness) throws IOException {
    PeripheralManagerService service = new PeripheralManagerService();
    spiDevice = service.openSpiDevice(spiDeviceName);
    spiDevice.setMode(SpiDevice.MODE3);
    spiDevice.setFrequency(16000000);     // 16MHz
    spiDevice.setDelay(80);
    spiDevice.setBitsPerWord(8);          // 8 BPW
    spiDevice.setBitJustification(false); // MSB first
    spiDevice.setCsChange(false);
    init(brightness);
}
 
開發者ID:dglabs,項目名稱:androidthings-drivers,代碼行數:18,代碼來源:TM1838Driver.java

示例5: onCreate

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

    mTagDetectedView = (TextView)findViewById(R.id.tag_read);
    mTagUidView = (TextView)findViewById(R.id.tag_uid);
    mTagResultsView = (TextView) findViewById(R.id.tag_results);
    button = (Button)findViewById(R.id.button);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mRfidTask = new RfidTask(mRc522);
            mRfidTask.execute();
            ((Button)v).setText(R.string.reading);
        }
    });
    PeripheralManagerService pioService = new PeripheralManagerService();
    try {
        spiDevice = pioService.openSpiDevice(SPI_PORT);
        gpioReset = pioService.openGpio(PIN_RESET);
        mRc522 = new Rc522(spiDevice, gpioReset);
        mRc522.setDebugging(true);
    } catch (IOException e) {
        Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    }
}
 
開發者ID:Galarzaa90,項目名稱:android-things-rc522,代碼行數:29,代碼來源:MainActivity.java

示例6: Adxl362

import com.google.android.things.pio.PeripheralManagerService; //導入方法依賴的package包/類
public Adxl362(String spiPort) throws IOException {
    PeripheralManagerService service = new PeripheralManagerService();
    device = service.openSpiDevice(spiPort);
    connfigureSpi(device);
}
 
開發者ID:vishal-android-freak,項目名稱:ADXL362-Interfacing-Library,代碼行數:6,代碼來源:Adxl362.java

示例7: Adxl362

import com.google.android.things.pio.PeripheralManagerService; //導入方法依賴的package包/類
/**
 * Creates a new SpiDevice instance
 * @param spiPort - can be either SPI0.0 or SPI0.1 (for Raspberry Pi)
 * @param frequencyInHz - This will vary according to the peripheral to be interfaced, default should be 1MHz.
 *                      ADXL362 has a range of 1MHz to 8MHz
 * @param mode - Modes are MODE_0, MODE_1, MODE_2, MODE_3.
 *             ADXL362 works on MODE_0
 * @throws IOException
 */
public Adxl362(String spiPort, int frequencyInHz, int mode) throws IOException {
    PeripheralManagerService service = new PeripheralManagerService();
    device = service.openSpiDevice(spiPort);
    connfigureSpi(device, frequencyInHz, mode);
}
 
開發者ID:vishal-android-freak,項目名稱:ADXL362-Interfacing-Library,代碼行數:15,代碼來源:Adxl362.java


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