Skip to content

Commit

Permalink
Rename cap12xx to cap1xxx, and update/deprecate old artifact.
Browse files Browse the repository at this point in the history
Change-Id: I34d57226dcb2961980968c7965ca926d100b96b6
  • Loading branch information
swittman committed Aug 2, 2018
1 parent 204e7a7 commit 73f09b7
Show file tree
Hide file tree
Showing 18 changed files with 282 additions and 108 deletions.
5 changes: 5 additions & 0 deletions cap12xx/CHANGELOG.md → cap1xxx/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
28 changes: 14 additions & 14 deletions cap12xx/README.md → cap1xxx/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 `<version>` matches the last version of the driver available on [jcenter][jcenter].

```
dependencies {
compile 'com.google.android.things.contrib:driver-cap12xx:<version>'
implementation 'com.google.android.things.contrib:driver-cap1xxx:<version>'
}
```

### 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
}
});
Expand All @@ -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);

Expand Down Expand Up @@ -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
File renamed without changes.
2 changes: 1 addition & 1 deletion cap12xx/gradle.properties → cap1xxx/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
TYPE="capacitive touch buttons"
ARTIFACT_VERSION=1.0
ARTIFACT_VERSION=2.0
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.things.contrib.driver.cap12xx">
package="com.google.android.things.contrib.driver.cap1xxx">

<uses-permission android:name="com.google.android.things.permission.MANAGE_INPUT_DRIVERS" />

<application>
<activity android:name=".Cap12xxTestActivity" />
<activity android:name=".Cap1xxxTestActivity" />
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -22,15 +22,15 @@

import java.io.IOException;

public class Cap12xxInputDriverInstrumentedTest {
public class Cap1xxxInputDriverInstrumentedTest {

@Rule
public ActivityTestRule<Cap12xxTestActivity> mActivityRule
= new ActivityTestRule<>(Cap12xxTestActivity.class);
public ActivityTestRule<Cap1xxxTestActivity> mActivityRule
= new ActivityTestRule<>(Cap1xxxTestActivity.class);

@Test
public void buttonDriverInjectsKeyEvents() throws IOException {
Cap12xxTestActivity activity = mActivityRule.getActivity();
Cap1xxxTestActivity activity = mActivityRule.getActivity();
activity.testKeyEvents();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 = {
Expand All @@ -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<KeyEvent> mKeyDownEvents = new LinkedBlockingQueue<>();
private BlockingQueue<KeyEvent> mKeyUpEvents = new LinkedBlockingQueue<>();
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.things.contrib.driver.cap12xx">
package="com.google.android.things.contrib.driver.cap1xxx">
<application>
<uses-library android:required="false" android:name="com.google.android.things"/>
</application>
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 73f09b7

Please sign in to comment.