Revisiting Rainbow HAT components
Following the same approach as for GPIO and PWM, we are going to start by removing the Rainbow HAT meta driver from our dependencies and using the specific drivers of the components directly. This time the components are the alphanumeric display and the temperature and pressure sensor.
Alphanumeric display (Ht16k33)
The driver for the alphanumeric display is called driver-ht16k33
, so we just need to add it to our build.gradle
:
dependencies { [...] implementation 'com.google.android.things.contrib:driver-ht16k33:+' }
The only difference with the code we used before is that we now have to construct an object of type AlphanumericDisplay
passing the I2C bus name, which we can initialize using one of the patterns described earlier; either BoardDefaults
or getI2CBus()
.
val display = AlphanumericDisplay(i2cBusName) display.setEnabled(true) [...]
And that's it; the rest of the interaction with the alphanumeric display is exactly the same as we did before.