com.google.android.things.contrib.driver.apa102.Apa102 Java Examples

The following examples show how to use com.google.android.things.contrib.driver.apa102.Apa102. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java    From drivers-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "APA102 MainActivity created");

    mPioThread = new HandlerThread("pioThread");
    mPioThread.start();

    mHandler = new Handler(mPioThread.getLooper());

    mLedColors = new int[NUM_LEDS];
    try {
        Log.d(TAG, "Initializing LED strip");
        mLedstrip = new Apa102(BoardDefaults.getSPIPort(), LED_MODE);
        mLedstrip.setBrightness(LED_BRIGHTNESS);
        mHandler.post(mAnimateRunnable);
    } catch (IOException e) {
        Log.e(TAG, "Error initializing LED strip", e);
    }
}
 
Example #2
Source File: RainbowHatInstrumentationTest.java    From contrib-drivers with Apache License 2.0 5 votes vote down vote up
/**
 * Opens Apa102 LED strip and writes colors to it.
 */
@Test
public void testLedStrip() throws IOException {
    Apa102 ledStrip = RainbowHat.openLedStrip();
    ledStrip.write(new int[] {Color.BLUE, Color.BLUE, Color.BLUE, Color.BLUE,
        Color.BLUE, Color.BLUE, Color.BLUE});
    ledStrip.write(new int[] {Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK,
        Color.BLACK, Color.BLACK, Color.BLACK});
    ledStrip.close();
}
 
Example #3
Source File: RainbowHat.java    From contrib-drivers with Apache License 2.0 4 votes vote down vote up
public static Apa102 openLedStrip() throws IOException {
    return new Apa102(BOARD.getSpiBus(), Apa102.Mode.BGR);
}