https://github.com/blundell/zxsensor
ZX Gesture Sensor Driver Library for Android Things
https://github.com/blundell/zxsensor
androidthings gesture-detection i2c uart zxsensor
Last synced: 9 months ago
JSON representation
ZX Gesture Sensor Driver Library for Android Things
- Host: GitHub
- URL: https://github.com/blundell/zxsensor
- Owner: blundell
- Created: 2017-08-17T14:48:02.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-15T12:32:38.000Z (about 8 years ago)
- Last Synced: 2025-04-01T16:55:54.949Z (about 1 year ago)
- Topics: androidthings, gesture-detection, i2c, uart, zxsensor
- Language: Java
- Size: 351 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
ZX Sensor driver for Android Things
===================================
This driver supports ZXSensor peripherals using the I2C and UART protocols.
See the [/library](/library) module for the implementation
See the [/demo](/demo) module for a working example
How to use the driver
---------------------
### Gradle dependency
To use the `zxsensor` 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.blundell:driver-zxsensor:'
}
```
### Sample usage
```java
import com.blundell.zxsensor.ZxSensor;
import com.blundell.zxsensor.ZxSensorUart;
// Access the ZXSensor (choose I2C or UART) here we show UART:
ZxSensorUart zxSensorUart;
try {
zxSensorUart = ZxSensor.Factory.openViaUart(BoardDefaults.getUartPin());
} catch (IOException e) {
throw new IllegalStateException("Can't open, did you use the correct pin name?", e);
}
zxSensorUart.setSwipeLeftListener(swipeLeftListener);
zxSensorUart.setSwipeRightListener(swipeRightListener);
ZxSensor.SwipeLeftListener swipeLeftListener = new ZxSensor.SwipeLeftListener() {
@Override
public void onSwipeLeft(int speed) {
Log.d("TUT", "Swipe left detected");
}
};
ZxSensor.SwipeRightListener swipeRightListener = new ZxSensor.SwipeRightListener() {
@Override
public void onSwipeRight(int speed) {
Log.d("TUT", "Swipe right detected");
}
};
// Start monitoring:
zxSensorUart.startMonitoringGestures();
// Stop monitoring:
zxSensorUart.stopMonitoringGestures();
// Close the ZXSensor when finished:
zxSensorUart.close();
```
[jcenter]: https://bintray.com/blundell/maven/driver-zxsensor/_latestVersion