Java源码示例:com.google.android.things.contrib.driver.apa102.Apa102

示例1
@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);
    }
}
 
示例2
/**
 * 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();
}
 
示例3
public static Apa102 openLedStrip() throws IOException {
    return new Apa102(BOARD.getSpiBus(), Apa102.Mode.BGR);
}