LED strip
As we have done in previous chapters, let's remove the dependency of the Rainbow HAT meta driver and add only the driver that we need. In the case of the RGB LED strip, that driver is called driver-apa102
:
dependencies { implementation 'com.google.android.things.contrib:driver-apa102:+' }
And, as we have been doing so far, let's use a BoardDefaults
object to be able to run our code independently of the developer kit pinout naming:
val spiBus: String get() = when (Build.DEVICE) { DEVICE_RPI3 ->"SPI0.0" DEVICE_IMX7D_PICO ->"SPI3.1" else -> throw IllegalStateException("Unknown Build.DEVICE ${Build.DEVICE}") }
There are a couple of important things to note here. First is that the exposed SPI bus on the Raspberry Pi is called 0, while the iMX7D one is 3. It is also important to note that the order of the chip select pins on both boards is reversed: SS1 and SS0 are swapped. That is why the iMX7D has the bus SPI3.1
, while the Raspberry Pi has SPI0.0
when using the Rainbow...