You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While sitting down with @proppy yesterday and getting something of a crash course in building drivers for Things, we ran into an omission in the cap1xxx library.
The cap1xxx range support at least 5 different i2c address that I'm aware of, via the use of a pull-down address select resistor:
Resistor
Address
82k
0x2c
100k
0x2b
120k
0x2a
150k
0x29
VDD
0x28
The hard-coded address needs substituting with an optional constructor for supplying one of the above resistor-selected values:
I have local code working with alternate i2c addresses (Pimoroni Drum HAT uses 0x2c) which looks like this:
publicCap12xx(Stringi2cName, StringalertName, Configurationchip, Handlerhandler) throwsIOException {
this(i2cName, I2C_ADDRESS, alertName, chip, handler);
}
/** * Create a new Cap12xx controller. * * @param i2cName I2C port name where the controller is attached. Cannot be null. * @param alertName optional GPIO pin name connected to the controller's * alert interrupt signal. Can be null. * @param chip identifier for the connected controller device chip. * @param handler optional {@link Handler} for software polling and callback events. * @throws IOException */publicCap12xx(Stringi2cName, inti2cAddress, StringalertName, Configurationchip, Handlerhandler)
throwsIOException {
mChipConfiguration = chip;
try {
PeripheralManagermanager = PeripheralManager.getInstance();
I2cDevicedevice = manager.openI2cDevice(i2cName, i2cAddress);
GpioalertPin = null;
if (alertName != null) {
alertPin = manager.openGpio(alertName);
}
init(device, alertPin, chip, handler);
} catch (IOException|RuntimeExceptione) {
// Close the peripherals if an init error occurstry {
close();
} catch (IOException|RuntimeExceptionignored) {
}
throwe;
}
}
I'm happy to raise a PR, but since this is my first Java rodeo my code may be a little rough around the edges and I'm currently missing tests for this feature.
The text was updated successfully, but these errors were encountered:
While sitting down with @proppy yesterday and getting something of a crash course in building drivers for Things, we ran into an omission in the cap1xxx library.
The cap1xxx range support at least 5 different i2c address that I'm aware of, via the use of a pull-down address select resistor:
The hard-coded address needs substituting with an optional constructor for supplying one of the above resistor-selected values:
contrib-drivers/cap12xx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xx.java
Line 231 in 69d9317
I have local code working with alternate i2c addresses (Pimoroni Drum HAT uses
0x2c
) which looks like this:I'm happy to raise a PR, but since this is my first Java rodeo my code may be a little rough around the edges and I'm currently missing tests for this feature.
The text was updated successfully, but these errors were encountered: