• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SpiDevice类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.android.things.pio.SpiDevice的典型用法代码示例。如果您正苦于以下问题:Java SpiDevice类的具体用法?Java SpiDevice怎么用?Java SpiDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SpiDevice类属于com.google.android.things.pio包,在下文中一共展示了SpiDevice类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: LedControl

import com.google.android.things.pio.SpiDevice; //导入依赖的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.SpiDevice; //导入依赖的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: TM1838Driver

import com.google.android.things.pio.SpiDevice; //导入依赖的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


示例4: SSD1306

import com.google.android.things.pio.SpiDevice; //导入依赖的package包/类
/**
 * Contructor to setup SSD1306 OLED
 * @param spiName
 * @throws IOException
 * @throws InterruptedException
 */
public SSD1306(String spiName) throws IOException, InterruptedException {
    DC_PIN = new PeripheralManagerService().openGpio("GP14");
    RST_PIN = new PeripheralManagerService().openGpio("GP15");
    spiDevice = new PeripheralManagerService().openSpiDevice(spiName);

    spiDevice.setMode(SpiDevice.MODE0);
    spiDevice.setFrequency(10000000);
    spiDevice.setBitsPerWord(8);
    spiDevice.setBitJustification(false);

    DC_PIN.setDirection(Gpio.DIRECTION_OUT_INITIALLY_HIGH);
    RST_PIN.setDirection(Gpio.DIRECTION_OUT_INITIALLY_HIGH);

    RST_PIN.setActiveType(Gpio.ACTIVE_HIGH);
    RST_PIN.setValue(true);
    Thread.sleep(5000); // VDD (3.3V) goes high at start, lets just chill for 5 ms
    RST_PIN.setActiveType(Gpio.ACTIVE_LOW);
    RST_PIN.setValue(true);
    Thread.sleep(10000); // wait 10ms
    RST_PIN.setActiveType(Gpio.ACTIVE_HIGH);
    RST_PIN.setValue(true);

    BitmapHelper.bmpToBytes(mBuffer, DATA_OFFSET,
            Bitmap.createBitmap(LCDWIDTH, LCDHEIGHT, Bitmap.Config.ARGB_8888),
            false);

    for ( byte c : INIT_PAYLOAD ) {
        command(c);
    }
}
 
开发者ID:hongcheng79,项目名称:androidthings,代码行数:37,代码来源:SSD1306.java


示例5: connfigureSpi

import com.google.android.things.pio.SpiDevice; //导入依赖的package包/类
/**
 * Configures SPI settings based on peripheral to be interfaced
 * @param device SpiDevice instance
 * @param frequencyInHz frequency in Hz. Minimum value should be 1MHz
 * @param mode MODE_0, MODE_1, MODE_2, MODE_3
 * @throws IOException
 */
private void connfigureSpi(SpiDevice device, int frequencyInHz, int mode) throws IOException {
    device.setMode(mode);
    device.setBitsPerWord(8);
    device.setFrequency(frequencyInHz);
    device.setBitJustification(false);

    mHandler.postDelayed(softRest, 1000);
}
 
开发者ID:vishal-android-freak,项目名称:ADXL362-Interfacing-Library,代码行数:16,代码来源:Adxl362.java


示例6: connfigureSpi

import com.google.android.things.pio.SpiDevice; //导入依赖的package包/类
private void connfigureSpi(SpiDevice device) throws IOException {
    device.setMode(SpiDevice.MODE0);
    device.setBitsPerWord(8);
    device.setFrequency(5000000);
    device.setBitJustification(false);

    mHandler.postDelayed(softRest, 1000);
}
 
开发者ID:vishal-android-freak,项目名称:ADXL362-Interfacing-Library,代码行数:9,代码来源:Adxl362.java


示例7: configure

import com.google.android.things.pio.SpiDevice; //导入依赖的package包/类
/**
 * Create a new Apa102 driver.
 *
 * @param device {@link SpiDevice} where the LED strip is attached to.
 * @param ledMode The {@link Mode} indicating the red/green/blue byte ordering for the device.
 */
@VisibleForTesting
/*package*/ Apa102(SpiDevice device, Mode ledMode, Direction direction) throws IOException {
    mLedMode = ledMode;
    mDirection = direction;
    mDevice = device;
    configure(mDevice);
}
 
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:14,代码来源:Apa102.java


示例8: Rc522

import com.google.android.things.pio.SpiDevice; //导入依赖的package包/类
/**
 * Initializes RC522 with the configured SPI port and pins.
 * @param spiDevice SPI port used on the board
 * @param resetPin Pin connected to the RST pin on the RC522
 */
public Rc522(SpiDevice spiDevice, Gpio resetPin) throws IOException {
    this.device = spiDevice;
    this.resetPin = resetPin;
    initializePeripherals();
}
 
开发者ID:Galarzaa90,项目名称:android-things-rc522,代码行数:11,代码来源:Rc522.java



注:本文中的com.google.android.things.pio.SpiDevice类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DBFReader类代码示例发布时间:2022-05-23
下一篇:
Java JsonParser类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap