From 71574308facb14f9894291221abfaf69e229731d Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 14 Sep 2018 11:15:21 +0100 Subject: [PATCH 1/4] Added support to specify an alternate i2c address for Cap12xx --- .../contrib/driver/cap12xx/Cap12xx.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/cap12xx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xx.java b/cap12xx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xx.java index a37da30..8191b60 100644 --- a/cap12xx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xx.java +++ b/cap12xx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xx.java @@ -192,7 +192,7 @@ public Cap12xx(Context context, String i2cName, String alertName, Configuration } /** - * Create a new Cap12xx controller. + * Create a new Cap12xx controller with the default I2C address. * * @param i2cName I2C port name where the controller is attached. Cannot be null. * @param alertName optional GPIO pin name connected to the controller's @@ -213,22 +213,37 @@ public Cap12xx(Context context, String i2cName, String alertName, Configuration this(i2cName, alertName, chip, handler); } + /** + * Create a new Cap12xx controller with the default I2C address. + * + * @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 + */ + public Cap12xx(String i2cName, String alertName, Configuration chip, Handler handler) throws IOException { + 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 i2cAddress 7-bit I2C address for the attached controller. 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 */ - public Cap12xx(String i2cName, String alertName, Configuration chip, Handler handler) + public Cap12xx(String i2cName, int i2cAddress, String alertName, Configuration chip, Handler handler) throws IOException { mChipConfiguration = chip; try { PeripheralManager manager = PeripheralManager.getInstance(); - I2cDevice device = manager.openI2cDevice(i2cName, I2C_ADDRESS); + I2cDevice device = manager.openI2cDevice(i2cName, i2cAddress); Gpio alertPin = null; if (alertName != null) { alertPin = manager.openGpio(alertName); From 3a317bd79503444fc8157384244f1935224e2546 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 14 Sep 2018 12:13:29 +0100 Subject: [PATCH 2/4] Fixed namingfrom Cap12xx to Cap1xxx --- .../google/android/things/contrib/driver/cap1xxx/Cap1xxx.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxx.java b/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxx.java index 1064ff9..12bb8f9 100644 --- a/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxx.java +++ b/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxx.java @@ -223,7 +223,7 @@ public Cap1xxx(Context context, String i2cName, String alertName, Configuration * @param handler optional {@link Handler} for software polling and callback events. * @throws IOException */ - public Cap12xx(String i2cName, String alertName, Configuration chip, Handler handler) throws IOException { + public Cap1xxx(String i2cName, String alertName, Configuration chip, Handler handler) throws IOException { this(i2cName, I2C_ADDRESS, alertName, chip, handler); } @@ -239,7 +239,7 @@ public Cap12xx(String i2cName, String alertName, Configuration chip, Handler han * @throws IOException */ - public Cap12xx(String i2cName, int i2cAddress, String alertName, Configuration chip, Handler handler) + public Cap1xxx(String i2cName, int i2cAddress, String alertName, Configuration chip, Handler handler) throws IOException { mChipConfiguration = chip; try { From 4a064fb4a5f95d0f559473665efe629d34e95a1c Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 14 Sep 2018 12:15:49 +0100 Subject: [PATCH 3/4] Fixed comments from Cap12xx to Cap1xxx --- .../google/android/things/contrib/driver/cap1xxx/Cap1xxx.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxx.java b/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxx.java index 12bb8f9..e97848a 100644 --- a/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxx.java +++ b/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxx.java @@ -214,7 +214,7 @@ public Cap1xxx(Context context, String i2cName, String alertName, Configuration } /** - * Create a new Cap12xx controller with the default I2C address. + * Create a new Cap1xxx controller with the default I2C address. * * @param i2cName I2C port name where the controller is attached. Cannot be null. * @param alertName optional GPIO pin name connected to the controller's @@ -228,7 +228,7 @@ public Cap1xxx(String i2cName, String alertName, Configuration chip, Handler han } /** - * Create a new Cap12xx controller. + * Create a new Cap1xxx controller. * * @param i2cName I2C port name where the controller is attached. Cannot be null. * @param i2cAddress 7-bit I2C address for the attached controller. Cannot be null. From 58c1bc1154c6dbd2e765f11b9f4489107d355d26 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Thu, 20 Sep 2018 14:42:59 +0100 Subject: [PATCH 4/4] Docstring changes and I2C_ADDRESS variable rename --- .../android/things/contrib/driver/cap1xxx/Cap1xxx.java | 8 ++++---- .../things/contrib/driver/cap1xxx/Cap1xxxInputDriver.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxx.java b/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxx.java index e97848a..296ba5f 100644 --- a/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxx.java +++ b/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxx.java @@ -89,7 +89,7 @@ public enum Configuration { /** * Default I2C slave address for the CAP1xxx family. */ - public static final int I2C_ADDRESS = 0x28; + public static final int DEFAULT_I2C_ADDRESS = 0x28; @Retention(RetentionPolicy.SOURCE) @IntDef({REPEAT_DISABLE, REPEAT_FAST, REPEAT_NORMAL, REPEAT_SLOW}) @@ -192,7 +192,7 @@ public Cap1xxx(Context context, String i2cName, String alertName, Configuration } /** - * Create a new Cap12xx controller with the default I2C address. + * Create a new Cap1xxx controller with the default I2C address. * * @param i2cName I2C port name where the controller is attached. Cannot be null. * @param alertName optional GPIO pin name connected to the controller's @@ -224,14 +224,14 @@ public Cap1xxx(Context context, String i2cName, String alertName, Configuration * @throws IOException */ public Cap1xxx(String i2cName, String alertName, Configuration chip, Handler handler) throws IOException { - this(i2cName, I2C_ADDRESS, alertName, chip, handler); + this(i2cName, DEFAULT_I2C_ADDRESS, alertName, chip, handler); } /** * Create a new Cap1xxx controller. * * @param i2cName I2C port name where the controller is attached. Cannot be null. - * @param i2cAddress 7-bit I2C address for the attached controller. Cannot be null. + * @param i2cAddress 7-bit I2C address for the attached controller. * @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. diff --git a/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxInputDriver.java b/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxInputDriver.java index 1dedcef..d3b026f 100644 --- a/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxInputDriver.java +++ b/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxInputDriver.java @@ -105,7 +105,7 @@ public Cap1xxxInputDriver(String i2cName, String alertName, Configuration chip, * framework. * * @param i2cName I2C port name where the controller is attached. Cannot be null. - * @param i2cAddress 7-bit I2C address for the attached controller. Cannot be null. + * @param i2cAddress 7-bit I2C address for the attached controller. * @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.