The Spirit installation at Google I/O was given hardware controls powered by Android Things.
Each of the sliders and dials are pushed into our Intel Edison board running Android Things via 3 analog digital converters available on Sparkfun.
We were able to interface these blocks via a newly created driver: Adcv2x, now part of the contrib library for Things.
For every ADC board you want to use, you need to first instantiate an Adcv2x:
final Adcv2x upperAdc = new Adcv2x(Adcv2x.DEFAULT_BUS, Adcv2x.I2C_ADDRESS_48);Every ADC board from Sparkfun has 4 available solderable addresses, available as static constants, meaning that Android Things can have up to 16 analog devices interfaced at once.
Once you have a ref to each Adcv2x, we implemented a simple wrapper class to make reading from specific channels and their associated name, and getting the normalized value back easier.
mAnalogDevices.add(new AdcWrapper(upperAdc, 3, "curlSize"));
mAnalogDevices.add(new AdcWrapper(upperAdc, 2, "radius"));
mAnalogDevices.add(new AdcWrapper(upperAdc, 1, "dieSpeed"));
mAnalogDevices.add(new AdcWrapper(upperAdc, 0, "speed"));Then we just read the voltage of each input in a loop via a Handler, and determine if the change was large enough to warrant updating our Firebase Realtime Database, so we don't spam it.
The names associated with each AdcWrapper correspond exactly to our values in the Firebase Realtime Database:
The slightly modified fork of The Spirit then uses dat.fire to automagically update its dat.gui interface with values being updated by this controller.

