From 73f09b7e87d53e98ac919a6c2be3464af7cbcf56 Mon Sep 17 00:00:00 2001 From: Sarah Wittman Date: Wed, 18 Jul 2018 09:42:18 -0700 Subject: [PATCH] Rename cap12xx to cap1xxx, and update/deprecate old artifact. Change-Id: I34d57226dcb2961980968c7965ca926d100b96b6 --- {cap12xx => cap1xxx}/CHANGELOG.md | 5 ++ {cap12xx => cap1xxx}/README.md | 28 +++--- {cap12xx => cap1xxx}/build.gradle | 0 {cap12xx => cap1xxx}/gradle.properties | 2 +- .../src/androidTest/AndroidManifest.xml | 4 +- .../Cap1xxxInputDriverInstrumentedTest.java | 10 +-- .../driver/cap1xxx/Cap1xxxTestActivity.java | 12 +-- .../src/main/AndroidManifest.xml | 2 +- .../contrib/driver/cap12xx/Cap12xx.java | 80 +++++++++++++++++ .../driver/cap12xx/Cap12xxInputDriver.java | 89 +++++++++++++++++++ .../contrib/driver/cap1xxx}/BitwiseUtil.java | 2 +- .../contrib/driver/cap1xxx/Cap1xxx.java | 28 +++--- .../driver/cap1xxx/Cap1xxxInputDriver.java | 62 ++++++------- .../driver/cap1xxx}/ArrayFillingAnswer.java | 2 +- .../cap1xxx}/ArrayFillingAnswerTest.java | 2 +- .../driver/cap1xxx}/BitwiseUtilTest.java | 2 +- .../contrib/driver/cap1xxx/Cap1xxxTest.java | 58 ++++++------ settings.gradle | 2 +- 18 files changed, 282 insertions(+), 108 deletions(-) rename {cap12xx => cap1xxx}/CHANGELOG.md (86%) rename {cap12xx => cap1xxx}/README.md (82%) rename {cap12xx => cap1xxx}/build.gradle (100%) rename {cap12xx => cap1xxx}/gradle.properties (60%) rename {cap12xx => cap1xxx}/src/androidTest/AndroidManifest.xml (87%) rename cap12xx/src/androidTest/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxInputDriverInstrumentedTest.java => cap1xxx/src/androidTest/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxInputDriverInstrumentedTest.java (74%) rename cap12xx/src/androidTest/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxTestActivity.java => cap1xxx/src/androidTest/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxTestActivity.java (94%) rename {cap12xx => cap1xxx}/src/main/AndroidManifest.xml (92%) create mode 100644 cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xx.java create mode 100644 cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxInputDriver.java rename {cap12xx/src/main/java/com/google/android/things/contrib/driver/cap12xx => cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx}/BitwiseUtil.java (96%) rename cap12xx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xx.java => cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxx.java (96%) rename cap12xx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxInputDriver.java => cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxInputDriver.java (78%) rename {cap12xx/src/sharedTest/java/com/google/android/things/contrib/driver/cap12xx => cap1xxx/src/sharedTest/java/com/google/android/things/contrib/driver/cap1xxx}/ArrayFillingAnswer.java (94%) rename {cap12xx/src/test/java/com/google/android/things/contrib/driver/cap12xx => cap1xxx/src/test/java/com/google/android/things/contrib/driver/cap1xxx}/ArrayFillingAnswerTest.java (97%) rename {cap12xx/src/test/java/com/google/android/things/contrib/driver/cap12xx => cap1xxx/src/test/java/com/google/android/things/contrib/driver/cap1xxx}/BitwiseUtilTest.java (97%) rename cap12xx/src/test/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxTest.java => cap1xxx/src/test/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxTest.java (87%) diff --git a/cap12xx/CHANGELOG.md b/cap1xxx/CHANGELOG.md similarity index 86% rename from cap12xx/CHANGELOG.md rename to cap1xxx/CHANGELOG.md index 53b9696..09cfedf 100644 --- a/cap12xx/CHANGELOG.md +++ b/cap1xxx/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## [2.0] - 2018-07-16 +### Updated +- renamed to Cap1xxx +- deprecated Cap12xx artifact + ## [1.0] - 2018-05-05 ### Updated - update to Android Things 1.0 diff --git a/cap12xx/README.md b/cap1xxx/README.md similarity index 82% rename from cap12xx/README.md rename to cap1xxx/README.md index b97dd34..a3a83d7 100644 --- a/cap12xx/README.md +++ b/cap1xxx/README.md @@ -1,4 +1,4 @@ -CAP12XX driver for Android Things +CAP1XXX driver for Android Things ================================= This driver supports capacitive touch controls build on the CAP12XX family of chips @@ -15,33 +15,33 @@ How to use the driver ### Gradle dependency -To use the `cap12xx` driver, simply add the line below to your project's `build.gradle`, +To use the `cap1xxx` driver, simply add the line below to your project's `build.gradle`, where `` matches the last version of the driver available on [jcenter][jcenter]. ``` dependencies { - compile 'com.google.android.things.contrib:driver-cap12xx:' + implementation 'com.google.android.things.contrib:driver-cap1xxx:' } ``` ### Sample usage ```java -import com.google.android.things.contrib.driver.cap12xx.Cap12xx; +import com.google.android.things.contrib.driver.cap1xxx.Cap1xxx; // Access the capacitive touch control: -Cap12xx mCapTouchControl; +Cap1xxx mCapTouchControl; try { - mCapTouchControl = new Cap12xx( + mCapTouchControl = new Cap1xxx( i2cBusName, // required I2C gpioPinName, // optional GPIO for interrupt alerts - Cap12xx.Configuration.CAP1208 // choose whichever matches your chip + Cap1xxx.Configuration.CAP1208 // choose whichever matches your chip ); - mCapTouchControl.setOnCapTouchListener(new Cap12xx.OnCapTouchListener() { + mCapTouchControl.setOnCapTouchListener(new Cap1xxx.OnCapTouchListener() { @Override - public void onCapTouchEvent(Cap12xx controller, boolean[] inputStatus) { + public void onCapTouchEvent(Cap1xxx controller, boolean[] inputStatus) { // do something awesome } }); @@ -65,19 +65,19 @@ with the system and receive `KeyEvent`s using the standard Android APIs: int[] keyCodes = new int[] { KevEvent.KEYCODE_1, KevEvent.KEYCODE_2, ... KevEvent.KEYCODE_8 }; -Cap12xxInputDriver mInputDriver; +Cap1xxxInputDriver mInputDriver; try { - mInputDriver = new Cap12xxInputDriver( + mInputDriver = new Cap1xxxInputDriver( this, // context i2cBusName, null, - Cap12xx.Configuration.CAP1208, // 8 input channels + Cap1xxx.Configuration.CAP1208, // 8 input channels keyCodes // keycodes mapped to input channels ); // Disable repeated events - mInputDriver.setRepeatRate(Cap12xx.REPEAT_DISABLE); + mInputDriver.setRepeatRate(Cap1xxx.REPEAT_DISABLE); // Block touches above 4 unique inputs mInputDriver.setMultitouchInputMax(4); @@ -129,4 +129,4 @@ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -[jcenter]: https://bintray.com/google/androidthings/contrib-driver-cap12xx/_latestVersion +[jcenter]: https://bintray.com/google/androidthings/contrib-driver-cap1xxx/_latestVersion diff --git a/cap12xx/build.gradle b/cap1xxx/build.gradle similarity index 100% rename from cap12xx/build.gradle rename to cap1xxx/build.gradle diff --git a/cap12xx/gradle.properties b/cap1xxx/gradle.properties similarity index 60% rename from cap12xx/gradle.properties rename to cap1xxx/gradle.properties index 6f1f88b..134b20c 100644 --- a/cap12xx/gradle.properties +++ b/cap1xxx/gradle.properties @@ -1,2 +1,2 @@ TYPE="capacitive touch buttons" -ARTIFACT_VERSION=1.0 +ARTIFACT_VERSION=2.0 diff --git a/cap12xx/src/androidTest/AndroidManifest.xml b/cap1xxx/src/androidTest/AndroidManifest.xml similarity index 87% rename from cap12xx/src/androidTest/AndroidManifest.xml rename to cap1xxx/src/androidTest/AndroidManifest.xml index da7597f..7324d85 100644 --- a/cap12xx/src/androidTest/AndroidManifest.xml +++ b/cap1xxx/src/androidTest/AndroidManifest.xml @@ -14,11 +14,11 @@ limitations under the License. --> + package="com.google.android.things.contrib.driver.cap1xxx"> - + diff --git a/cap12xx/src/androidTest/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxInputDriverInstrumentedTest.java b/cap1xxx/src/androidTest/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxInputDriverInstrumentedTest.java similarity index 74% rename from cap12xx/src/androidTest/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxInputDriverInstrumentedTest.java rename to cap1xxx/src/androidTest/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxInputDriverInstrumentedTest.java index b0cde5f..d35bec3 100644 --- a/cap12xx/src/androidTest/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxInputDriverInstrumentedTest.java +++ b/cap1xxx/src/androidTest/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxInputDriverInstrumentedTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.things.contrib.driver.cap12xx; +package com.google.android.things.contrib.driver.cap1xxx; import android.support.test.rule.ActivityTestRule; @@ -22,15 +22,15 @@ import java.io.IOException; -public class Cap12xxInputDriverInstrumentedTest { +public class Cap1xxxInputDriverInstrumentedTest { @Rule - public ActivityTestRule mActivityRule - = new ActivityTestRule<>(Cap12xxTestActivity.class); + public ActivityTestRule mActivityRule + = new ActivityTestRule<>(Cap1xxxTestActivity.class); @Test public void buttonDriverInjectsKeyEvents() throws IOException { - Cap12xxTestActivity activity = mActivityRule.getActivity(); + Cap1xxxTestActivity activity = mActivityRule.getActivity(); activity.testKeyEvents(); } } diff --git a/cap12xx/src/androidTest/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxTestActivity.java b/cap1xxx/src/androidTest/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxTestActivity.java similarity index 94% rename from cap12xx/src/androidTest/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxTestActivity.java rename to cap1xxx/src/androidTest/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxTestActivity.java index 80708ed..6feb006 100644 --- a/cap12xx/src/androidTest/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxTestActivity.java +++ b/cap1xxx/src/androidTest/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxTestActivity.java @@ -26,7 +26,7 @@ import android.util.Log; import android.view.KeyEvent; -import com.google.android.things.contrib.driver.cap12xx.Cap12xx.Configuration; +import com.google.android.things.contrib.driver.cap1xxx.Cap1xxx.Configuration; import com.google.android.things.pio.I2cDevice; import org.mockito.Mockito; @@ -38,7 +38,7 @@ public class Cap12xxTestActivity extends Activity { - private static final String TAG = "Cap12xxTestActivity"; + private static final String TAG = "Cap1xxxTestActivity"; static final Configuration CONFIGURATION = Configuration.CAP1208; static final int[] KEYCODES = { @@ -60,8 +60,8 @@ public class Cap12xxTestActivity extends Activity { new ArrayFillingAnswer((byte) 0); private I2cDevice mI2c; - private Cap12xx mCap12xx; - private Cap12xxInputDriver mInputDriver; + private Cap1xxx mCap1xxx; + private Cap1xxxInputDriver mInputDriver; private BlockingQueue mKeyDownEvents = new LinkedBlockingQueue<>(); private BlockingQueue mKeyUpEvents = new LinkedBlockingQueue<>(); @@ -81,8 +81,8 @@ protected void onCreate(Bundle savedInstanceState) { try { mI2c = initMockI2cDevice(); - mCap12xx = new Cap12xx(mI2c, null, Configuration.CAP1208); - mInputDriver = new Cap12xxInputDriver(mCap12xx, KEYCODES); + mCap1xxx = new Cap1xxx(mI2c, null, Configuration.CAP1208); + mInputDriver = new Cap12xxInputDriver(mCap1xxx, KEYCODES); } catch (IOException e) { throw new RuntimeException("Error initializing input driver", e); } diff --git a/cap12xx/src/main/AndroidManifest.xml b/cap1xxx/src/main/AndroidManifest.xml similarity index 92% rename from cap12xx/src/main/AndroidManifest.xml rename to cap1xxx/src/main/AndroidManifest.xml index 4e5ef73..16eebcb 100644 --- a/cap12xx/src/main/AndroidManifest.xml +++ b/cap1xxx/src/main/AndroidManifest.xml @@ -15,7 +15,7 @@ limitations under the License. --> + package="com.google.android.things.contrib.driver.cap1xxx"> diff --git a/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xx.java b/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xx.java new file mode 100644 index 0000000..0731781 --- /dev/null +++ b/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xx.java @@ -0,0 +1,80 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.android.things.contrib.driver.cap12xx; + +import android.content.Context; +import android.os.Handler; + +import com.google.android.things.contrib.driver.cap1xxx.Cap1xxx; + +import java.io.IOException; + +/** + * Driver for the Microchip CAP12xx Capacitive Touch Controller + * e.g. http://www.microchip.com/wwwproducts/en/CAP1208 + * @deprecated Use {@link Cap1xxx} instead. + */ +@Deprecated +@SuppressWarnings("WeakerAccess") +public class Cap12xx extends Cap1xxx { + private static final String TAG = "Cap12xx"; + + /** + * @deprecated Use {@link #Cap12xx(String, String, Configuration)} instead. + */ + @Deprecated + public Cap12xx(Context context, String i2cName, String alertName, Configuration chip) throws IOException { + this(i2cName, alertName, chip, null); + } + + /** + * Create a new Cap1xxx 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. + * @throws IOException + */ + public Cap12xx(String i2cName, String alertName, Configuration chip) throws IOException { + this(i2cName, alertName, chip, null); + } + + /** + * @deprecated Use {@link #Cap12xx(String, String, Configuration, Handler)} instead. + */ + @Deprecated + public Cap12xx(Context context, String i2cName, String alertName, Configuration chip, + Handler handler) throws IOException { + this(i2cName, alertName, chip, handler); + } + + /** + * Create a new Cap1xxx 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 + */ + public Cap12xx(String i2cName, String alertName, Configuration chip, Handler handler) + throws IOException { + super(i2cName, alertName, chip, handler); + } +} diff --git a/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxInputDriver.java b/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxInputDriver.java new file mode 100644 index 0000000..3b1e02a --- /dev/null +++ b/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxInputDriver.java @@ -0,0 +1,89 @@ +/* + * Copyright 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.android.things.contrib.driver.cap12xx; + +import android.content.Context; +import android.os.Handler; +import android.view.KeyEvent; + +import com.google.android.things.contrib.driver.cap1xxx.Cap1xxx.Configuration; +import com.google.android.things.contrib.driver.cap1xxx.Cap1xxxInputDriver; + +import java.io.IOException; + +/** + * User-space driver to process capacitive touch events from the + * CAP12xx family of touch controllers and forward them to the + * Android input framework. + * @deprecated Use {@link Cap1xxxInputDriver} instead. + */ +@Deprecated +@SuppressWarnings("WeakerAccess") +public class Cap12xxInputDriver extends Cap1xxxInputDriver { + private static final String TAG = "Cap12xxInputDriver"; + + /** + * @deprecated Use {@link #Cap12xxInputDriver(String, String, Configuration, int[])} instead. + */ + @Deprecated + public Cap12xxInputDriver(Context context, String i2cName, String alertName, Configuration chip, + int[] keyCodes) throws IOException { + this(i2cName, alertName, chip, null, keyCodes); + } + + /** + * Create a new Cap1xxxInputDriver to forward capacitive touch events to the Android input + * framework. + * + * @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 keyCodes {@link KeyEvent} codes to be emitted for each input channel. Length must + * match the input channel count of the Configuration {@code chip}. + */ + public Cap12xxInputDriver(String i2cName, String alertName, Configuration chip, int[] keyCodes) + throws IOException { + this(i2cName, alertName, chip, null, keyCodes); + } + + /** + * @deprecated Use {@link #Cap12xxInputDriver(String, String, Configuration, Handler, int[])} instead. + */ + @Deprecated + public Cap12xxInputDriver(Context context, String i2cName, String alertName, Configuration chip, + Handler handler, int[] keyCodes) throws IOException { + this(i2cName, alertName, chip, handler, keyCodes); + } + + /** + * Create a new Cap1xxxInputDriver to forward capacitive touch events to the Android input + * framework. + * + * @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. + * @param keyCodes {@link KeyEvent} codes to be emitted for each input channel. Length must + * match the input channel count of the Configuration {@code chip}. + */ + public Cap12xxInputDriver(String i2cName, String alertName, Configuration chip, Handler handler, + int[] keyCodes) throws IOException { + super(i2cName, alertName, chip, handler, keyCodes); + } +} diff --git a/cap12xx/src/main/java/com/google/android/things/contrib/driver/cap12xx/BitwiseUtil.java b/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/BitwiseUtil.java similarity index 96% rename from cap12xx/src/main/java/com/google/android/things/contrib/driver/cap12xx/BitwiseUtil.java rename to cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/BitwiseUtil.java index 6522055..fa03f3d 100644 --- a/cap12xx/src/main/java/com/google/android/things/contrib/driver/cap12xx/BitwiseUtil.java +++ b/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/BitwiseUtil.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.android.things.contrib.driver.cap12xx; +package com.google.android.things.contrib.driver.cap1xxx; /** * Collection of helpers for bitwise operations diff --git a/cap12xx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xx.java b/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxx.java similarity index 96% rename from cap12xx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xx.java rename to cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxx.java index a37da30..da56482 100644 --- a/cap12xx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xx.java +++ b/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxx.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.android.things.contrib.driver.cap12xx; +package com.google.android.things.contrib.driver.cap1xxx; import android.content.Context; import android.os.Handler; @@ -33,12 +33,12 @@ import java.lang.annotation.RetentionPolicy; /** - * Driver for the Microchip CAP12xx Capacitive Touch Controller + * Driver for the Microchip CAP1xxx Capacitive Touch Controller * e.g. http://www.microchip.com/wwwproducts/en/CAP1208 */ @SuppressWarnings("WeakerAccess") -public class Cap12xx implements AutoCloseable { - private static final String TAG = "Cap12xx"; +public class Cap1xxx implements AutoCloseable { + private static final String TAG = "Cap1xxx"; /** * Interface definition for a callback to be invoked when @@ -53,7 +53,7 @@ public interface OnCapTouchListener { * @param inputStatus array of input states. An input will report * true when touched, false otherwise */ - void onCapTouchEvent(Cap12xx controller, boolean[] inputStatus); + void onCapTouchEvent(Cap1xxx controller, boolean[] inputStatus); } /** @@ -184,15 +184,15 @@ public enum Configuration { private byte[] mInputThresholds; /** - * @deprecated Use {@link #Cap12xx(String, String, Configuration)} instead. + * @deprecated Use {@link #Cap1xxx(String, String, Configuration)} instead. */ @Deprecated - public Cap12xx(Context context, String i2cName, String alertName, Configuration chip) throws IOException { + public Cap1xxx(Context context, String i2cName, String alertName, Configuration chip) throws IOException { this(i2cName, alertName, chip, null); } /** - * Create a new Cap12xx controller. + * Create a new Cap1xxx 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 @@ -200,21 +200,21 @@ public Cap12xx(Context context, String i2cName, String alertName, Configuration * @param chip identifier for the connected controller device chip. * @throws IOException */ - public Cap12xx(String i2cName, String alertName, Configuration chip) throws IOException { + public Cap1xxx(String i2cName, String alertName, Configuration chip) throws IOException { this(i2cName, alertName, chip, null); } /** - * @deprecated Use {@link #Cap12xx(String, String, Configuration, Handler)} instead. + * @deprecated Use {@link #Cap1xxx(String, String, Configuration, Handler)} instead. */ @Deprecated - public Cap12xx(Context context, String i2cName, String alertName, Configuration chip, + public Cap1xxx(Context context, String i2cName, String alertName, Configuration chip, Handler handler) throws IOException { this(i2cName, alertName, chip, handler); } /** - * Create a new Cap12xx controller. + * Create a new Cap1xxx 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 @@ -223,7 +223,7 @@ public Cap12xx(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) + public Cap1xxx(String i2cName, String alertName, Configuration chip, Handler handler) throws IOException { mChipConfiguration = chip; try { @@ -248,7 +248,7 @@ public Cap12xx(String i2cName, String alertName, Configuration chip, Handler han * Constructor invoked from unit tests. */ @VisibleForTesting - /*package*/ Cap12xx(I2cDevice i2cDevice, Gpio alertPin, Configuration chip) throws IOException { + /*package*/ Cap1xxx(I2cDevice i2cDevice, Gpio alertPin, Configuration chip) throws IOException { mChipConfiguration = chip; init(i2cDevice, alertPin, chip, null); } diff --git a/cap12xx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxInputDriver.java b/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxInputDriver.java similarity index 78% rename from cap12xx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxInputDriver.java rename to cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxInputDriver.java index 12a388e..6b8f2f2 100644 --- a/cap12xx/src/main/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxInputDriver.java +++ b/cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxInputDriver.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.android.things.contrib.driver.cap12xx; +package com.google.android.things.contrib.driver.cap1xxx; import android.content.Context; import android.os.Handler; @@ -23,7 +23,7 @@ import android.view.InputDevice; import android.view.KeyEvent; -import com.google.android.things.contrib.driver.cap12xx.Cap12xx.Configuration; +import com.google.android.things.contrib.driver.cap1xxx.Cap1xxx.Configuration; import com.google.android.things.userdriver.input.InputDriver; import com.google.android.things.userdriver.UserDriverManager; @@ -32,33 +32,33 @@ /** * User-space driver to process capacitive touch events from the - * CAP12xx family of touch controllers and forward them to the + * CAP1xxx family of touch controllers and forward them to the * Android input framework. */ @SuppressWarnings("WeakerAccess") -public class Cap12xxInputDriver implements AutoCloseable { - private static final String TAG = "Cap12xxInputDriver"; +public class Cap1xxxInputDriver implements AutoCloseable { + private static final String TAG = "Cap1xxxInputDriver"; // Driver parameters - private static final String DRIVER_NAME = "Cap12xx"; + private static final String DRIVER_NAME = "Cap1xxx"; - private Cap12xx mPeripheralDevice; + private Cap1xxx mPeripheralDevice; // Framework input driver private InputDriver mInputDriver; // Key codes mapped to input channels private int[] mKeycodes; /** - * @deprecated Use {@link #Cap12xxInputDriver(String, String, Configuration, int[])} instead. + * @deprecated Use {@link #Cap1xxxInputDriver(String, String, Configuration, int[])} instead. */ @Deprecated - public Cap12xxInputDriver(Context context, String i2cName, String alertName, Configuration chip, + public Cap1xxxInputDriver(Context context, String i2cName, String alertName, Configuration chip, int[] keyCodes) throws IOException { this(i2cName, alertName, chip, null, keyCodes); } /** - * Create a new Cap12xxInputDriver to forward capacitive touch events to the Android input + * Create a new Cap1xxxInputDriver to forward capacitive touch events to the Android input * framework. * * @param i2cName I2C port name where the controller is attached. Cannot be null. @@ -68,22 +68,22 @@ public Cap12xxInputDriver(Context context, String i2cName, String alertName, Con * @param keyCodes {@link KeyEvent} codes to be emitted for each input channel. Length must * match the input channel count of the Configuration {@code chip}. */ - public Cap12xxInputDriver(String i2cName, String alertName, Configuration chip, int[] keyCodes) + public Cap1xxxInputDriver(String i2cName, String alertName, Configuration chip, int[] keyCodes) throws IOException { this(i2cName, alertName, chip, null, keyCodes); } /** - * @deprecated Use {@link #Cap12xxInputDriver(String, String, Configuration, Handler, int[])} instead. + * @deprecated Use {@link #Cap1xxxInputDriver(String, String, Configuration, Handler, int[])} instead. */ @Deprecated - public Cap12xxInputDriver(Context context, String i2cName, String alertName, Configuration chip, + public Cap1xxxInputDriver(Context context, String i2cName, String alertName, Configuration chip, Handler handler, int[] keyCodes) throws IOException { this(i2cName, alertName, chip, handler, keyCodes); } /** - * Create a new Cap12xxInputDriver to forward capacitive touch events to the Android input + * Create a new Cap1xxxInputDriver to forward capacitive touch events to the Android input * framework. * * @param i2cName I2C port name where the controller is attached. Cannot be null. @@ -94,9 +94,9 @@ public Cap12xxInputDriver(Context context, String i2cName, String alertName, Con * @param keyCodes {@link KeyEvent} codes to be emitted for each input channel. Length must * match the input channel count of the Configuration {@code chip}. */ - public Cap12xxInputDriver(String i2cName, String alertName, Configuration chip, Handler handler, + public Cap1xxxInputDriver(String i2cName, String alertName, Configuration chip, Handler handler, int[] keyCodes) throws IOException { - Cap12xx peripheral = new Cap12xx(i2cName, alertName, chip, handler); + Cap1xxx peripheral = new Cap1xxx(i2cName, alertName, chip, handler); init(peripheral, keyCodes); } @@ -104,14 +104,14 @@ public Cap12xxInputDriver(String i2cName, String alertName, Configuration chip, * Constructor invoked from unit tests. */ @VisibleForTesting - /*package*/ Cap12xxInputDriver(Cap12xx peripheral, int[] keyCodes) throws IOException { + /*package*/ Cap1xxxInputDriver(Cap1xxx peripheral, int[] keyCodes) throws IOException { init(peripheral, keyCodes); } /** * Initialize peripheral defaults from the constructor. */ - private void init(Cap12xx peripheral, int[] keyCodes) { + private void init(Cap1xxx peripheral, int[] keyCodes) { // Verify inputs if (keyCodes == null) { throw new IllegalArgumentException("Must provide a valid set of key codes."); @@ -124,19 +124,19 @@ private void init(Cap12xx peripheral, int[] keyCodes) { /** * Set the repeat rate of generated events on active input channels. - * Can be one of {@link Cap12xx#REPEAT_NORMAL}, {@link Cap12xx#REPEAT_FAST}, or - * {@link Cap12xx#REPEAT_SLOW} to generate continuous events while any of + * Can be one of {@link Cap1xxx#REPEAT_NORMAL}, {@link Cap1xxx#REPEAT_FAST}, or + * {@link Cap1xxx#REPEAT_SLOW} to generate continuous events while any of * the input channels are actively detecting touch input. * - *

Use {@link Cap12xx#REPEAT_DISABLE} to generate a single event for each - * input touch and release. The default is {@link Cap12xx#REPEAT_NORMAL}. + *

Use {@link Cap1xxx#REPEAT_DISABLE} to generate a single event for each + * input touch and release. The default is {@link Cap1xxx#REPEAT_NORMAL}. * - * @param rate one of {@link Cap12xx#REPEAT_NORMAL}, {@link Cap12xx#REPEAT_SLOW}, - * {@link Cap12xx#REPEAT_FAST}, or {@link Cap12xx#REPEAT_DISABLE}. + * @param rate one of {@link Cap1xxx#REPEAT_NORMAL}, {@link Cap1xxx#REPEAT_SLOW}, + * {@link Cap1xxx#REPEAT_FAST}, or {@link Cap1xxx#REPEAT_DISABLE}. * * @throws IOException */ - public void setRepeatRate(@Cap12xx.RepeatRate int rate) throws IOException { + public void setRepeatRate(@Cap1xxx.RepeatRate int rate) throws IOException { if (mPeripheralDevice != null) { mPeripheralDevice.setRepeatRate(rate); } @@ -145,14 +145,14 @@ public void setRepeatRate(@Cap12xx.RepeatRate int rate) throws IOException { /** * Set the detection sensitivity of the capacitive input channels. * - *

The default is {@link Cap12xx#SENSITIVITY_NORMAL}. + *

The default is {@link Cap1xxx#SENSITIVITY_NORMAL}. * - * @param sensitivity one of {@link Cap12xx#SENSITIVITY_NORMAL}, - * {@link Cap12xx#SENSITIVITY_LOW}, or {@link Cap12xx#SENSITIVITY_HIGH}. + * @param sensitivity one of {@link Cap1xxx#SENSITIVITY_NORMAL}, + * {@link Cap1xxx#SENSITIVITY_LOW}, or {@link Cap1xxx#SENSITIVITY_HIGH}. * * @throws IOException */ - public void setSensitivity(@Cap12xx.Sensitivity int sensitivity) throws IOException { + public void setSensitivity(@Cap1xxx.Sensitivity int sensitivity) throws IOException { if (mPeripheralDevice != null) { mPeripheralDevice.setSensitivity(sensitivity); } @@ -177,9 +177,9 @@ public void setMultitouchInputMax(int count) throws IOException { * Callback invoked when touch events are received from * the peripheral device. */ - private Cap12xx.OnCapTouchListener mTouchListener = new Cap12xx.OnCapTouchListener() { + private Cap1xxx.OnCapTouchListener mTouchListener = new Cap1xxx.OnCapTouchListener() { @Override - public void onCapTouchEvent(Cap12xx controller, boolean[] inputStatus) { + public void onCapTouchEvent(Cap1xxx controller, boolean[] inputStatus) { emitInputEvents(inputStatus); } }; diff --git a/cap12xx/src/sharedTest/java/com/google/android/things/contrib/driver/cap12xx/ArrayFillingAnswer.java b/cap1xxx/src/sharedTest/java/com/google/android/things/contrib/driver/cap1xxx/ArrayFillingAnswer.java similarity index 94% rename from cap12xx/src/sharedTest/java/com/google/android/things/contrib/driver/cap12xx/ArrayFillingAnswer.java rename to cap1xxx/src/sharedTest/java/com/google/android/things/contrib/driver/cap1xxx/ArrayFillingAnswer.java index 024c8fd..6e640b1 100644 --- a/cap12xx/src/sharedTest/java/com/google/android/things/contrib/driver/cap12xx/ArrayFillingAnswer.java +++ b/cap1xxx/src/sharedTest/java/com/google/android/things/contrib/driver/cap1xxx/ArrayFillingAnswer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.things.contrib.driver.cap12xx; +package com.google.android.things.contrib.driver.cap1xxx; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; diff --git a/cap12xx/src/test/java/com/google/android/things/contrib/driver/cap12xx/ArrayFillingAnswerTest.java b/cap1xxx/src/test/java/com/google/android/things/contrib/driver/cap1xxx/ArrayFillingAnswerTest.java similarity index 97% rename from cap12xx/src/test/java/com/google/android/things/contrib/driver/cap12xx/ArrayFillingAnswerTest.java rename to cap1xxx/src/test/java/com/google/android/things/contrib/driver/cap1xxx/ArrayFillingAnswerTest.java index 9e6a906..91132f7 100644 --- a/cap12xx/src/test/java/com/google/android/things/contrib/driver/cap12xx/ArrayFillingAnswerTest.java +++ b/cap1xxx/src/test/java/com/google/android/things/contrib/driver/cap1xxx/ArrayFillingAnswerTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.things.contrib.driver.cap12xx; +package com.google.android.things.contrib.driver.cap1xxx; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNull; diff --git a/cap12xx/src/test/java/com/google/android/things/contrib/driver/cap12xx/BitwiseUtilTest.java b/cap1xxx/src/test/java/com/google/android/things/contrib/driver/cap1xxx/BitwiseUtilTest.java similarity index 97% rename from cap12xx/src/test/java/com/google/android/things/contrib/driver/cap12xx/BitwiseUtilTest.java rename to cap1xxx/src/test/java/com/google/android/things/contrib/driver/cap1xxx/BitwiseUtilTest.java index 2e3fdd0..1ed651c 100644 --- a/cap12xx/src/test/java/com/google/android/things/contrib/driver/cap12xx/BitwiseUtilTest.java +++ b/cap1xxx/src/test/java/com/google/android/things/contrib/driver/cap1xxx/BitwiseUtilTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.things.contrib.driver.cap12xx; +package com.google.android.things.contrib.driver.cap1xxx; import org.junit.Rule; import org.junit.Test; diff --git a/cap12xx/src/test/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxTest.java b/cap1xxx/src/test/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxTest.java similarity index 87% rename from cap12xx/src/test/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxTest.java rename to cap1xxx/src/test/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxTest.java index caf88c8..83fe347 100644 --- a/cap12xx/src/test/java/com/google/android/things/contrib/driver/cap12xx/Cap12xxTest.java +++ b/cap1xxx/src/test/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.things.contrib.driver.cap12xx; +package com.google.android.things.contrib.driver.cap1xxx; import static com.google.android.things.contrib.driver.testutils.BitsMatcher.hasBitsNotSet; import static com.google.android.things.contrib.driver.testutils.BitsMatcher.hasBitsSet; @@ -31,9 +31,9 @@ import android.os.Handler; -import com.google.android.things.contrib.driver.cap12xx.Cap12xx.AlertCallback; -import com.google.android.things.contrib.driver.cap12xx.Cap12xx.Configuration; -import com.google.android.things.contrib.driver.cap12xx.Cap12xx.OnCapTouchListener; +import com.google.android.things.contrib.driver.cap1xxx.Cap1xxx.AlertCallback; +import com.google.android.things.contrib.driver.cap1xxx.Cap1xxx.Configuration; +import com.google.android.things.contrib.driver.cap1xxx.Cap1xxx.OnCapTouchListener; import com.google.android.things.pio.Gpio; import com.google.android.things.pio.GpioCallback; import com.google.android.things.pio.I2cDevice; @@ -52,8 +52,8 @@ import java.io.IOException; @RunWith(PowerMockRunner.class) -@PrepareForTest({Cap12xx.class, Gpio.class}) -public class Cap12xxTest { +@PrepareForTest({Cap1xxx.class, Gpio.class}) +public class Cap1xxxTest { @Mock I2cDevice mI2c; @@ -70,7 +70,7 @@ public class Cap12xxTest { // Configuration used for all tests private static final Configuration CONFIGURATION = Configuration.CAP1188; - private Cap12xx mDriver; + private Cap1xxx mDriver; @Before public void setup() throws Exception { @@ -79,7 +79,7 @@ public void setup() throws Exception { PowerMockito.doNothing().when(mGpio).registerGpioCallback(any(GpioCallback.class)); PowerMockito.whenNew(AlertCallback.class).withNoArguments().thenReturn(mGpioCallback); - mDriver = new Cap12xx(mI2c, mGpio, CONFIGURATION); + mDriver = new Cap1xxx(mI2c, mGpio, CONFIGURATION); // clear invocations from driver init Mockito.reset(mGpio); Mockito.reset(mI2c); @@ -88,7 +88,7 @@ public void setup() throws Exception { @Test public void driverInit() throws IOException { // re-initialize since we want to verify invocations from driver init - mDriver = new Cap12xx(mI2c, mGpio, CONFIGURATION); + mDriver = new Cap1xxx(mI2c, mGpio, CONFIGURATION); verify(mGpio).setDirection(Gpio.DIRECTION_IN); verify(mGpio).setEdgeTriggerType(Gpio.EDGE_FALLING); verify(mGpio).registerGpioCallback(any(Handler.class), any(GpioCallback.class)); @@ -103,14 +103,14 @@ public void driverInit() throws IOException { // setRepeatRate verify(mI2c).writeRegByte(0x28, (byte) 0xFF); verify(mI2c).writeRegByte(eq(0x22), - byteThat(hasBitsSet((byte) (0x0F & Cap12xx.REPEAT_NORMAL)))); + byteThat(hasBitsSet((byte) (0x0F & Cap1xxx.REPEAT_NORMAL)))); verify(mI2c).writeRegByte(eq(0x23), - byteThat(hasBitsSet((byte) (0x0F & Cap12xx.REPEAT_NORMAL)))); + byteThat(hasBitsSet((byte) (0x0F & Cap1xxx.REPEAT_NORMAL)))); // setSensitivity Mockito.verify(mI2c).writeRegByte(eq(0x1F), - byteThat(hasBitsSet((byte) (0x70 & Cap12xx.SENSITIVITY_NORMAL)))); + byteThat(hasBitsSet((byte) (0x70 & Cap1xxx.SENSITIVITY_NORMAL)))); // setLedFade - Mockito.verify(mI2c).writeRegByte(0x94, (byte) Cap12xx.LED_FADE_INSTANT); + Mockito.verify(mI2c).writeRegByte(0x94, (byte) Cap1xxx.LED_FADE_INSTANT); // setLedBrightness Mockito.verify(mI2c).writeRegByte(0x93, (byte) 0xF0); // setLedInputLinkEnabled @@ -182,14 +182,14 @@ public void setLedState_throwsIfTooSLarge() throws IOException { @Test public void readInterruptFlag() throws IOException { - mDriver = new Cap12xx(mI2c, mGpio, CONFIGURATION); + mDriver = new Cap1xxx(mI2c, mGpio, CONFIGURATION); mDriver.readInterruptFlag(); verify(mI2c).readRegByte(0x00); } @Test public void readInterruptFlag_clearBit() throws IOException { - mDriver = new Cap12xx(mI2c, mGpio, CONFIGURATION); + mDriver = new Cap1xxx(mI2c, mGpio, CONFIGURATION); Mockito.when(mI2c.readRegByte(0x00)).thenReturn((byte) 1); // Should not clear @@ -265,50 +265,50 @@ public void setLedInputLinkEnabled() throws IOException { @Test public void setRepeatRate() throws IOException { - mDriver.setRepeatRate(Cap12xx.REPEAT_DISABLE); + mDriver.setRepeatRate(Cap1xxx.REPEAT_DISABLE); verify(mI2c).writeRegByte(0x28, (byte) 0); Mockito.reset(mI2c); - mDriver.setRepeatRate(Cap12xx.REPEAT_SLOW); + mDriver.setRepeatRate(Cap1xxx.REPEAT_SLOW); verify(mI2c).writeRegByte(0x28, (byte) 0xFF); verify(mI2c).writeRegByte(eq(0x22), - byteThat(hasBitsSet((byte) (0x0F & Cap12xx.REPEAT_SLOW)))); + byteThat(hasBitsSet((byte) (0x0F & Cap1xxx.REPEAT_SLOW)))); verify(mI2c).writeRegByte(eq(0x23), - byteThat(hasBitsSet((byte) (0x0F & Cap12xx.REPEAT_SLOW)))); + byteThat(hasBitsSet((byte) (0x0F & Cap1xxx.REPEAT_SLOW)))); Mockito.reset(mI2c); - mDriver.setRepeatRate(Cap12xx.REPEAT_FAST); + mDriver.setRepeatRate(Cap1xxx.REPEAT_FAST); verify(mI2c).writeRegByte(0x28, (byte) 0xFF); verify(mI2c).writeRegByte(eq(0x22), - byteThat(hasBitsSet((byte) (0x0F & Cap12xx.REPEAT_FAST)))); + byteThat(hasBitsSet((byte) (0x0F & Cap1xxx.REPEAT_FAST)))); verify(mI2c).writeRegByte(eq(0x23), - byteThat(hasBitsSet((byte) (0x0F & Cap12xx.REPEAT_FAST)))); + byteThat(hasBitsSet((byte) (0x0F & Cap1xxx.REPEAT_FAST)))); } @Test public void setSensitivity() throws IOException { - mDriver.setSensitivity(Cap12xx.SENSITIVITY_LOW); + mDriver.setSensitivity(Cap1xxx.SENSITIVITY_LOW); verify(mI2c).writeRegByte(eq(0x1F), - byteThat(hasBitsSet((byte) (0x70 & Cap12xx.SENSITIVITY_LOW)))); + byteThat(hasBitsSet((byte) (0x70 & Cap1xxx.SENSITIVITY_LOW)))); Mockito.reset(mI2c); - mDriver.setSensitivity(Cap12xx.SENSITIVITY_HIGH); + mDriver.setSensitivity(Cap1xxx.SENSITIVITY_HIGH); // mask for this sensitivity is zero, so invert the check verify(mI2c).writeRegByte(eq(0x1F), byteThat(hasBitsNotSet((byte) ~0x70))); } @Test public void setLedFade() throws IOException { - mDriver.setLedFade(Cap12xx.LED_FADE_FAST); - verify(mI2c).writeRegByte(0x94, (byte) Cap12xx.LED_FADE_FAST); + mDriver.setLedFade(Cap1xxx.LED_FADE_FAST); + verify(mI2c).writeRegByte(0x94, (byte) Cap1xxx.LED_FADE_FAST); Mockito.reset(mI2c); - mDriver.setLedFade(Cap12xx.LED_FADE_SLOW); - verify(mI2c).writeRegByte(0x94, (byte) Cap12xx.LED_FADE_SLOW); + mDriver.setLedFade(Cap1xxx.LED_FADE_SLOW); + verify(mI2c).writeRegByte(0x94, (byte) Cap1xxx.LED_FADE_SLOW); } @Test diff --git a/settings.gradle b/settings.gradle index e7972c3..03f4d61 100644 --- a/settings.gradle +++ b/settings.gradle @@ -18,7 +18,7 @@ include ':adc' include ':apa102' include ':button' include ':bmx280' -include ':cap12xx' +include ':cap1xxx' include ':gps' include ':ht16k33' include ':lowpan'