Skip to content

Commit

Permalink
Merge pull request leinardi#10 from diegoferreiracaetano/master
Browse files Browse the repository at this point in the history
preview 7
  • Loading branch information
leinardi authored Mar 20, 2018
2 parents 59d0676 + b409c23 commit a61a49e
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.os.Build;
import android.util.Log;


@SuppressWarnings("WeakerAccess")
public class BoardDefaults {
private static final String TAG = BoardDefaults.class.getSimpleName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private void handleBootComplete(Context context) {
// Otherwise, set the DS3231 using the system time if the system time appears sane
if (isSaneTimestamp(ds3231Timestamp)) {
Log.i(TAG, "Setting system clock using DS3231");
TimeManager timeManager = new TimeManager();
TimeManager timeManager = TimeManager.getInstance();
timeManager.setTime(ds3231Timestamp);

// Re-enable NTP updates. The call to setTime() disables them automatically,
Expand Down
1 change: 1 addition & 0 deletions driver-ds3231/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/


apply plugin: 'com.android.library'
apply from: rootProject.file('checkstyle.gradle')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import android.util.Log;

import com.google.android.things.pio.I2cDevice;
import com.google.android.things.pio.PeripheralManagerService;
import com.google.android.things.pio.PeripheralManager;

import java.io.Closeable;
import java.io.IOException;
Expand Down Expand Up @@ -224,7 +224,7 @@ public Ds3231(String i2cName) throws IOException {
* @throws IOException
*/
public Ds3231(String i2cName, int i2cAddress) throws IOException {
I2cDevice device = new PeripheralManagerService().openI2cDevice(i2cName, i2cAddress);
I2cDevice device = PeripheralManager.getInstance().openI2cDevice(i2cName, i2cAddress);
try {
connect(device);
} catch (IOException | RuntimeException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import android.hardware.Sensor;

import com.google.android.things.userdriver.UserDriverManager;
import com.google.android.things.userdriver.UserSensor;
import com.google.android.things.userdriver.UserSensorDriver;
import com.google.android.things.userdriver.UserSensorReading;
import com.google.android.things.userdriver.sensor.UserSensor;
import com.google.android.things.userdriver.sensor.UserSensorDriver;
import com.google.android.things.userdriver.sensor.UserSensorReading;

import java.io.IOException;
import java.util.UUID;
Expand Down Expand Up @@ -96,7 +96,7 @@ public void registerTemperatureSensor() {

if (mTemperatureUserDriver == null) {
mTemperatureUserDriver = new TemperatureUserDriver();
UserDriverManager.getManager().registerSensor(mTemperatureUserDriver.getUserSensor());
UserDriverManager.getInstance().registerSensor(mTemperatureUserDriver.getUserSensor());
}
}

Expand All @@ -105,12 +105,12 @@ public void registerTemperatureSensor() {
*/
public void unregisterTemperatureSensor() {
if (mTemperatureUserDriver != null) {
UserDriverManager.getManager().unregisterSensor(mTemperatureUserDriver.getUserSensor());
UserDriverManager.getInstance().unregisterSensor(mTemperatureUserDriver.getUserSensor());
mTemperatureUserDriver = null;
}
}

private class TemperatureUserDriver extends UserSensorDriver {
private class TemperatureUserDriver implements UserSensorDriver {
private UserSensor mUserSensor;

private UserSensor getUserSensor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.leinardi.android.things.driver.epaperdriverhat;

import com.google.android.things.pio.Gpio;
import com.google.android.things.pio.PeripheralManagerService;
import com.google.android.things.pio.PeripheralManager;
import com.google.android.things.pio.SpiDevice;

import java.io.Closeable;
Expand Down Expand Up @@ -60,7 +60,7 @@ public Epd() throws IOException {
}

public Epd(String spiBusPort, String resetPin, String dataCommandPin, String busyPin) throws IOException {
PeripheralManagerService pioService = new PeripheralManagerService();
PeripheralManager pioService = PeripheralManager.getInstance();
mSpiDevice = pioService.openSpiDevice(spiBusPort);
mResetPin = pioService.openGpio(resetPin);
mDataCommandPin = pioService.openGpio(dataCommandPin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import android.util.Log;

import com.google.android.things.pio.Gpio;
import com.google.android.things.pio.PeripheralManagerService;
import com.google.android.things.pio.PeripheralManager;

import java.io.Closeable;
import java.io.IOException;
Expand Down Expand Up @@ -56,7 +56,7 @@ public class Hcsr04 implements Closeable {
* @throws IOException
*/
public Hcsr04(String trigPin, String echoPin) throws IOException {
PeripheralManagerService pioService = new PeripheralManagerService();
PeripheralManager pioService = PeripheralManager.getInstance();
Gpio trigGpio = pioService.openGpio(trigPin);
Gpio echoGpio = pioService.openGpio(echoPin);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import android.hardware.Sensor;

import com.google.android.things.userdriver.UserDriverManager;
import com.google.android.things.userdriver.UserSensor;
import com.google.android.things.userdriver.UserSensorDriver;
import com.google.android.things.userdriver.UserSensorReading;
import com.google.android.things.userdriver.sensor.UserSensor;
import com.google.android.things.userdriver.sensor.UserSensorDriver;
import com.google.android.things.userdriver.sensor.UserSensorReading;

import java.io.IOException;
import java.util.UUID;
Expand Down Expand Up @@ -83,7 +83,7 @@ public void registerProximitySensor() {

if (mDistanceUserDriver == null) {
mDistanceUserDriver = new DistanceUserDriver();
UserDriverManager.getManager().registerSensor(mDistanceUserDriver.getUserSensor());
UserDriverManager.getInstance().registerSensor(mDistanceUserDriver.getUserSensor());
}
}

Expand All @@ -92,12 +92,12 @@ public void registerProximitySensor() {
*/
public void unregisterProximitySensor() {
if (mDistanceUserDriver != null) {
UserDriverManager.getManager().unregisterSensor(mDistanceUserDriver.getUserSensor());
UserDriverManager.getInstance().unregisterSensor(mDistanceUserDriver.getUserSensor());
mDistanceUserDriver = null;
}
}

private class DistanceUserDriver extends UserSensorDriver {
private class DistanceUserDriver implements UserSensorDriver {
private UserSensor mUserSensor;

private UserSensor getUserSensor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import android.util.Log;

import com.google.android.things.pio.I2cDevice;
import com.google.android.things.pio.PeripheralManagerService;
import com.google.android.things.pio.PeripheralManager;

import java.io.IOException;
import java.lang.annotation.Retention;
Expand Down Expand Up @@ -115,7 +115,7 @@ public Hd44780(String i2cName, int i2cAddress, @Geometry int geometry) throws IO
*/
public Hd44780(String i2cName, int i2cAddress, @Geometry int geometry, boolean use5x10Dots) throws IOException {
mLcdGeometry = GEOMETRIES[geometry];
I2cDevice device = new PeripheralManagerService().openI2cDevice(i2cName, i2cAddress);
I2cDevice device = PeripheralManager.getInstance().openI2cDevice(i2cName, i2cAddress);
try {
init(device, use5x10Dots);
} catch (IOException | RuntimeException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import android.support.annotation.IntDef;

import com.google.android.things.pio.I2cDevice;
import com.google.android.things.pio.PeripheralManagerService;
import com.google.android.things.pio.PeripheralManager;

import java.io.Closeable;
import java.io.IOException;
Expand Down Expand Up @@ -211,7 +211,7 @@ public class Lsm9ds1 implements Closeable {
* @throws IOException
*/
private Lsm9ds1(Builder builder) throws IOException {
PeripheralManagerService pioService = new PeripheralManagerService();
PeripheralManager pioService = PeripheralManager.getInstance();
I2cDevice accelGyroDevice = pioService.openI2cDevice(builder.mI2cBus, builder.mI2cAddressAccelGyro);
I2cDevice magDevice = pioService.openI2cDevice(builder.mI2cBus, builder.mI2cAddressMag);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import android.hardware.Sensor;

import com.google.android.things.userdriver.UserDriverManager;
import com.google.android.things.userdriver.UserSensor;
import com.google.android.things.userdriver.UserSensorDriver;
import com.google.android.things.userdriver.UserSensorReading;
import com.google.android.things.userdriver.sensor.UserSensor;
import com.google.android.things.userdriver.sensor.UserSensorDriver;
import com.google.android.things.userdriver.sensor.UserSensorReading;

import java.io.IOException;
import java.util.UUID;
Expand Down Expand Up @@ -110,7 +110,7 @@ public void registerAccelerometerSensor() {

if (mAccelerationUserDriver == null) {
mAccelerationUserDriver = new AccelerationUserDriver();
UserDriverManager.getManager().registerSensor(mAccelerationUserDriver.getUserSensor());
UserDriverManager.getInstance().registerSensor(mAccelerationUserDriver.getUserSensor());
}
}

Expand All @@ -119,7 +119,7 @@ public void registerAccelerometerSensor() {
*/
public void unregisterAccelerometerSensor() {
if (mAccelerationUserDriver != null) {
UserDriverManager.getManager().unregisterSensor(mAccelerationUserDriver.getUserSensor());
UserDriverManager.getInstance().unregisterSensor(mAccelerationUserDriver.getUserSensor());
mAccelerationUserDriver = null;
}
}
Expand All @@ -136,7 +136,7 @@ public void registerGyroscopeSensor() {

if (mAngularVelocityUserDriver == null) {
mAngularVelocityUserDriver = new AngularVelocityUserDriver();
UserDriverManager.getManager().registerSensor(mAngularVelocityUserDriver.getUserSensor());
UserDriverManager.getInstance().registerSensor(mAngularVelocityUserDriver.getUserSensor());
}
}

Expand All @@ -145,7 +145,7 @@ public void registerGyroscopeSensor() {
*/
public void unregisterGyroscopeSensor() {
if (mAngularVelocityUserDriver != null) {
UserDriverManager.getManager().unregisterSensor(mAngularVelocityUserDriver.getUserSensor());
UserDriverManager.getInstance().unregisterSensor(mAngularVelocityUserDriver.getUserSensor());
mAngularVelocityUserDriver = null;
}
}
Expand All @@ -162,7 +162,7 @@ public void registerMagneticFieldSensor() {

if (mMagneticInductionUserDriver == null) {
mMagneticInductionUserDriver = new MagneticInductionUserDriver();
UserDriverManager.getManager().registerSensor(mMagneticInductionUserDriver.getUserSensor());
UserDriverManager.getInstance().registerSensor(mMagneticInductionUserDriver.getUserSensor());
}
}

Expand All @@ -171,7 +171,7 @@ public void registerMagneticFieldSensor() {
*/
public void unregisterMagneticFieldSensor() {
if (mMagneticInductionUserDriver != null) {
UserDriverManager.getManager().unregisterSensor(mMagneticInductionUserDriver.getUserSensor());
UserDriverManager.getInstance().unregisterSensor(mMagneticInductionUserDriver.getUserSensor());
mMagneticInductionUserDriver = null;
}
}
Expand All @@ -188,7 +188,7 @@ public void registerTemperatureSensor() {

if (mTemperatureUserDriver == null) {
mTemperatureUserDriver = new TemperatureUserDriver();
UserDriverManager.getManager().registerSensor(mTemperatureUserDriver.getUserSensor());
UserDriverManager.getInstance().registerSensor(mTemperatureUserDriver.getUserSensor());
}
}

Expand All @@ -197,7 +197,7 @@ public void registerTemperatureSensor() {
*/
public void unregisterTemperatureSensor() {
if (mTemperatureUserDriver != null) {
UserDriverManager.getManager().unregisterSensor(mTemperatureUserDriver.getUserSensor());
UserDriverManager.getInstance().unregisterSensor(mTemperatureUserDriver.getUserSensor());
mTemperatureUserDriver = null;
}
}
Expand Down Expand Up @@ -249,7 +249,7 @@ private void maybeSleep() throws IOException {
}
}

private class AccelerationUserDriver extends UserSensorDriver {
private class AccelerationUserDriver implements UserSensorDriver {
// DRIVER parameters
// documented at https://source.android.com/devices/sensors/hal-interface.html#sensor_t
private static final float DRIVER_MAX_RANGE = Lsm9ds1.MAX_ACCEL_RANGE_G_DEFAULT;
Expand Down Expand Up @@ -296,7 +296,7 @@ private boolean isEnabled() {
}
}

private class AngularVelocityUserDriver extends UserSensorDriver {
private class AngularVelocityUserDriver implements UserSensorDriver {
// DRIVER parameters
// documented at https://source.android.com/devices/sensors/hal-interface.html#sensor_t
private static final float DRIVER_MAX_RANGE = Lsm9ds1.MAX_GYRO_RATE_DPS_DEFAULT;
Expand Down Expand Up @@ -343,7 +343,7 @@ private boolean isEnabled() {
}
}

private class MagneticInductionUserDriver extends UserSensorDriver {
private class MagneticInductionUserDriver implements UserSensorDriver {
// DRIVER parameters
// documented at https://source.android.com/devices/sensors/hal-interface.html#sensor_t
private static final float DRIVER_MAX_RANGE = Lsm9ds1.MAX_MAG_GAIN_GS_DEFAULT;
Expand Down Expand Up @@ -390,7 +390,7 @@ private boolean isEnabled() {
}
}

private class TemperatureUserDriver extends UserSensorDriver {
private class TemperatureUserDriver implements UserSensorDriver {
// DRIVER parameters
// documented at https://source.android.com/devices/sensors/hal-interface.html#sensor_t
private static final float DRIVER_MAX_RANGE = Lsm9ds1.MAX_TEMP_C;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import android.graphics.Bitmap;

import com.google.android.things.pio.I2cDevice;
import com.google.android.things.pio.PeripheralManagerService;
import com.google.android.things.pio.PeripheralManager;

import java.io.Closeable;
import java.io.IOException;
Expand Down Expand Up @@ -149,7 +149,7 @@ public Sh1106(String i2cName, int i2cAddress) throws IOException {
* @throws IOException
*/
public Sh1106(String i2cName, int i2cAddress, int width, int height) throws IOException {
I2cDevice device = new PeripheralManagerService().openI2cDevice(i2cName, i2cAddress);
I2cDevice device = PeripheralManager.getInstance().openI2cDevice(i2cName, i2cAddress);
try {
init(device, width, height);
} catch (IOException | RuntimeException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import android.util.Log;

import com.google.android.things.pio.I2cDevice;
import com.google.android.things.pio.PeripheralManagerService;
import com.google.android.things.pio.PeripheralManager;

import java.io.Closeable;
import java.io.IOException;
Expand Down Expand Up @@ -178,7 +178,7 @@ public class Tsl256x implements Closeable {
* @throws IOException
*/
public Tsl256x(String i2cName, int i2cAddress) throws IOException {
PeripheralManagerService pioService = new PeripheralManagerService();
PeripheralManager pioService = PeripheralManager.getInstance();
I2cDevice device = pioService.openI2cDevice(i2cName, i2cAddress);
try {
connect(device);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import android.hardware.Sensor;

import com.google.android.things.userdriver.UserDriverManager;
import com.google.android.things.userdriver.UserSensor;
import com.google.android.things.userdriver.UserSensorDriver;
import com.google.android.things.userdriver.UserSensorReading;
import com.google.android.things.userdriver.sensor.UserSensor;
import com.google.android.things.userdriver.sensor.UserSensorDriver;
import com.google.android.things.userdriver.sensor.UserSensorReading;

import java.io.IOException;
import java.util.UUID;
Expand Down Expand Up @@ -97,7 +97,7 @@ public void registerLightSensor() {

if (mLightUserDriver == null) {
mLightUserDriver = new LightUserDriver();
UserDriverManager.getManager().registerSensor(mLightUserDriver.getUserSensor());
UserDriverManager.getInstance().registerSensor(mLightUserDriver.getUserSensor());
}
}

Expand All @@ -106,12 +106,12 @@ public void registerLightSensor() {
*/
public void unregisterLightSensor() {
if (mLightUserDriver != null) {
UserDriverManager.getManager().unregisterSensor(mLightUserDriver.getUserSensor());
UserDriverManager.getInstance().unregisterSensor(mLightUserDriver.getUserSensor());
mLightUserDriver = null;
}
}

private class LightUserDriver extends UserSensorDriver {
private class LightUserDriver implements UserSensorDriver {
private UserSensor mUserSensor;

private UserSensor getUserSensor() {
Expand Down
2 changes: 1 addition & 1 deletion versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def versions = [:]
versions.android_checkstyle_plugin = "1.0.0"
versions.android_gradle_plugin = "3.1.0-beta1"
versions.android_maven_gradle_plugin = "2.0"
versions.androidthings = "0.6.1-devpreview"
versions.androidthings = "0.7-devpreview"
versions.apache_commons = "2.5"
versions.arch = hasProperty("ARCH_VERSION") ? getProperty("ARCH_VERSION") : "1.0.0"
versions.atsl_rules = "1.0.1"
Expand Down

0 comments on commit a61a49e

Please sign in to comment.