├── apa102
├── .gitignore
├── rpi3_schematics.fzz
├── rpi3_schematics.png
├── .google
│ └── packaging.yaml
├── src
│ └── main
│ │ ├── res
│ │ └── values
│ │ │ └── strings.xml
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── androidthings
│ │ │ └── driversamples
│ │ │ ├── BoardDefaults.java
│ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
├── build.gradle
└── README.md
├── bmx280
├── .gitignore
├── rpi3_schematics.fzz
├── rpi3_schematics.png
├── .google
│ └── packaging.yaml
├── src
│ └── main
│ │ ├── res
│ │ └── values
│ │ │ └── strings.xml
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── androidthings
│ │ │ └── driversamples
│ │ │ ├── BoardDefaults.java
│ │ │ └── TemperatureActivity.java
│ │ └── AndroidManifest.xml
├── build.gradle
└── README.md
├── gps
├── .gitignore
├── .google
│ └── packaging.yaml
├── src
│ └── main
│ │ ├── res
│ │ └── values
│ │ │ └── strings.xml
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── androidthings
│ │ │ └── driversamples
│ │ │ ├── BoardDefaults.java
│ │ │ └── GpsActivity.java
│ │ └── AndroidManifest.xml
├── build.gradle
└── README.md
├── tm1637
├── .gitignore
├── rpi3_schematics.fzz
├── rpi3_schematics.png
├── .google
│ └── packaging.yaml
├── src
│ └── main
│ │ ├── res
│ │ └── values
│ │ │ └── strings.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── androidthings
│ │ └── driversamples
│ │ ├── BoardDefaults.java
│ │ └── SegmentDisplayActivity.java
├── build.gradle
└── README.md
├── ads1015
├── .gitignore
├── rpi3_schematics.fzz
├── rpi3_schematics.png
├── src
│ └── main
│ │ ├── res
│ │ └── values
│ │ │ └── strings.xml
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── android
│ │ │ └── things
│ │ │ └── ads1015
│ │ │ ├── BoardDefaults.java
│ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
├── build.gradle
└── README.md
├── cap1xxx
├── .gitignore
├── .google
│ └── packaging.yaml
├── src
│ └── main
│ │ ├── res
│ │ └── values
│ │ │ └── strings.xml
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── androidthings
│ │ │ └── driversamples
│ │ │ ├── BoardDefaults.java
│ │ │ └── CaptouchActivity.java
│ │ └── AndroidManifest.xml
├── build.gradle
└── README.md
├── ht16k33
├── .gitignore
├── rpi3_schematics.fzz
├── rpi3_schematics.png
├── .google
│ └── packaging.yaml
├── src
│ └── main
│ │ ├── res
│ │ └── values
│ │ │ └── strings.xml
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── androidthings
│ │ │ └── driversamples
│ │ │ ├── BoardDefaults.java
│ │ │ └── SegmentDisplayActivity.java
│ │ └── AndroidManifest.xml
├── build.gradle
└── README.md
├── matrixkeypad
├── .gitignore
├── rpi3_schematics.fzz
├── rpi3_schematics.png
├── src
│ └── main
│ │ ├── res
│ │ ├── values
│ │ │ └── strings.xml
│ │ └── layout
│ │ │ └── layout_main.xml
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── androidthings
│ │ │ └── driversamples
│ │ │ ├── BoardDefaults.java
│ │ │ └── MatrixKeypadActivity.java
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
├── build.gradle
└── README.md
├── mma7660fc
├── rpi3_schematics.fzz
├── rpi3_schematics.png
├── .google
│ └── packaging.yaml
├── src
│ └── main
│ │ ├── res
│ │ └── values
│ │ │ └── strings.xml
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── androidthings
│ │ │ └── driversamples
│ │ │ ├── BoardDefaults.java
│ │ │ └── AccelerometerActivity.java
│ │ └── AndroidManifest.xml
├── build.gradle
└── README.md
├── pwmservo
├── rpi3_schematics.fzz
├── rpi3_schematics.png
├── .google
│ └── packaging.yaml
├── src
│ └── main
│ │ ├── res
│ │ └── values
│ │ │ └── strings.xml
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── androidthings
│ │ │ └── driversamples
│ │ │ ├── BoardDefaults.java
│ │ │ └── ServoActivity.java
│ │ └── AndroidManifest.xml
├── build.gradle
└── README.md
├── ssd1306
├── rpi3_schematics.fzz
├── rpi3_schematics.png
├── src
│ └── main
│ │ ├── res
│ │ ├── drawable-nodpi
│ │ │ └── flower.png
│ │ └── values
│ │ │ └── strings.xml
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── androidthings
│ │ │ └── driversamples
│ │ │ ├── BoardDefaults.java
│ │ │ └── OledScreenActivity.java
│ │ └── AndroidManifest.xml
├── .google
│ └── packaging.yaml
├── build.gradle
└── README.md
├── pwmspeaker
├── rpi3_schematics.fzz
├── rpi3_schematics.png
├── .google
│ └── packaging.yaml
├── src
│ └── main
│ │ ├── res
│ │ └── values
│ │ │ └── strings.xml
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── androidthings
│ │ │ └── driversamples
│ │ │ ├── MusicNotes.java
│ │ │ ├── BoardDefaults.java
│ │ │ └── SpeakerActivity.java
│ │ └── AndroidManifest.xml
├── build.gradle
└── README.md
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .google
└── packaging.yaml
├── .gitignore
├── settings.gradle
├── README.md
├── CONTRIBUTING.md
├── gradlew.bat
├── gradlew
└── LICENSE
/apa102/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/bmx280/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/gps/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/tm1637/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ads1015/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/cap1xxx/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ht16k33/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/matrixkeypad/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/apa102/rpi3_schematics.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/apa102/rpi3_schematics.fzz
--------------------------------------------------------------------------------
/apa102/rpi3_schematics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/apa102/rpi3_schematics.png
--------------------------------------------------------------------------------
/bmx280/rpi3_schematics.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/bmx280/rpi3_schematics.fzz
--------------------------------------------------------------------------------
/bmx280/rpi3_schematics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/bmx280/rpi3_schematics.png
--------------------------------------------------------------------------------
/tm1637/rpi3_schematics.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/tm1637/rpi3_schematics.fzz
--------------------------------------------------------------------------------
/tm1637/rpi3_schematics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/tm1637/rpi3_schematics.png
--------------------------------------------------------------------------------
/ads1015/rpi3_schematics.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/ads1015/rpi3_schematics.fzz
--------------------------------------------------------------------------------
/ads1015/rpi3_schematics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/ads1015/rpi3_schematics.png
--------------------------------------------------------------------------------
/ht16k33/rpi3_schematics.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/ht16k33/rpi3_schematics.fzz
--------------------------------------------------------------------------------
/ht16k33/rpi3_schematics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/ht16k33/rpi3_schematics.png
--------------------------------------------------------------------------------
/mma7660fc/rpi3_schematics.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/mma7660fc/rpi3_schematics.fzz
--------------------------------------------------------------------------------
/mma7660fc/rpi3_schematics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/mma7660fc/rpi3_schematics.png
--------------------------------------------------------------------------------
/pwmservo/rpi3_schematics.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/pwmservo/rpi3_schematics.fzz
--------------------------------------------------------------------------------
/pwmservo/rpi3_schematics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/pwmservo/rpi3_schematics.png
--------------------------------------------------------------------------------
/ssd1306/rpi3_schematics.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/ssd1306/rpi3_schematics.fzz
--------------------------------------------------------------------------------
/ssd1306/rpi3_schematics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/ssd1306/rpi3_schematics.png
--------------------------------------------------------------------------------
/pwmspeaker/rpi3_schematics.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/pwmspeaker/rpi3_schematics.fzz
--------------------------------------------------------------------------------
/pwmspeaker/rpi3_schematics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/pwmspeaker/rpi3_schematics.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/matrixkeypad/rpi3_schematics.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/matrixkeypad/rpi3_schematics.fzz
--------------------------------------------------------------------------------
/matrixkeypad/rpi3_schematics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/matrixkeypad/rpi3_schematics.png
--------------------------------------------------------------------------------
/ssd1306/src/main/res/drawable-nodpi/flower.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidthings/drivers-samples/HEAD/ssd1306/src/main/res/drawable-nodpi/flower.png
--------------------------------------------------------------------------------
/matrixkeypad/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | MatrixKeypad Demo
4 |
--------------------------------------------------------------------------------
/.google/packaging.yaml:
--------------------------------------------------------------------------------
1 | status: PUBLISHED
2 | technologies: [Android, Android Things]
3 | categories: [Android Things]
4 | languages: [Java]
5 | solutions: [IoT]
6 | github: androidthings/drivers-samples
7 | license: apache2
8 |
--------------------------------------------------------------------------------
/gps/.google/packaging.yaml:
--------------------------------------------------------------------------------
1 | status: PUBLISHED
2 | technologies: [Android, Android Things]
3 | categories: [Android Things]
4 | languages: [Java]
5 | solutions: [IoT]
6 | github: androidthings/drivers-samples
7 | license: apache2
8 |
--------------------------------------------------------------------------------
/apa102/.google/packaging.yaml:
--------------------------------------------------------------------------------
1 | status: PUBLISHED
2 | technologies: [Android, Android Things]
3 | categories: [Android Things]
4 | languages: [Java]
5 | solutions: [IoT]
6 | github: androidthings/drivers-samples
7 | license: apache2
8 |
--------------------------------------------------------------------------------
/bmx280/.google/packaging.yaml:
--------------------------------------------------------------------------------
1 | status: PUBLISHED
2 | technologies: [Android, Android Things]
3 | categories: [Android Things]
4 | languages: [Java]
5 | solutions: [IoT]
6 | github: androidthings/drivers-samples
7 | license: apache2
8 |
--------------------------------------------------------------------------------
/cap1xxx/.google/packaging.yaml:
--------------------------------------------------------------------------------
1 | status: PUBLISHED
2 | technologies: [Android, Android Things]
3 | categories: [Android Things]
4 | languages: [Java]
5 | solutions: [IoT]
6 | github: androidthings/drivers-samples
7 | license: apache2
8 |
--------------------------------------------------------------------------------
/ht16k33/.google/packaging.yaml:
--------------------------------------------------------------------------------
1 | status: PUBLISHED
2 | technologies: [Android, Android Things]
3 | categories: [Android Things]
4 | languages: [Java]
5 | solutions: [IoT]
6 | github: androidthings/drivers-samples
7 | license: apache2
8 |
--------------------------------------------------------------------------------
/mma7660fc/.google/packaging.yaml:
--------------------------------------------------------------------------------
1 | status: PUBLISHED
2 | technologies: [Android, Android Things]
3 | categories: [Android Things]
4 | languages: [Java]
5 | solutions: [IoT]
6 | github: androidthings/drivers-samples
7 | license: apache2
8 |
--------------------------------------------------------------------------------
/pwmservo/.google/packaging.yaml:
--------------------------------------------------------------------------------
1 | status: PUBLISHED
2 | technologies: [Android, Android Things]
3 | categories: [Android Things]
4 | languages: [Java]
5 | solutions: [IoT]
6 | github: androidthings/drivers-samples
7 | license: apache2
8 |
--------------------------------------------------------------------------------
/pwmspeaker/.google/packaging.yaml:
--------------------------------------------------------------------------------
1 | status: PUBLISHED
2 | technologies: [Android, Android Things]
3 | categories: [Android Things]
4 | languages: [Java]
5 | solutions: [IoT]
6 | github: androidthings/drivers-samples
7 | license: apache2
8 |
--------------------------------------------------------------------------------
/ssd1306/.google/packaging.yaml:
--------------------------------------------------------------------------------
1 | status: PUBLISHED
2 | technologies: [Android, Android Things]
3 | categories: [Android Things]
4 | languages: [Java]
5 | solutions: [IoT]
6 | github: androidthings/drivers-samples
7 | license: apache2
8 |
--------------------------------------------------------------------------------
/tm1637/.google/packaging.yaml:
--------------------------------------------------------------------------------
1 | status: PUBLISHED
2 | technologies: [Android, Android Things]
3 | categories: [Android Things]
4 | languages: [Java]
5 | solutions: [IoT]
6 | github: androidthings/drivers-samples
7 | license: apache2
8 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Aug 10 16:22:03 PDT 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ### Android ###
2 | # Built application files
3 | *.apk
4 | *.ap_
5 |
6 | # Files for the ART/Dalvik VM
7 | *.dex
8 |
9 | # Java class files
10 | *.class
11 |
12 | # Generated files
13 | bin/
14 | gen/
15 | out/
16 |
17 | # Gradle files
18 | .gradle/
19 | build/
20 |
21 | # Local configuration file (sdk path, etc)
22 | local.properties
23 | gradle.properties
24 |
25 | # Proguard folder generated by Eclipse
26 | proguard/
27 |
28 | # Log Files
29 | *.log
30 |
31 | # Android Studio Navigation editor temp files
32 | .navigation/
33 |
34 | # Android Studio captures folder
35 | captures/
36 |
37 | # Intellij
38 | *.iml
39 | *.iws
40 | .idea/
41 |
42 | # External native build folder generated in Android Studio 2.2 and later
43 | .externalNativeBuild
44 |
45 | .DS_Store
46 |
--------------------------------------------------------------------------------
/gps/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | GPS demo
19 |
20 |
--------------------------------------------------------------------------------
/ads1015/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | ADS1015
19 |
20 |
--------------------------------------------------------------------------------
/apa102/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | APA102 demo
19 |
20 |
--------------------------------------------------------------------------------
/bmx280/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | Temperature demo
19 |
20 |
--------------------------------------------------------------------------------
/cap1xxx/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | CapTouch demo
19 |
20 |
--------------------------------------------------------------------------------
/pwmservo/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | Servo demo
19 |
20 |
--------------------------------------------------------------------------------
/pwmspeaker/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | Speaker Demo
19 |
20 |
--------------------------------------------------------------------------------
/ssd1306/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | OledScreen Demo
19 |
20 |
--------------------------------------------------------------------------------
/mma7660fc/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | Accelerometer Demo
19 |
20 |
--------------------------------------------------------------------------------
/tm1637/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | NumericDisplay demo
19 |
20 |
--------------------------------------------------------------------------------
/ht16k33/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | AlphanumericDisplay demo
19 |
20 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | include ':ads1015'
18 | include ':apa102'
19 | include ':bmx280'
20 | include ':cap1xxx'
21 | include ':gps'
22 | include ':ht16k33'
23 | include ':matrixkeypad'
24 | include ':mma7660fc'
25 | include ':pwmspeaker'
26 | include ':pwmservo'
27 | include ':ssd1306'
28 | include ':tm1637'
29 |
--------------------------------------------------------------------------------
/matrixkeypad/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /usr/local/google/home/fleker/Android/Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/mma7660fc/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'com.android.application'
18 |
19 | android {
20 | compileSdkVersion 27
21 |
22 | defaultConfig {
23 | applicationId 'com.example.androidthings.driversamples'
24 | minSdkVersion 27
25 | targetSdkVersion 27
26 | versionCode 1
27 | versionName '1.0'
28 | }
29 | }
30 |
31 | dependencies {
32 | implementation 'com.google.android.things.contrib:driver-mma7660fc:1.0'
33 | compileOnly 'com.google.android.things:androidthings:1.0'
34 | }
35 |
--------------------------------------------------------------------------------
/pwmspeaker/src/main/java/com/example/androidthings/driversamples/MusicNotes.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | public class MusicNotes {
20 |
21 | public static final double REST = -1;
22 | public static final double G4 = 391.995;
23 | public static final double E4_FLAT = 311.127;
24 |
25 | public static final double[] DRAMATIC_THEME = {
26 | G4, REST, G4, REST, G4, REST, E4_FLAT, E4_FLAT
27 | };
28 |
29 | private MusicNotes() {
30 | //no instance
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/gps/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'com.android.application'
18 |
19 | android {
20 | compileSdkVersion 27
21 |
22 | defaultConfig {
23 | applicationId "com.example.androidthings.driversamples"
24 | minSdkVersion 27
25 | targetSdkVersion 27
26 | versionCode 1
27 | versionName "1.0"
28 | }
29 | buildTypes {
30 | release {
31 | minifyEnabled false
32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33 | }
34 | }
35 | }
36 |
37 | dependencies {
38 | implementation 'com.google.android.things.contrib:driver-gps:1.0'
39 | compileOnly 'com.google.android.things:androidthings:1.0'
40 | }
41 |
--------------------------------------------------------------------------------
/pwmservo/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'com.android.application'
18 |
19 | android {
20 | compileSdkVersion 27
21 | defaultConfig {
22 | applicationId 'com.example.androidthings.driversamples'
23 | minSdkVersion 27
24 | targetSdkVersion 27
25 | versionCode 1
26 | versionName "1.0"
27 | }
28 | buildTypes {
29 | release {
30 | minifyEnabled false
31 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
32 | }
33 | }
34 | }
35 |
36 | dependencies {
37 | implementation 'com.google.android.things.contrib:driver-pwmservo:1.0'
38 | compileOnly 'com.google.android.things:androidthings:1.0'
39 | }
40 |
--------------------------------------------------------------------------------
/apa102/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'com.android.application'
18 |
19 | android {
20 | compileSdkVersion 27
21 |
22 | defaultConfig {
23 | applicationId 'com.example.androidthings.driversamples'
24 | minSdkVersion 27
25 | targetSdkVersion 27
26 | versionCode 1
27 | versionName "1.0"
28 | }
29 | buildTypes {
30 | release {
31 | minifyEnabled false
32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33 | }
34 | }
35 | }
36 |
37 | dependencies {
38 | implementation 'com.google.android.things.contrib:driver-apa102:1.0'
39 | compileOnly 'com.google.android.things:androidthings:1.0'
40 | }
41 |
--------------------------------------------------------------------------------
/bmx280/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'com.android.application'
18 |
19 | android {
20 | compileSdkVersion 27
21 |
22 | defaultConfig {
23 | applicationId 'com.example.androidthings.driversamples'
24 | minSdkVersion 27
25 | targetSdkVersion 27
26 | versionCode 1
27 | versionName "1.0"
28 | }
29 | buildTypes {
30 | release {
31 | minifyEnabled false
32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33 | }
34 | }
35 | }
36 |
37 | dependencies {
38 | implementation 'com.google.android.things.contrib:driver-bmx280:1.0'
39 | compileOnly 'com.google.android.things:androidthings:1.0'
40 | }
41 |
--------------------------------------------------------------------------------
/ht16k33/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'com.android.application'
18 |
19 | android {
20 | compileSdkVersion 27
21 |
22 | defaultConfig {
23 | applicationId 'com.example.androidthings.driversamples'
24 | minSdkVersion 27
25 | targetSdkVersion 27
26 | versionCode 1
27 | versionName "1.0"
28 | }
29 | buildTypes {
30 | release {
31 | minifyEnabled false
32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33 | }
34 | }
35 | }
36 |
37 | dependencies {
38 | implementation 'com.google.android.things.contrib:driver-ht16k33:1.0'
39 | compileOnly 'com.google.android.things:androidthings:1.0'
40 | }
41 |
--------------------------------------------------------------------------------
/pwmspeaker/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'com.android.application'
18 |
19 | android {
20 | compileSdkVersion 27
21 | defaultConfig {
22 | applicationId 'com.example.androidthings.driversamples'
23 | minSdkVersion 27
24 | targetSdkVersion 27
25 | versionCode 1
26 | versionName "1.0"
27 | }
28 | buildTypes {
29 | release {
30 | minifyEnabled false
31 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
32 | }
33 | }
34 | }
35 |
36 | dependencies {
37 | implementation 'com.google.android.things.contrib:driver-pwmspeaker:1.0'
38 | compileOnly 'com.google.android.things:androidthings:1.0'
39 | }
40 |
--------------------------------------------------------------------------------
/ssd1306/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'com.android.application'
18 |
19 | android {
20 | compileSdkVersion 27
21 |
22 | defaultConfig {
23 | applicationId 'com.example.androidthings.driversamples'
24 | minSdkVersion 27
25 | targetSdkVersion 27
26 | versionCode 1
27 | versionName "1.0"
28 | }
29 | buildTypes {
30 | release {
31 | minifyEnabled false
32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33 | }
34 | }
35 | }
36 |
37 | dependencies {
38 | implementation 'com.google.android.things.contrib:driver-ssd1306:1.1'
39 | compileOnly 'com.google.android.things:androidthings:1.0'
40 | }
41 |
--------------------------------------------------------------------------------
/tm1637/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'com.android.application'
18 |
19 | android {
20 | compileSdkVersion 27
21 |
22 | defaultConfig {
23 | applicationId 'com.example.androidthings.driversamples'
24 | minSdkVersion 27
25 | targetSdkVersion 27
26 | versionCode 1
27 | versionName "1.0"
28 | }
29 | buildTypes {
30 | release {
31 | minifyEnabled false
32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33 | }
34 | }
35 | }
36 |
37 | dependencies {
38 | implementation 'com.google.android.things.contrib:driver-tm1637:1.0'
39 | compileOnly 'com.google.android.things:androidthings:1.0'
40 | }
41 |
--------------------------------------------------------------------------------
/cap1xxx/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'com.android.application'
18 |
19 | android {
20 | compileSdkVersion 27
21 |
22 | defaultConfig {
23 | applicationId "com.example.androidthings.driversamples"
24 | minSdkVersion 27
25 | targetSdkVersion 27
26 | versionCode 1
27 | versionName "1.0"
28 | }
29 |
30 | buildTypes {
31 | release {
32 | minifyEnabled false
33 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
34 | }
35 | }
36 | }
37 |
38 | dependencies {
39 | implementation 'com.google.android.things.contrib:driver-cap1xxx:2.0'
40 | compileOnly 'com.google.android.things:androidthings:1.0'
41 | }
42 |
--------------------------------------------------------------------------------
/ads1015/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'com.android.application'
18 |
19 | android {
20 | compileSdkVersion 27
21 |
22 | defaultConfig {
23 | applicationId 'com.example.androidthings.driversamples'
24 | minSdkVersion 27
25 | targetSdkVersion 27
26 | versionCode 1
27 | versionName "1.0"
28 | }
29 |
30 | buildTypes {
31 | release {
32 | minifyEnabled false
33 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
34 | }
35 | }
36 |
37 | }
38 |
39 | dependencies {
40 | compileOnly 'com.google.android.things:androidthings:1.0'
41 | implementation 'com.google.android.things.contrib:driver-adc:2.1'
42 | }
43 |
--------------------------------------------------------------------------------
/matrixkeypad/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'com.android.application'
18 |
19 | android {
20 | compileSdkVersion 27
21 |
22 | defaultConfig {
23 | applicationId "com.example.androidthings.driversamples"
24 | minSdkVersion 27
25 | targetSdkVersion 27
26 | versionCode 1
27 | versionName "1.0"
28 | }
29 | buildTypes {
30 | release {
31 | minifyEnabled false
32 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33 | }
34 | }
35 | }
36 |
37 | dependencies {
38 | implementation 'com.google.android.things.contrib:driver-matrixkeypad:1.0'
39 | compileOnly 'com.google.android.things:androidthings:1.0'
40 | }
41 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Peripheral Driver Samples
2 |
3 | Samples for Android Things peripheral drivers located in the
4 | [contrib-drivers repository](https://github.com/androidthings/contrib-drivers).
5 |
6 | > **Note:** The Android Things Console will be turned down for non-commercial
7 | > use on January 5, 2022. For more details, see the
8 | > [FAQ page](https://developer.android.com/things/faq).
9 |
10 | ## Build and install
11 |
12 | Open the project in Android Studio, select the "Run Configuration" for the
13 | sample you want to run and click the "Run" button.
14 |
15 | See each sample subdirectory `README.md` for more instructions.
16 |
17 | ## License
18 |
19 | Copyright 2016 Google Inc.
20 |
21 | Licensed to the Apache Software Foundation (ASF) under one or more contributor
22 | license agreements. See the NOTICE file distributed with this work for
23 | additional information regarding copyright ownership. The ASF licenses this
24 | file to you under the Apache License, Version 2.0 (the "License"); you may not
25 | use this file except in compliance with the License. You may obtain a copy of
26 | the License at
27 |
28 | http://www.apache.org/licenses/LICENSE-2.0
29 |
30 | Unless required by applicable law or agreed to in writing, software
31 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
32 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
33 | License for the specific language governing permissions and limitations under
34 | the License.
35 |
--------------------------------------------------------------------------------
/matrixkeypad/src/main/res/layout/layout_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
22 |
30 |
36 |
--------------------------------------------------------------------------------
/pwmservo/src/main/java/com/example/androidthings/driversamples/BoardDefaults.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.os.Build;
20 |
21 | @SuppressWarnings("WeakerAccess")
22 | public class BoardDefaults {
23 | private static final String DEVICE_RPI3 = "rpi3";
24 | private static final String DEVICE_RPI3BP = "rpi3bp";
25 | private static final String DEVICE_IMX7D_PICO = "imx7d_pico";
26 |
27 | public static String getPwmPin() {
28 | switch (Build.DEVICE) {
29 | case DEVICE_RPI3:
30 | case DEVICE_RPI3BP:
31 | return "PWM0";
32 | case DEVICE_IMX7D_PICO:
33 | return "PWM1";
34 | default:
35 | throw new UnsupportedOperationException("Unknown device: " + Build.DEVICE);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/pwmspeaker/src/main/java/com/example/androidthings/driversamples/BoardDefaults.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.os.Build;
20 |
21 | @SuppressWarnings("WeakerAccess")
22 | public class BoardDefaults {
23 | private static final String DEVICE_RPI3 = "rpi3";
24 | private static final String DEVICE_RPI3BP = "rpi3bp";
25 | private static final String DEVICE_IMX7D_PICO = "imx7d_pico";
26 |
27 | public static String getPwmPin() {
28 | switch (Build.DEVICE) {
29 | case DEVICE_RPI3:
30 | case DEVICE_RPI3BP:
31 | return "PWM1";
32 | case DEVICE_IMX7D_PICO:
33 | return "PWM2";
34 | default:
35 | throw new UnsupportedOperationException("Unknown device: " + Build.DEVICE);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ads1015/src/main/java/com/example/android/things/ads1015/BoardDefaults.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.things.ads1015;
18 |
19 | import android.os.Build;
20 |
21 | @SuppressWarnings("WeakerAccess")
22 | public class BoardDefaults {
23 | private static final String DEVICE_RPI3 = "rpi3";
24 | private static final String DEVICE_RPI3BP = "rpi3bp";
25 | private static final String DEVICE_IMX7D_PICO = "imx7d_pico";
26 |
27 | /**
28 | * Return the preferred I2C port for each board.
29 | */
30 | public static String getI2CPort() {
31 | switch (Build.DEVICE) {
32 | case DEVICE_RPI3:
33 | case DEVICE_RPI3BP:
34 | return "I2C1";
35 | case DEVICE_IMX7D_PICO:
36 | return "I2C1";
37 | default:
38 | throw new IllegalStateException("Unknown Build.DEVICE " + Build.DEVICE);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/gps/src/main/java/com/example/androidthings/driversamples/BoardDefaults.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.os.Build;
20 |
21 | @SuppressWarnings("WeakerAccess")
22 | public class BoardDefaults {
23 | private static final String DEVICE_RPI3 = "rpi3";
24 | private static final String DEVICE_RPI3BP = "rpi3bp";
25 | private static final String DEVICE_IMX7D_PICO = "imx7d_pico";
26 |
27 | /**
28 | * Return the UART for current board.
29 | */
30 | public static String getUartName() {
31 | switch (Build.DEVICE) {
32 | case DEVICE_RPI3:
33 | case DEVICE_RPI3BP:
34 | return "UART0";
35 | case DEVICE_IMX7D_PICO:
36 | return "UART6";
37 | default:
38 | throw new IllegalStateException("Unknown Build.DEVICE " + Build.DEVICE);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/apa102/src/main/java/com/example/androidthings/driversamples/BoardDefaults.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.os.Build;
20 |
21 | @SuppressWarnings("WeakerAccess")
22 | public class BoardDefaults {
23 | private static final String DEVICE_RPI3 = "rpi3";
24 | private static final String DEVICE_RPI3BP = "rpi3bp";
25 | private static final String DEVICE_IMX7D_PICO = "imx7d_pico";
26 | /**
27 | * Return the preferred I2C port for each board.
28 | */
29 | public static String getSPIPort() {
30 | switch (Build.DEVICE) {
31 | case DEVICE_RPI3:
32 | case DEVICE_RPI3BP:
33 | return "SPI0.0";
34 | case DEVICE_IMX7D_PICO:
35 | return "SPI3.1";
36 | default:
37 | throw new IllegalStateException("Unknown Build.DEVICE " + Build.DEVICE);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/bmx280/src/main/java/com/example/androidthings/driversamples/BoardDefaults.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.os.Build;
20 |
21 | @SuppressWarnings("WeakerAccess")
22 | public class BoardDefaults {
23 | private static final String DEVICE_RPI3 = "rpi3";
24 | private static final String DEVICE_RPI3BP = "rpi3bp";
25 | private static final String DEVICE_IMX7D_PICO = "imx7d_pico";
26 |
27 | /**
28 | * Return the preferred I2C port for each board.
29 | */
30 | public static String getI2CPort() {
31 | switch (Build.DEVICE) {
32 | case DEVICE_RPI3:
33 | case DEVICE_RPI3BP:
34 | return "I2C1";
35 | case DEVICE_IMX7D_PICO:
36 | return "I2C1";
37 | default:
38 | throw new IllegalStateException("Unknown Build.DEVICE " + Build.DEVICE);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/cap1xxx/src/main/java/com/example/androidthings/driversamples/BoardDefaults.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.os.Build;
20 |
21 | @SuppressWarnings("WeakerAccess")
22 | public class BoardDefaults {
23 | private static final String DEVICE_RPI3 = "rpi3";
24 | private static final String DEVICE_RPI3BP = "rpi3bp";
25 | private static final String DEVICE_IMX7D_PICO = "imx7d_pico";
26 |
27 | /**
28 | * Return the preferred I2C port for each board.
29 | */
30 | public static String getI2CPort() {
31 | switch (Build.DEVICE) {
32 | case DEVICE_RPI3:
33 | case DEVICE_RPI3BP:
34 | return "I2C1";
35 | case DEVICE_IMX7D_PICO:
36 | return "I2C1";
37 | default:
38 | throw new IllegalStateException("Unknown Build.DEVICE " + Build.DEVICE);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ht16k33/src/main/java/com/example/androidthings/driversamples/BoardDefaults.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.os.Build;
20 |
21 | @SuppressWarnings("WeakerAccess")
22 | public class BoardDefaults {
23 | private static final String DEVICE_RPI3 = "rpi3";
24 | private static final String DEVICE_RPI3BP = "rpi3bp";
25 | private static final String DEVICE_IMX7D_PICO = "imx7d_pico";
26 |
27 | /**
28 | * Return the preferred I2C port for each board.
29 | */
30 | public static String getI2CPort() {
31 | switch (Build.DEVICE) {
32 | case DEVICE_RPI3:
33 | case DEVICE_RPI3BP:
34 | return "I2C1";
35 | case DEVICE_IMX7D_PICO:
36 | return "I2C1";
37 | default:
38 | throw new IllegalStateException("Unknown Build.DEVICE " + Build.DEVICE);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/mma7660fc/src/main/java/com/example/androidthings/driversamples/BoardDefaults.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.os.Build;
20 |
21 | @SuppressWarnings("WeakerAccess")
22 | public class BoardDefaults {
23 | private static final String DEVICE_RPI3 = "rpi3";
24 | private static final String DEVICE_RPI3BP = "rpi3bp";
25 | private static final String DEVICE_IMX7D_PICO = "imx7d_pico";
26 |
27 | /**
28 | * Return the preferred I2C port for each board.
29 | */
30 | public static String getI2CPort() {
31 | switch (Build.DEVICE) {
32 | case DEVICE_RPI3:
33 | case DEVICE_RPI3BP:
34 | return "I2C1";
35 | case DEVICE_IMX7D_PICO:
36 | return "I2C1";
37 | default:
38 | throw new IllegalStateException("Unknown Build.DEVICE " + Build.DEVICE);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ssd1306/src/main/java/com/example/androidthings/driversamples/BoardDefaults.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.os.Build;
20 |
21 | @SuppressWarnings("WeakerAccess")
22 | public class BoardDefaults {
23 | private static final String DEVICE_RPI3 = "rpi3";
24 | private static final String DEVICE_RPI3BP = "rpi3bp";
25 | private static final String DEVICE_IMX7D_PICO = "imx7d_pico";
26 |
27 | /**
28 | * Return the preferred I2C port for each board.
29 | */
30 | public static String getI2CPort() {
31 | switch (Build.DEVICE) {
32 | case DEVICE_RPI3:
33 | case DEVICE_RPI3BP:
34 | return "I2C1";
35 | case DEVICE_IMX7D_PICO:
36 | return "I2C1";
37 | default:
38 | throw new IllegalStateException("Unknown Build.DEVICE " + Build.DEVICE);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to become a contributor and submit your own code
2 |
3 | ## Contributor License Agreements
4 |
5 | We'd love to accept your sample apps and patches! Before we can take them, we
6 | have to jump a couple of legal hurdles.
7 |
8 | Please fill out either the individual or corporate Contributor License Agreement (CLA).
9 |
10 | * If you are an individual writing original source code and you're sure you
11 | own the intellectual property, then you'll need to sign an [individual CLA]
12 | (https://developers.google.com/open-source/cla/individual).
13 | * If you work for a company that wants to allow you to contribute your work,
14 | then you'll need to sign a [corporate CLA]
15 | (https://developers.google.com/open-source/cla/corporate).
16 |
17 | Follow either of the two links above to access the appropriate CLA and
18 | instructions for how to sign and return it. Once we receive it, we'll be able to
19 | accept your pull requests.
20 |
21 | ## Contributing A Patch
22 |
23 | 1. Submit an issue describing your proposed change to the repo in question.
24 | 1. The repo owner will respond to your issue promptly.
25 | 1. If your proposed change is accepted, and you haven't already done so, sign a
26 | Contributor License Agreement (see details above).
27 | 1. Fork the desired repo, develop and test your code changes.
28 | 1. Ensure that your code adheres to the existing style in the sample to which
29 | you are contributing. Refer to the
30 | [Android Code Style Guide]
31 | (https://source.android.com/source/code-style.html) for the
32 | recommended coding standards for this organization.
33 | 1. Ensure that your code has an appropriate set of unit tests which all pass.
34 | 1. Submit a pull request.
35 |
36 |
--------------------------------------------------------------------------------
/ads1015/README.md:
--------------------------------------------------------------------------------
1 | ADS1015 ADC sample for Android Things
2 | =====================================
3 |
4 | This Android Things sample demonstrates how to use an ADS1015 ADC module
5 | with the ADS1xxx contrib driver.
6 |
7 |
8 | Pre-requisites
9 | --------------
10 |
11 | - Android Things compatible board
12 | - Android Studio 2.2+
13 | - 1 [ADS1015 ADC module](https://www.adafruit.com/product/1083)
14 | - jumper wires
15 | - 1 breadboard
16 |
17 | Schematics
18 | ----------
19 |
20 | 
21 |
22 | Build and install
23 | =================
24 |
25 | On Android Studio, click on the "Run" button.
26 |
27 | If you prefer to run on the command line, from this repository's root directory, type
28 |
29 | ```bash
30 | ./gradlew ads1015:installDebug
31 | adb shell am start com.example.androidthings.driversamples/.MainActivity
32 | ```
33 |
34 | If you have everything set up correctly, the latest ADC reading will be
35 | written to logcat.
36 |
37 | License
38 | -------
39 |
40 | Copyright 2018 The Android Open Source Project, Inc.
41 |
42 | Licensed to the Apache Software Foundation (ASF) under one or more contributor
43 | license agreements. See the NOTICE file distributed with this work for
44 | additional information regarding copyright ownership. The ASF licenses this
45 | file to you under the Apache License, Version 2.0 (the "License"); you may not
46 | use this file except in compliance with the License. You may obtain a copy of
47 | the License at
48 |
49 | http://www.apache.org/licenses/LICENSE-2.0
50 |
51 | Unless required by applicable law or agreed to in writing, software
52 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
53 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
54 | License for the specific language governing permissions and limitations under
55 | the License.
56 |
--------------------------------------------------------------------------------
/apa102/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
32 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/pwmservo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
32 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/pwmspeaker/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
32 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/ssd1306/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
32 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/ht16k33/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
32 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/tm1637/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
32 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/ads1015/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
20 |
21 |
22 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
36 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/matrixkeypad/src/main/java/com/example/androidthings/driversamples/BoardDefaults.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.os.Build;
20 |
21 | public class BoardDefaults {
22 | private static final String DEVICE_RPI3 = "rpi3";
23 | private static final String DEVICE_RPI3BP = "rpi3bp";
24 | private static final String DEVICE_IMX7D_PICO = "imx7d_pico";
25 |
26 | public static String[] getRowPins() {
27 | switch (Build.DEVICE) {
28 | case DEVICE_RPI3:
29 | case DEVICE_RPI3BP:
30 | return new String[] {"BCM27", "BCM5", "BCM6", "BCM26"};
31 | case DEVICE_IMX7D_PICO:
32 | return new String[] {"GPIO2_IO03", "GPIO2_IO01", "GPIO2_IO02", "GPIO2_IO05"};
33 | default:
34 | throw new UnsupportedOperationException("Unknown device: " + Build.DEVICE);
35 | }
36 | }
37 |
38 | public static String[] getColPins() {
39 | switch (Build.DEVICE) {
40 | case DEVICE_RPI3:
41 | case DEVICE_RPI3BP:
42 | return new String[] {"BCM16", "BCM24", "BCM23"};
43 | case DEVICE_IMX7D_PICO:
44 | return new String[] {"GPIO2_IO07", "GPIO6_IO12", "GPIO6_IO13"};
45 | default:
46 | throw new UnsupportedOperationException("Unknown device: " + Build.DEVICE);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/bmx280/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
33 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/cap1xxx/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
33 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/matrixkeypad/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
33 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/mma7660fc/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
33 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/tm1637/src/main/java/com/example/androidthings/driversamples/BoardDefaults.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.os.Build;
20 |
21 | @SuppressWarnings("WeakerAccess")
22 | public class BoardDefaults {
23 | private static final String DEVICE_RPI3 = "rpi3";
24 | private static final String DEVICE_RPI3BP = "rpi3bp";
25 | private static final String DEVICE_IMX7D_PICO = "imx7d_pico";
26 |
27 | /**
28 | * Return the preferred Data GPIO pin for each board.
29 | */
30 | public static String getGPIOforData() {
31 |
32 | switch (Build.DEVICE) {
33 | case DEVICE_RPI3:
34 | case DEVICE_RPI3BP:
35 | return "BCM20";
36 | case DEVICE_IMX7D_PICO:
37 | return "GPIO6_IO15";
38 | default:
39 | throw new IllegalStateException("Unknown Build.DEVICE " + Build.DEVICE);
40 | }
41 | }
42 |
43 | /**
44 | * Return the preferred Clock GPIO pin for each board.
45 | */
46 | public static String getGPIOforClock() {
47 | switch (Build.DEVICE) {
48 | case DEVICE_RPI3:
49 | case DEVICE_RPI3BP:
50 | return "BCM21";
51 | case DEVICE_IMX7D_PICO:
52 | return "GPIO6_IO14";
53 | default:
54 | throw new IllegalStateException("Unknown Build.DEVICE " + Build.DEVICE);
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/pwmservo/README.md:
--------------------------------------------------------------------------------
1 | Servo sample for Android Things
2 | ===============================
3 |
4 | This sample demonstrates how to control a servo using PWM with Android Things.
5 |
6 |
7 | Screenshots
8 | -----------
9 |
10 | ![Servo sample demo][demo-gif]
11 |
12 | [(Watch the demo on YouTube)][demo-yt]
13 |
14 | Pre-requisites
15 | --------------
16 |
17 | - Android Things compatible board
18 | - Android Studio 2.2+
19 | - 1 [servo](https://www.adafruit.com/products/169)
20 | - jumper wires
21 | - 1 breadboard
22 |
23 |
24 | Schematics
25 | ----------
26 |
27 | 
28 |
29 |
30 | Build and install
31 | =================
32 |
33 | On Android Studio, click on the "Run" button.
34 |
35 | If you prefer to run on the command line, from this repository's root directory, type
36 |
37 | ```bash
38 | ./gradlew pwmservo:installDebug
39 | adb shell am start com.example.androidthings.driversamples/.ServoActivity
40 | ```
41 |
42 | If you have everything set up correctly, you will see the servo periodically update its position.
43 |
44 |
45 | License
46 | -------
47 |
48 | Copyright 2016 The Android Open Source Project, Inc.
49 |
50 | Licensed to the Apache Software Foundation (ASF) under one or more contributor
51 | license agreements. See the NOTICE file distributed with this work for
52 | additional information regarding copyright ownership. The ASF licenses this
53 | file to you under the Apache License, Version 2.0 (the "License"); you may not
54 | use this file except in compliance with the License. You may obtain a copy of
55 | the License at
56 |
57 | http://www.apache.org/licenses/LICENSE-2.0
58 |
59 | Unless required by applicable law or agreed to in writing, software
60 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
61 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
62 | License for the specific language governing permissions and limitations under
63 | the License.
64 |
65 | [demo-yt]: https://www.youtube.com/watch?v=2IC6zcF29Ww&index=20&list=PLWz5rJ2EKKc-GjpNkFe9q3DhE2voJscDT
66 | [demo-gif]: https://storage.googleapis.com/android-things/samples-gifs/pwmservo.gif
--------------------------------------------------------------------------------
/matrixkeypad/README.md:
--------------------------------------------------------------------------------
1 | # Matrix Keypad sample for Android Things
2 |
3 | This sample demonstrates how to receive events from a matrix keypad with Android Things.
4 |
5 | ## Pre-requisites
6 |
7 |
8 | - Android Things compatible board
9 | - Android Studio 2.2+
10 | - 1 [matrix keypad](https://www.adafruit.com/products/419)
11 | - jumper wires
12 | - 1 breadboard
13 | - 4 resistors (any impedance should be fine)
14 |
15 | ### Example wiring diagram
16 | 
17 |
18 | See the schematic above as a reference for how to wire the matrix keypad.
19 | Note that the first four pins, for each row, are connected to ground with
20 | a resistor.
21 |
22 | ## Build and install
23 |
24 | On Android Studio, click on the "Run" button.
25 |
26 | If you prefer to run on the command line, from this repository's root directory, type
27 |
28 | ```bash
29 | ./gradlew matrixkeypad:installDebug
30 | adb shell am start com.example.androidthings.driversamples/.MatrixKeypadActivity
31 | ```
32 |
33 | If everything is set up correctly, you will see key events be logged for every button you
34 | push on the keypad.
35 |
36 | ### Using a UI
37 | A user interface is optionally available, allowing the user to print
38 | keys on the screen. To use this mode, set the value of `USE_LAYOUT` to `true`
39 | in `MatrixKeypadActivity.java`.
40 |
41 | ## License
42 |
43 | Copyright 2017 The Android Open Source Project, Inc.
44 |
45 | Licensed to the Apache Software Foundation (ASF) under one or more contributor
46 | license agreements. See the NOTICE file distributed with this work for
47 | additional information regarding copyright ownership. The ASF licenses this
48 | file to you under the Apache License, Version 2.0 (the "License"); you may not
49 | use this file except in compliance with the License. You may obtain a copy of
50 | the License at
51 |
52 | http://www.apache.org/licenses/LICENSE-2.0
53 |
54 | Unless required by applicable law or agreed to in writing, software
55 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
56 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
57 | License for the specific language governing permissions and limitations under
58 | the License.
59 |
--------------------------------------------------------------------------------
/gps/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
37 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/tm1637/README.md:
--------------------------------------------------------------------------------
1 | 4-Digit Segment Display sample for Android Things
2 | =================================================
3 |
4 | This Android Things sample demonstrates how to use a 4-Digit segment display
5 | based on the TM1637 IC.
6 |
7 |
8 | Screenshots
9 | -----------
10 |
11 | ![4-Digit Segment Display sample demo][demo-gif]
12 |
13 | [(Watch the demo on YouTube)][demo-yt]
14 |
15 | Pre-requisites
16 | --------------
17 |
18 | - Android Things compatible board
19 | - Android Studio 2.2+
20 | - 1 4-Digit Segment display like [this](http://wiki.seeed.cc/Grove-4-Digit_Display/)
21 | - jumper wires
22 | - 1 breadboard
23 |
24 |
25 | Schematics
26 | ----------
27 |
28 | 
29 |
30 |
31 | Build and install
32 | =================
33 |
34 | On Android Studio, click on the "Run" button.
35 |
36 | If you prefer to run on the command line, from this repository's root directory, type
37 |
38 | ```bash
39 | ./gradlew tm1637:installDebug
40 | adb shell am start com.example.androidthings.driversamples/.SegmentDisplayActivity
41 | ```
42 |
43 | If you have everything set up correctly, the segment display will show "2342".
44 |
45 | License
46 | -------
47 |
48 | Copyright 2016 The Android Open Source Project, Inc.
49 |
50 | Licensed to the Apache Software Foundation (ASF) under one or more contributor
51 | license agreements. See the NOTICE file distributed with this work for
52 | additional information regarding copyright ownership. The ASF licenses this
53 | file to you under the Apache License, Version 2.0 (the "License"); you may not
54 | use this file except in compliance with the License. You may obtain a copy of
55 | the License at
56 |
57 | http://www.apache.org/licenses/LICENSE-2.0
58 |
59 | Unless required by applicable law or agreed to in writing, software
60 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
61 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
62 | License for the specific language governing permissions and limitations under
63 | the License.
64 |
65 | [demo-yt]: https://www.youtube.com/watch?v=fUwTR3X9BdE&index=23&list=PLWz5rJ2EKKc-GjpNkFe9q3DhE2voJscDT
66 | [demo-gif]: https://storage.googleapis.com/android-things/samples-gifs/tm1637.png
--------------------------------------------------------------------------------
/mma7660fc/README.md:
--------------------------------------------------------------------------------
1 | Accelerometer sample for Android Things
2 | =======================================
3 |
4 | This Android Things sample demonstrates how to use the MMA7660FC accelerometer
5 | sensor and integrates it into the Android sensor framework.
6 |
7 | Pre-requisites
8 | --------------
9 |
10 | - Android Things compatible board
11 | - Android Studio 2.2+
12 | - 1 [MMA7660FC based accelerometer](http://wiki.seeed.cc/Grove-3-Axis_Digital_Accelerometer-1.5g/)
13 | - jumper wires
14 | - 1 breadboard
15 |
16 |
17 | Schematics
18 | ----------
19 |
20 | 
21 |
22 |
23 | Build and install
24 | =================
25 |
26 | On Android Studio, click on the "Run" button.
27 |
28 | If you prefer to run on the command line, from this repository's root directory, type
29 |
30 | ```bash
31 | ./gradlew mma7660fc:installDebug
32 | adb shell am start com.example.androidthings.driversamples/.AccelerometerActivity
33 | ```
34 |
35 | If you have everything set up correctly, a log will be generated on logcat
36 | whenever there is an accelerometer sensor update.
37 |
38 | Notice that the Accelerometer driver integrates with the Android sensor
39 | framework using a user driver and fuses with other sensors, so
40 | the part of the app that handles the sensor updates works exactly the same
41 | no matter which, or how many accelerometer sources are available.
42 |
43 |
44 | License
45 | -------
46 |
47 | Copyright 2016 The Android Open Source Project, Inc.
48 |
49 | Licensed to the Apache Software Foundation (ASF) under one or more contributor
50 | license agreements. See the NOTICE file distributed with this work for
51 | additional information regarding copyright ownership. The ASF licenses this
52 | file to you under the Apache License, Version 2.0 (the "License"); you may not
53 | use this file except in compliance with the License. You may obtain a copy of
54 | the License at
55 |
56 | http://www.apache.org/licenses/LICENSE-2.0
57 |
58 | Unless required by applicable law or agreed to in writing, software
59 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
60 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
61 | License for the specific language governing permissions and limitations under
62 | the License.
63 |
--------------------------------------------------------------------------------
/ssd1306/README.md:
--------------------------------------------------------------------------------
1 | OLED Screen sample for Android Things
2 | =====================================
3 |
4 | This sample demonstrates how to control the SSD1306 OLED display using I2C with
5 | Android Things.
6 |
7 |
8 | Screenshots
9 | -----------
10 |
11 | ![OLED Screen sample demo][demo-gif]
12 |
13 | [(Watch the demo on YouTube)][demo-yt]
14 |
15 | Pre-requisites
16 | --------------
17 |
18 | - Android Things compatible board
19 | - Android Studio 2.2+
20 | - 1 [SSD1306 OLED screen](https://www.adafruit.com/product/326)
21 | - jumper wires
22 | - 1 breadboard
23 |
24 |
25 | Schematics
26 | ----------
27 |
28 | 
29 |
30 |
31 | Build and install
32 | =================
33 |
34 | On Android Studio, click on the "Run" button.
35 |
36 | If you prefer to run on the command line, from this repository's root directory, type
37 |
38 | ```bash
39 | ./gradlew ssd1306:installDebug
40 | adb shell am start com.example.androidthings.driversamples/.OledScreenActivity
41 | ```
42 |
43 | If you have everything set up correctly, you will see a small bitmap slowly
44 | moving in the screen. If you want to change the pattern displayed, change the
45 | variable mMode in OledScreenActivity and deploy again. The sample has three
46 | modes: DOTS, BITMAP (default) and CROSSHAIRS.
47 |
48 |
49 | License
50 | -------
51 |
52 | Copyright 2016 The Android Open Source Project, Inc.
53 |
54 | Licensed to the Apache Software Foundation (ASF) under one or more contributor
55 | license agreements. See the NOTICE file distributed with this work for
56 | additional information regarding copyright ownership. The ASF licenses this
57 | file to you under the Apache License, Version 2.0 (the "License"); you may not
58 | use this file except in compliance with the License. You may obtain a copy of
59 | the License at
60 |
61 | http://www.apache.org/licenses/LICENSE-2.0
62 |
63 | Unless required by applicable law or agreed to in writing, software
64 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
65 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
66 | License for the specific language governing permissions and limitations under
67 | the License.
68 |
69 | [demo-yt]: https://www.youtube.com/watch?v=Ozrn5FEqmj0&list=PLWz5rJ2EKKc-GjpNkFe9q3DhE2voJscDT&index=22
70 | [demo-gif]: https://storage.googleapis.com/android-things/samples-gifs/ssd1306.gif
--------------------------------------------------------------------------------
/tm1637/src/main/java/com/example/androidthings/driversamples/SegmentDisplayActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.app.Activity;
20 | import android.os.Bundle;
21 | import android.util.Log;
22 |
23 | import com.google.android.things.contrib.driver.tm1637.NumericDisplay;
24 |
25 | import java.io.IOException;
26 |
27 | /**
28 | * SegmentDisplayActivity is an example that use the driver
29 | * for the TM1637 Alphanumeric segment display.
30 | */
31 | public class SegmentDisplayActivity extends Activity {
32 | private static final String TAG = SegmentDisplayActivity.class.getSimpleName();
33 |
34 | private NumericDisplay mSegmentDisplay;
35 |
36 | @Override
37 | protected void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | Log.i(TAG, "Starting SegmentDisplayActivity");
40 | try {
41 | mSegmentDisplay = new NumericDisplay(
42 | BoardDefaults.getGPIOforData(),
43 | BoardDefaults.getGPIOforClock());
44 | mSegmentDisplay.setBrightness(1.0f);
45 | mSegmentDisplay.setColonEnabled(true);
46 | mSegmentDisplay.display("2342");
47 | } catch (IOException e) {
48 | Log.e(TAG, "Error configuring display", e);
49 | }
50 | }
51 |
52 | @Override
53 | protected void onDestroy() {
54 | super.onDestroy();
55 | if (mSegmentDisplay != null) {
56 | Log.i(TAG, "Closing display");
57 | try {
58 | mSegmentDisplay.close();
59 | } catch (IOException e) {
60 | Log.e(TAG, "Error closing display", e);
61 | } finally {
62 | mSegmentDisplay = null;
63 | }
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/ht16k33/README.md:
--------------------------------------------------------------------------------
1 | Segment display sample for Android Things
2 | =========================================
3 |
4 | This Android Things sample demonstrates how to use a segment display based on
5 | the HT16K33 chip with an I2C backpack.
6 |
7 |
8 | Screenshots
9 | -----------
10 |
11 | ![Segment display sample demo][demo-gif]
12 |
13 | [(Watch the demo on YouTube)][demo-yt]
14 |
15 | Pre-requisites
16 | --------------
17 |
18 | - Android Things compatible board
19 | - Android Studio 2.2+
20 | - [Rainbow Hat for Android Things](https://shop.pimoroni.com/products/rainbow-hat-for-android-things) or the following individual components:
21 | - 1 [HT16K33 based segment display with I2C backpack](https://www.adafruit.com/product/1270)
22 | - jumper wires
23 | - 1 breadboard
24 |
25 | Schematics
26 | ----------
27 |
28 | If you have the Raspberry Pi [Rainbow Hat for Android Things](https://shop.pimoroni.com/products/rainbow-hat-for-android-things), just plug it onto your Raspberry Pi 3.
29 |
30 | 
31 |
32 | Build and install
33 | =================
34 |
35 | On Android Studio, click on the "Run" button.
36 |
37 | If you prefer to run on the command line, from this repository's root directory, type
38 |
39 | ```bash
40 | ./gradlew ht16k33:installDebug
41 | adb shell am start com.example.androidthings.driversamples/.SegmentDisplayActivity
42 | ```
43 |
44 | If you have everything set up correctly, the segment display will show "ABCD".
45 |
46 | License
47 | -------
48 |
49 | Copyright 2016 The Android Open Source Project, Inc.
50 |
51 | Licensed to the Apache Software Foundation (ASF) under one or more contributor
52 | license agreements. See the NOTICE file distributed with this work for
53 | additional information regarding copyright ownership. The ASF licenses this
54 | file to you under the Apache License, Version 2.0 (the "License"); you may not
55 | use this file except in compliance with the License. You may obtain a copy of
56 | the License at
57 |
58 | http://www.apache.org/licenses/LICENSE-2.0
59 |
60 | Unless required by applicable law or agreed to in writing, software
61 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
62 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
63 | License for the specific language governing permissions and limitations under
64 | the License.
65 |
66 | [demo-yt]: https://www.youtube.com/watch?v=OiPkBVN_ulc&index=19&list=PLWz5rJ2EKKc-GjpNkFe9q3DhE2voJscDT
67 | [demo-gif]: https://storage.googleapis.com/android-things/samples-gifs/ht16k33.png
--------------------------------------------------------------------------------
/bmx280/README.md:
--------------------------------------------------------------------------------
1 | Temperature sensor sample for Android Things
2 | ============================================
3 |
4 | This Android Things sample demonstrates how to use a BMP280 temperature sensor
5 | and integrate it to the Android `SensorManager`.
6 |
7 |
8 | Screenshots
9 | -----------
10 |
11 | ![Temperature sensor sample demo][demo-gif]
12 |
13 | [(Watch the demo on YouTube)][demo-yt]
14 |
15 | Pre-requisites
16 | --------------
17 |
18 | - Android Things compatible board
19 | - Android Studio 2.2+
20 | - [Rainbow Hat for Android Things](https://shop.pimoroni.com/products/rainbow-hat-for-android-things) or the following individual components:
21 | - 1 [BMP280 temperature sensor](https://www.adafruit.com/product/2651)
22 | - jumper wires
23 | - 1 breadboard
24 |
25 | Schematics
26 | ----------
27 |
28 | If you have the Raspberry Pi [Rainbow Hat for Android Things](https://shop.pimoroni.com/products/rainbow-hat-for-android-things), just plug it onto your Raspberry Pi 3.
29 |
30 | 
31 |
32 | Build and install
33 | =================
34 |
35 | On Android Studio, click on the "Run" button.
36 |
37 | If you prefer to run on the command line, from this repository's root directory, type
38 |
39 | ```bash
40 | ./gradlew bmx280:installDebug
41 | adb shell am start com.example.androidthings.driversamples/.TemperatureActivity
42 | ```
43 |
44 | If you have everything set up correctly, the current temperature will be
45 | logged to logcat.
46 |
47 | License
48 | -------
49 |
50 | Copyright 2016 The Android Open Source Project, Inc.
51 |
52 | Licensed to the Apache Software Foundation (ASF) under one or more contributor
53 | license agreements. See the NOTICE file distributed with this work for
54 | additional information regarding copyright ownership. The ASF licenses this
55 | file to you under the Apache License, Version 2.0 (the "License"); you may not
56 | use this file except in compliance with the License. You may obtain a copy of
57 | the License at
58 |
59 | http://www.apache.org/licenses/LICENSE-2.0
60 |
61 | Unless required by applicable law or agreed to in writing, software
62 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
63 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
64 | License for the specific language governing permissions and limitations under
65 | the License.
66 |
67 | [demo-yt]: https://www.youtube.com/watch?v=K4WuwHODXvY&list=PLWz5rJ2EKKc-GjpNkFe9q3DhE2voJscDT&index=16
68 | [demo-gif]: https://storage.googleapis.com/android-things/samples-gifs/bmx280.gif
--------------------------------------------------------------------------------
/ht16k33/src/main/java/com/example/androidthings/driversamples/SegmentDisplayActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.app.Activity;
20 | import android.os.Bundle;
21 | import android.util.Log;
22 |
23 | import com.google.android.things.contrib.driver.ht16k33.AlphanumericDisplay;
24 |
25 | import java.io.IOException;
26 |
27 | /**
28 | * SegmentDisplayActivity is an example that use the driver
29 | * for the HT16k33 Alphanumeric segment display.
30 | */
31 | public class SegmentDisplayActivity extends Activity {
32 | private static final String TAG = SegmentDisplayActivity.class.getSimpleName();
33 | /**
34 | * I2C bus the segment display is connected to.
35 | */
36 | private static final String I2C_BUS = BoardDefaults.getI2CPort();
37 |
38 | private AlphanumericDisplay mSegmentDisplay;
39 |
40 | @Override
41 | protected void onCreate(Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 | Log.i(TAG, "Starting SegmentDisplayActivity");
44 |
45 | try {
46 | mSegmentDisplay = new AlphanumericDisplay(I2C_BUS);
47 | mSegmentDisplay.setBrightness(1.0f);
48 | mSegmentDisplay.setEnabled(true);
49 | mSegmentDisplay.clear();
50 | mSegmentDisplay.display("ABCD");
51 | } catch (IOException e) {
52 | Log.e(TAG, "Error configuring display", e);
53 | }
54 | }
55 |
56 | @Override
57 | protected void onDestroy() {
58 | super.onDestroy();
59 | if (mSegmentDisplay != null) {
60 | Log.i(TAG, "Closing display");
61 | try {
62 | mSegmentDisplay.close();
63 | } catch (IOException e) {
64 | Log.e(TAG, "Error closing display", e);
65 | } finally {
66 | mSegmentDisplay = null;
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/pwmspeaker/README.md:
--------------------------------------------------------------------------------
1 | PWM Speaker Sample for Android Things
2 | =============================================
3 |
4 | This sample demonstrates how to control a speaker/buzzer using PWM with
5 | Android Things.
6 |
7 |
8 | Screenshots
9 | -----------
10 |
11 | ![PWM Speaker sample demo][demo-gif]
12 |
13 | [(Watch the demo on YouTube)][demo-yt]
14 |
15 | Pre-requisites
16 | --------------
17 |
18 | - Android Things compatible board
19 | - Android Studio 2.2+
20 | - [Rainbow Hat for Android Things](https://shop.pimoroni.com/products/rainbow-hat-for-android-things) or the following individual components:
21 | - 1 [Piezo Buzzer](https://www.adafruit.com/products/160)
22 | - jumper wires
23 | - 1 breadboard
24 |
25 | Schematics
26 | ----------
27 |
28 | If you have the Raspberry Pi [Rainbow Hat for Android Things](https://shop.pimoroni.com/products/rainbow-hat-for-android-things), just plug it onto your Raspberry Pi 3.
29 |
30 | 
31 |
32 | Build and install
33 | =================
34 |
35 | On Android Studio, click on the "Run" button.
36 |
37 | If you prefer to run on the command line, from this repository's root directory, type
38 |
39 | ```bash
40 | ./gradlew pwmspeaker:installDebug
41 | adb shell am start com.example.androidthings.driversamples/.SpeakerActivity
42 | ```
43 |
44 | If you have everything set up correctly, you will hear the speaker play a
45 | series of notes. To play the tune again, re-run the app from AndroidStudio.
46 | If you prefer the command line, run again with
47 |
48 | ```bash
49 | adb shell am start -S com.example.androidthings.driversamples/.SpeakerActivity
50 | ```
51 |
52 | License
53 | -------
54 |
55 | Copyright 2016 The Android Open Source Project, Inc.
56 |
57 | Licensed to the Apache Software Foundation (ASF) under one or more contributor
58 | license agreements. See the NOTICE file distributed with this work for
59 | additional information regarding copyright ownership. The ASF licenses this
60 | file to you under the Apache License, Version 2.0 (the "License"); you may not
61 | use this file except in compliance with the License. You may obtain a copy of
62 | the License at
63 |
64 | http://www.apache.org/licenses/LICENSE-2.0
65 |
66 | Unless required by applicable law or agreed to in writing, software
67 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
68 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
69 | License for the specific language governing permissions and limitations under
70 | the License.
71 |
72 | [demo-yt]: https://www.youtube.com/watch?v=T81zZpaO8qU&index=21&list=PLWz5rJ2EKKc-GjpNkFe9q3DhE2voJscDT
73 | [demo-gif]: https://storage.googleapis.com/android-things/samples-gifs/pwmspeaker.gif
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/cap1xxx/README.md:
--------------------------------------------------------------------------------
1 | Capacitive touch sample for Android Things
2 | ============================================
3 |
4 | This Android Things sample demonstrates how to connect to a Capacitive Touch
5 | sensor based on a CAP1xxx microchip and how to integrate it to the
6 | Android framework using an InputDriver.
7 |
8 |
9 | Screenshots
10 | -----------
11 |
12 | ![Capacitive touch sample demo][demo-gif]
13 |
14 | [(Watch the demo on YouTube)][demo-yt]
15 |
16 | Pre-requisites
17 | --------------
18 |
19 | - Android Things compatible board
20 | - Android Studio 2.2+
21 | - 1 capacitive touch sensor based on a CAP1xxx microchip like the
22 | [Pimoroni Explorer Hat](https://www.adafruit.com/product/2427)
23 | - jumper wires
24 | - 1 breadboard
25 |
26 |
27 | Schematics
28 | ----------
29 |
30 | If using the [Raspberry Pi Explorer Hat]((https://shop.pimoroni.com/products/explorer-hat), just plug it onto your Raspberry Pi 3.
31 |
32 |
33 | Build and install
34 | =================
35 |
36 | On Android Studio, click on the "Run" button.
37 |
38 | If you prefer to run on the command line, from this repository's root directory, type
39 |
40 | ```bash
41 | ./gradlew cap1xxx:installDebug
42 | adb shell am start com.example.androidthings.driversamples/.CaptouchActivity
43 | ```
44 |
45 | If you have everything set up correctly, pressing any of the 8 capacitive
46 | buttons labeled 1 to 8 on the Explorer Hat will log the corresponding button
47 | label to logcat.
48 |
49 | Notice that the Cap12xx driver integrates with the Android framework using an
50 | InputDriver user driver and simulates regular key presses, so the part of the
51 | app that handles the button presses works exactly the same as if it was a
52 | regular keyboard generating the key presses.
53 |
54 |
55 | License
56 | -------
57 |
58 | Copyright 2016 The Android Open Source Project, Inc.
59 |
60 | Licensed to the Apache Software Foundation (ASF) under one or more contributor
61 | license agreements. See the NOTICE file distributed with this work for
62 | additional information regarding copyright ownership. The ASF licenses this
63 | file to you under the Apache License, Version 2.0 (the "License"); you may not
64 | use this file except in compliance with the License. You may obtain a copy of
65 | the License at
66 |
67 | http://www.apache.org/licenses/LICENSE-2.0
68 |
69 | Unless required by applicable law or agreed to in writing, software
70 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
71 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
72 | License for the specific language governing permissions and limitations under
73 | the License.
74 |
75 | [demo-yt]: https://www.youtube.com/watch?v=4vbNUmD7vM0&index=17&list=PLWz5rJ2EKKc-GjpNkFe9q3DhE2voJscDT
76 | [demo-gif]: https://storage.googleapis.com/android-things/samples-gifs/cap12xx.gif
--------------------------------------------------------------------------------
/gps/README.md:
--------------------------------------------------------------------------------
1 | UART GPS sample for Android Things
2 | ==================================
3 |
4 | This Android Things sample demonstrates how to connect to a GPS unit that
5 | emits data via UART in the NMEA format, and integrates it into the Android
6 | location framework.
7 |
8 |
9 | Screenshots
10 | -----------
11 |
12 | ![UART GPS sample demo][demo-gif]
13 |
14 | [(Watch the demo on YouTube)][demo-yt]
15 |
16 | Pre-requisites
17 | --------------
18 |
19 | - Android Things compatible board
20 | - Android Studio 2.2+
21 | - 1 GPS NMEA-compatible module with UART interface, like the
22 | [Ultimate GPS hat](https://www.adafruit.com/product/2324)
23 | - jumper wires
24 | - 1 breadboard
25 |
26 |
27 | Schematics
28 | ----------
29 |
30 | If using the [Raspberry Pi Ultimate GPS Hat](https://www.adafruit.com/product/2324), just plug it
31 | onto your Raspberry Pi 3.
32 |
33 | NOTE: Raspberry Pi 3 shares the UART pins between multiple ports, including the serial debugging
34 | console. Refer to the [mode matrix][pi3-modes] for more details.
35 |
36 | Build and install
37 | =================
38 |
39 | On Android Studio, click on the "Run" button.
40 |
41 | If you prefer to run on the command line, from this repository's root directory, type
42 |
43 | ```bash
44 | ./gradlew gps:installDebug
45 | adb shell am start com.example.androidthings.driversamples/.GpsActivity
46 | ```
47 |
48 | If you have everything set up correctly, a log will be generated on logcat
49 | whenever there is a location update.
50 |
51 | Notice that the GPS driver integrates with the Android location framework
52 | using a GpsDriver user driver and fuses with other location sources, so
53 | the part of the app that handles the location updates works exactly the same
54 | no matter which, or how many location sources are available.
55 |
56 |
57 | License
58 | -------
59 |
60 | Copyright 2016 The Android Open Source Project, Inc.
61 |
62 | Licensed to the Apache Software Foundation (ASF) under one or more contributor
63 | license agreements. See the NOTICE file distributed with this work for
64 | additional information regarding copyright ownership. The ASF licenses this
65 | file to you under the Apache License, Version 2.0 (the "License"); you may not
66 | use this file except in compliance with the License. You may obtain a copy of
67 | the License at
68 |
69 | http://www.apache.org/licenses/LICENSE-2.0
70 |
71 | Unless required by applicable law or agreed to in writing, software
72 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
73 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
74 | License for the specific language governing permissions and limitations under
75 | the License.
76 |
77 | [pi3-modes]: https://developer.android.com/things/hardware/raspberrypi-mode-matrix.html
78 | [demo-yt]: https://www.youtube.com/watch?v=ld-06RYRZVQ&index=18&list=PLWz5rJ2EKKc-GjpNkFe9q3DhE2voJscDT
79 | [demo-gif]: https://storage.googleapis.com/android-things/samples-gifs/gps.gif
--------------------------------------------------------------------------------
/apa102/README.md:
--------------------------------------------------------------------------------
1 | RGB LED strip (APA102) sample for Android Things
2 | ================================================
3 |
4 | This Android Things sample demonstrates how to interface with a basic
5 | RGB led strip using the APA102 over SPI protocol.
6 |
7 |
8 | Screenshots
9 | -----------
10 |
11 | ![RGB LED strip sample demo][demo-gif]
12 |
13 | [(Watch the demo on YouTube)][demo-yt]
14 |
15 | Pre-requisites
16 | --------------
17 |
18 | - Android Things compatible board
19 | - Android Studio 2.2+
20 | - [Rainbow Hat for Android Things](https://shop.pimoroni.com/products/rainbow-hat-for-android-things) or the following individual components:
21 | - 1 [APA102 compatible RGB Led strip](https://www.adafruit.com/product/2241)
22 | - jumper wires
23 |
24 | Schematics
25 | ----------
26 |
27 | If you have the Raspberry Pi [Rainbow Hat for Android Things](https://shop.pimoroni.com/products/rainbow-hat-for-android-things), just plug it onto your Raspberry Pi 3.
28 |
29 | 
30 |
31 | The 5v and GND from the Edison and Raspberry Pi 3 are sufficient for driving a few LEDs,
32 | connect these pins to the power pins on the APA102 connector.
33 |
34 | Build and install
35 | =================
36 |
37 | On Android Studio, edit the `MainActivity.java` file and set the correct number
38 | of LEDs in your LED strip (constant `NUM_LEDS`).
39 |
40 | Then, click on the "Run" button.
41 |
42 | If you prefer to run on the command line, from this repository's root directory, type
43 |
44 | ```bash
45 | ./gradlew apa102:installDebug
46 | adb shell am start com.example.androidthings.driversamples/.MainActivity
47 | ```
48 |
49 | The LEDs will blink in various patterns.
50 |
51 | Troubleshooting
52 | =================
53 |
54 | For a strip with more than a few LEDs, use an external power adapter for your
55 | board, or power the LED strip from an external power source.
56 |
57 | License
58 | -------
59 |
60 | Copyright 2016 The Android Open Source Project, Inc.
61 |
62 | Licensed to the Apache Software Foundation (ASF) under one or more contributor
63 | license agreements. See the NOTICE file distributed with this work for
64 | additional information regarding copyright ownership. The ASF licenses this
65 | file to you under the Apache License, Version 2.0 (the "License"); you may not
66 | use this file except in compliance with the License. You may obtain a copy of
67 | the License at
68 |
69 | http://www.apache.org/licenses/LICENSE-2.0
70 |
71 | Unless required by applicable law or agreed to in writing, software
72 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
73 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
74 | License for the specific language governing permissions and limitations under
75 | the License.
76 |
77 | [demo-yt]: https://www.youtube.com/watch?v=HGhk9xm7qig&index=15&list=PLWz5rJ2EKKc-GjpNkFe9q3DhE2voJscDT
78 | [demo-gif]: https://storage.googleapis.com/android-things/samples-gifs/apa102.gif
--------------------------------------------------------------------------------
/ads1015/src/main/java/com/example/android/things/ads1015/MainActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.things.ads1015;
18 |
19 | import android.app.Activity;
20 | import android.os.Bundle;
21 | import android.os.Handler;
22 | import android.os.HandlerThread;
23 | import android.util.Log;
24 | import android.widget.TextView;
25 |
26 | import com.google.android.things.contrib.driver.adc.ads1xxx.Ads1xxx;
27 |
28 | import java.io.IOException;
29 |
30 | /**
31 | * Sample activity that demonstrates the usage of the
32 | * Ads1xxx driver with an ADS1015 module.
33 | *
34 | * https://www.adafruit.com/product/1083
35 | */
36 | public class MainActivity extends Activity {
37 | private static final String TAG = MainActivity.class.getSimpleName();
38 |
39 | private static final int DELAY_MS = 100; // 10 samples/second
40 |
41 | private Ads1xxx mAdcDriver;
42 | private Handler mHandler;
43 | private HandlerThread mReadThread;
44 |
45 | @Override
46 | protected void onCreate(Bundle savedInstanceState) {
47 | super.onCreate(savedInstanceState);
48 |
49 | try {
50 | Log.d(TAG, "Initializing ADC Driver");
51 | mAdcDriver = new Ads1xxx(BoardDefaults.getI2CPort(), Ads1xxx.Configuration.ADS1015);
52 | // Increase default range to fit +3.3V
53 | mAdcDriver.setInputRange(Ads1xxx.RANGE_4_096V);
54 |
55 | // Set up I/O polling thread
56 | mReadThread = new HandlerThread("ADC Reader");
57 | mReadThread.start();
58 | mHandler = new Handler(mReadThread.getLooper());
59 | mHandler.post(mReadAction);
60 | } catch (IOException e) {
61 | Log.e(TAG, "Failed to initialize ADC driver", e);
62 | }
63 | }
64 |
65 | @Override
66 | protected void onDestroy() {
67 | super.onDestroy();
68 | mReadThread.quit();
69 |
70 | try {
71 | mAdcDriver.close();
72 | } catch (IOException e) {
73 | Log.e(TAG, "Failed to close ADC driver", e);
74 | } finally {
75 | mAdcDriver = null;
76 | }
77 | }
78 |
79 | /* Read a single analog sample and log the result */
80 | private Runnable mReadAction = new Runnable() {
81 | @Override
82 | public void run() {
83 | try {
84 | // Read differential between IN0+/IN1-
85 | final int value = mAdcDriver.readDifferentialInput(Ads1xxx.INPUT_DIFF_0P_1N);
86 | Log.i(TAG, "Current ADC value: " + value);
87 | } catch (IOException e) {
88 | Log.e(TAG, "Unable to read analog sample", e);
89 | }
90 |
91 | mHandler.postDelayed(this, DELAY_MS);
92 | }
93 | };
94 | }
95 |
--------------------------------------------------------------------------------
/pwmservo/src/main/java/com/example/androidthings/driversamples/ServoActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.app.Activity;
20 | import android.os.Bundle;
21 | import android.os.Handler;
22 | import android.util.Log;
23 |
24 | import com.google.android.things.contrib.driver.pwmservo.Servo;
25 |
26 | import java.io.IOException;
27 |
28 | public class ServoActivity extends Activity {
29 |
30 | private static final String TAG = "ServoActivity";
31 |
32 | private Servo mServo;
33 | private Handler mHandler;
34 |
35 | @Override
36 | protected void onCreate(Bundle savedInstanceState) {
37 | super.onCreate(savedInstanceState);
38 |
39 | try {
40 | mServo = new Servo(BoardDefaults.getPwmPin());
41 | mServo.setAngleRange(0f, 180f);
42 | mServo.setEnabled(true);
43 | } catch (IOException e) {
44 | Log.e(TAG, "Error creating Servo", e);
45 | return; // don't init handler
46 | }
47 |
48 | mHandler = new Handler();
49 | mHandler.post(mMoveServoRunnable);
50 | }
51 |
52 | @Override
53 | protected void onDestroy() {
54 | super.onDestroy();
55 |
56 | if (mHandler != null) {
57 | mHandler.removeCallbacks(mMoveServoRunnable);
58 | }
59 | if (mServo != null) {
60 | try {
61 | mServo.close();
62 | } catch (IOException e) {
63 | Log.e(TAG, "Error closing Servo");
64 | } finally {
65 | mServo = null;
66 | }
67 | }
68 | }
69 |
70 | private Runnable mMoveServoRunnable = new Runnable() {
71 |
72 | private static final float ANGLE_STEP = 30;
73 | private static final long DELAY_MS = 5000L; // 5 seconds
74 |
75 | private double mAngle = Float.NEGATIVE_INFINITY;
76 |
77 | @Override
78 | public void run() {
79 | if (mServo == null) {
80 | return;
81 | }
82 |
83 | try {
84 | if (mAngle < mServo.getMinimumAngle()) {
85 | mAngle = mServo.getMinimumAngle();
86 | } else {
87 | mAngle = mAngle + ANGLE_STEP;
88 | if (mAngle > mServo.getMaximumAngle()) {
89 | mAngle = mServo.getMinimumAngle();
90 | }
91 | }
92 | mServo.setAngle(mAngle);
93 |
94 | mHandler.postDelayed(this, DELAY_MS);
95 | } catch (IOException e) {
96 | Log.e(TAG, "Error setting Servo angle");
97 | }
98 | }
99 | };
100 | }
101 |
--------------------------------------------------------------------------------
/matrixkeypad/src/main/java/com/example/androidthings/driversamples/MatrixKeypadActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.app.Activity;
20 | import android.os.Bundle;
21 | import android.util.Log;
22 | import android.view.KeyEvent;
23 | import android.widget.EditText;
24 | import android.widget.TextView;
25 | import com.google.android.things.contrib.driver.matrixkeypad.MatrixKeypadInputDriver;
26 | import java.io.IOException;
27 |
28 | public class MatrixKeypadActivity extends Activity {
29 | private static final String TAG = MatrixKeypadActivity.class.getSimpleName();
30 | private static final boolean USE_LAYOUT = true;
31 |
32 | private MatrixKeypadInputDriver mMatrixKeypadDriver;
33 |
34 | @Override
35 | protected void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | if (USE_LAYOUT) {
38 | setContentView(R.layout.layout_main);
39 | }
40 | try {
41 | mMatrixKeypadDriver = new MatrixKeypadInputDriver(BoardDefaults.getRowPins(),
42 | BoardDefaults.getColPins(),
43 | new int[] {KeyEvent.KEYCODE_NUMPAD_1, KeyEvent.KEYCODE_NUMPAD_2,
44 | KeyEvent.KEYCODE_NUMPAD_3, KeyEvent.KEYCODE_NUMPAD_4,
45 | KeyEvent.KEYCODE_NUMPAD_5, KeyEvent.KEYCODE_NUMPAD_6,
46 | KeyEvent.KEYCODE_NUMPAD_7, KeyEvent.KEYCODE_NUMPAD_8,
47 | KeyEvent.KEYCODE_NUMPAD_9, KeyEvent.KEYCODE_NUMPAD_MULTIPLY,
48 | KeyEvent.KEYCODE_NUMPAD_0, KeyEvent.KEYCODE_NUMPAD_ENTER});
49 | mMatrixKeypadDriver.register();
50 | } catch (IOException e) {
51 | Log.e(TAG, "Cannot register matrix keypad driver:", e);
52 | }
53 | }
54 |
55 | @Override
56 | public boolean onKeyDown(int keyCode, KeyEvent event) {
57 | if (event.getAction() == KeyEvent.ACTION_DOWN) {
58 | Log.d(TAG, "Detect key down " + KeyEvent.keyCodeToString(keyCode) + " " + event
59 | .toString());
60 | return true;
61 | }
62 | return super.onKeyDown(keyCode, event);
63 | }
64 |
65 | @Override
66 | public boolean onKeyUp(int keyCode, KeyEvent event) {
67 | Log.d(TAG, "Detect key up " + KeyEvent.keyCodeToString(keyCode) + " " + event
68 | .toString());
69 | if (USE_LAYOUT && keyCode == KeyEvent.KEYCODE_ENTER) {
70 | // Update lines in sample
71 | ((TextView) findViewById(R.id.previousentry)).setText(
72 | ((EditText) findViewById(R.id.textentry)).getText().toString());
73 | return true;
74 | }
75 | return super.onKeyUp(keyCode, event);
76 | }
77 |
78 | @Override
79 | protected void onDestroy() {
80 | super.onDestroy();
81 | try {
82 | mMatrixKeypadDriver.close();
83 | } catch (IOException e) {
84 | Log.e(TAG, "Driver unable to close:", e);
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/pwmspeaker/src/main/java/com/example/androidthings/driversamples/SpeakerActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.app.Activity;
20 | import android.os.Bundle;
21 | import android.os.Handler;
22 | import android.os.HandlerThread;
23 | import android.util.Log;
24 |
25 | import com.google.android.things.contrib.driver.pwmspeaker.Speaker;
26 |
27 | import java.io.IOException;
28 |
29 | import static android.content.ContentValues.TAG;
30 |
31 | public class SpeakerActivity extends Activity {
32 |
33 | private static final long PLAYBACK_NOTE_DELAY = 80L;
34 |
35 | private Speaker mSpeaker;
36 | private HandlerThread mHandlerThread;
37 | private Handler mHandler;
38 |
39 | @Override
40 | protected void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 |
43 | try {
44 | mSpeaker = new Speaker(BoardDefaults.getPwmPin());
45 | mSpeaker.stop(); // in case the PWM pin was enabled already
46 | } catch (IOException e) {
47 | Log.e(TAG, "Error initializing speaker");
48 | return; // don't initilize the handler
49 | }
50 |
51 | mHandlerThread = new HandlerThread("pwm-playback");
52 | mHandlerThread.start();
53 | mHandler = new Handler(mHandlerThread.getLooper());
54 | mHandler.post(mPlaybackRunnable);
55 | }
56 |
57 | @Override
58 | protected void onDestroy() {
59 | super.onDestroy();
60 |
61 | if (mHandler != null) {
62 | mHandler.removeCallbacks(mPlaybackRunnable);
63 | mHandlerThread.quitSafely();
64 | }
65 | if (mSpeaker != null) {
66 | try {
67 | mSpeaker.stop();
68 | mSpeaker.close();
69 | } catch (IOException e) {
70 | Log.e(TAG, "Error closing speaker", e);
71 | } finally {
72 | mSpeaker = null;
73 | }
74 | }
75 | }
76 |
77 | private Runnable mPlaybackRunnable = new Runnable() {
78 |
79 | private int index = 0;
80 |
81 | @Override
82 | public void run() {
83 | if (mSpeaker == null) {
84 | return;
85 | }
86 |
87 | try {
88 | if (index == MusicNotes.DRAMATIC_THEME.length) {
89 | // reached the end
90 | mSpeaker.stop();
91 | } else {
92 | double note = MusicNotes.DRAMATIC_THEME[index++];
93 | if (note > 0) {
94 | mSpeaker.play(note);
95 | } else {
96 | mSpeaker.stop();
97 | }
98 | mHandler.postDelayed(this, PLAYBACK_NOTE_DELAY);
99 | }
100 | } catch (IOException e) {
101 | Log.e(TAG, "Error playing speaker", e);
102 | }
103 | }
104 | };
105 | }
106 |
--------------------------------------------------------------------------------
/mma7660fc/src/main/java/com/example/androidthings/driversamples/AccelerometerActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.app.Activity;
20 | import android.content.Context;
21 | import android.hardware.Sensor;
22 | import android.hardware.SensorEvent;
23 | import android.hardware.SensorEventListener;
24 | import android.hardware.SensorManager;
25 | import android.os.Bundle;
26 | import android.util.Log;
27 |
28 | import com.google.android.things.contrib.driver.mma7660fc.Mma7660FcAccelerometerDriver;
29 |
30 | import java.io.IOException;
31 |
32 | /**
33 | * AccelerometerActivity is a sample activity that use an Accelerometer driver to
34 | * read data from a Grove accelerator and log them.
35 | */
36 | public class AccelerometerActivity extends Activity implements SensorEventListener {
37 | private static final String TAG = AccelerometerActivity.class.getSimpleName();
38 |
39 | private Mma7660FcAccelerometerDriver mAccelerometerDriver;
40 | private SensorManager mSensorManager;
41 |
42 | @Override
43 | public void onCreate(Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 | Log.i(TAG, "Accelerometer demo created");
46 |
47 | mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
48 | mSensorManager.registerDynamicSensorCallback(new SensorManager.DynamicSensorCallback() {
49 | @Override
50 | public void onDynamicSensorConnected(Sensor sensor) {
51 | if (sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
52 | Log.i(TAG, "Accelerometer sensor connected");
53 | mSensorManager.registerListener(AccelerometerActivity.this, sensor,
54 | SensorManager.SENSOR_DELAY_NORMAL);
55 | }
56 | }
57 | });
58 | try {
59 | mAccelerometerDriver = new Mma7660FcAccelerometerDriver(BoardDefaults.getI2CPort());
60 | mAccelerometerDriver.register();
61 | Log.i(TAG, "Accelerometer driver registered");
62 | } catch (IOException e) {
63 | Log.e(TAG, "Error initializing accelerometer driver: ", e);
64 | }
65 | }
66 |
67 | @Override
68 | public void onDestroy() {
69 | super.onDestroy();
70 | if (mAccelerometerDriver != null) {
71 | mSensorManager.unregisterListener(this);
72 | mAccelerometerDriver.unregister();
73 | try {
74 | mAccelerometerDriver.close();
75 | } catch (IOException e) {
76 | Log.e(TAG, "Error closing accelerometer driver: ", e);
77 | } finally {
78 | mAccelerometerDriver = null;
79 | }
80 | }
81 | }
82 |
83 | @Override
84 | public void onSensorChanged(SensorEvent event) {
85 | Log.i(TAG, "Accelerometer event: " +
86 | event.values[0] + ", " + event.values[1] + ", " + event.values[2]);
87 | }
88 |
89 | @Override
90 | public void onAccuracyChanged(Sensor sensor, int accuracy) {
91 | Log.i(TAG, "Accelerometer accuracy changed: " + accuracy);
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/bmx280/src/main/java/com/example/androidthings/driversamples/TemperatureActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.app.Activity;
20 | import android.content.Context;
21 | import android.hardware.Sensor;
22 | import android.hardware.SensorEvent;
23 | import android.hardware.SensorEventListener;
24 | import android.hardware.SensorManager;
25 | import android.hardware.SensorManager.DynamicSensorCallback;
26 | import android.os.Bundle;
27 | import android.util.Log;
28 |
29 | import com.google.android.things.contrib.driver.bmx280.Bmx280SensorDriver;
30 |
31 | import java.io.IOException;
32 |
33 | /**
34 | * TemperatureActivity is an example that use the driver for the BMP280 temperature sensor.
35 | */
36 | public class TemperatureActivity extends Activity implements SensorEventListener {
37 | private static final String TAG = TemperatureActivity.class.getSimpleName();
38 |
39 | private Bmx280SensorDriver mTemperatureSensorDriver;
40 | private SensorManager mSensorManager;
41 |
42 | private DynamicSensorCallback mDynamicSensorCallback = new DynamicSensorCallback() {
43 | @Override
44 | public void onDynamicSensorConnected(Sensor sensor) {
45 | if (sensor.getType() == Sensor.TYPE_AMBIENT_TEMPERATURE) {
46 | Log.i(TAG, "Temperature sensor connected");
47 | mSensorManager.registerListener(TemperatureActivity.this,
48 | sensor, SensorManager.SENSOR_DELAY_NORMAL);
49 | }
50 | }
51 | };
52 |
53 | @Override
54 | protected void onCreate(Bundle savedInstanceState) {
55 | super.onCreate(savedInstanceState);
56 | Log.i(TAG, "Starting TemperatureActivity");
57 |
58 | mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
59 | mSensorManager.registerDynamicSensorCallback(mDynamicSensorCallback);
60 |
61 | try {
62 | mTemperatureSensorDriver = new Bmx280SensorDriver(BoardDefaults.getI2CPort());
63 | mTemperatureSensorDriver.registerTemperatureSensor();
64 | } catch (IOException e) {
65 | Log.e(TAG, "Error configuring sensor", e);
66 | }
67 | }
68 |
69 | @Override
70 | protected void onDestroy() {
71 | super.onDestroy();
72 | Log.i(TAG, "Closing sensor");
73 | if (mTemperatureSensorDriver != null) {
74 | mSensorManager.unregisterDynamicSensorCallback(mDynamicSensorCallback);
75 | mSensorManager.unregisterListener(this);
76 | mTemperatureSensorDriver.unregisterTemperatureSensor();
77 | try {
78 | mTemperatureSensorDriver.close();
79 | } catch (IOException e) {
80 | Log.e(TAG, "Error closing sensor", e);
81 | } finally {
82 | mTemperatureSensorDriver = null;
83 | }
84 | }
85 | }
86 |
87 | @Override
88 | public void onSensorChanged(SensorEvent event) {
89 | Log.i(TAG, "sensor changed: " + event.values[0]);
90 | }
91 |
92 | @Override
93 | public void onAccuracyChanged(Sensor sensor, int accuracy) {
94 | Log.i(TAG, "sensor accuracy changed: " + accuracy);
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/apa102/src/main/java/com/example/androidthings/driversamples/MainActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.app.Activity;
20 | import android.graphics.Color;
21 | import android.os.Bundle;
22 | import android.os.Handler;
23 | import android.os.HandlerThread;
24 | import android.util.Log;
25 |
26 | import com.google.android.things.contrib.driver.apa102.Apa102;
27 |
28 | import java.io.IOException;
29 |
30 | /**
31 | * Sample activity that demonstrates usage of the APA102 LED driver.
32 | */
33 | public class MainActivity extends Activity {
34 | private static final String TAG = MainActivity.class.getSimpleName();
35 |
36 | // LED configuration.
37 | private static final int NUM_LEDS = 7;
38 | private static final int LED_BRIGHTNESS = 5; // 0 ... 31
39 | private static final Apa102.Mode LED_MODE = Apa102.Mode.BGR;
40 |
41 | // Animation configuration.
42 | private static final int FRAME_DELAY_MS = 100; // 10fps
43 |
44 | private Apa102 mLedstrip;
45 | private int[] mLedColors;
46 | private int mFrame = 0;
47 | private Handler mHandler = new Handler();
48 | private HandlerThread mPioThread;
49 |
50 | @Override
51 | public void onCreate(Bundle savedInstanceState) {
52 | super.onCreate(savedInstanceState);
53 | Log.d(TAG, "APA102 MainActivity created");
54 |
55 | mPioThread = new HandlerThread("pioThread");
56 | mPioThread.start();
57 |
58 | mHandler = new Handler(mPioThread.getLooper());
59 |
60 | mLedColors = new int[NUM_LEDS];
61 | try {
62 | Log.d(TAG, "Initializing LED strip");
63 | mLedstrip = new Apa102(BoardDefaults.getSPIPort(), LED_MODE);
64 | mLedstrip.setBrightness(LED_BRIGHTNESS);
65 | mHandler.post(mAnimateRunnable);
66 | } catch (IOException e) {
67 | Log.e(TAG, "Error initializing LED strip", e);
68 | }
69 | }
70 |
71 | @Override
72 | public void onDestroy() {
73 | super.onDestroy();
74 | // Remove pending sensor Runnable from the handler.
75 | mHandler.removeCallbacks(mAnimateRunnable);
76 | mPioThread.quitSafely();
77 | Log.d(TAG, "Closing LED strip");
78 | try {
79 | mLedstrip.close();
80 | } catch (IOException e) {
81 | Log.e(TAG, "Exception closing LED strip", e);
82 | } finally {
83 | mLedstrip = null;
84 | }
85 | }
86 |
87 | private Runnable mAnimateRunnable = new Runnable() {
88 | final float[] hsv = {1f, 1f, 1f};
89 |
90 | @Override
91 | public void run() {
92 | try {
93 | for (int i = 0; i < mLedColors.length; i++) { // Assigns gradient colors.
94 | int n = (i + mFrame) % mLedColors.length;
95 | hsv[0] = n * 360.f / mLedColors.length;
96 | mLedColors[i] = Color.HSVToColor(0, hsv);
97 | }
98 | mLedstrip.write(mLedColors);
99 | mFrame = (mFrame + 1) % mLedColors.length;
100 | } catch (IOException e) {
101 | Log.e(TAG, "Error while writing to LED strip", e);
102 | }
103 | mHandler.postDelayed(mAnimateRunnable, FRAME_DELAY_MS);
104 | }
105 | };
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/cap1xxx/src/main/java/com/example/androidthings/driversamples/CaptouchActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.app.Activity;
20 | import android.os.Bundle;
21 | import android.util.Log;
22 | import android.view.KeyEvent;
23 |
24 | import com.google.android.things.contrib.driver.cap1xxx.Cap1xxx;
25 | import com.google.android.things.contrib.driver.cap1xxx.Cap1xxxInputDriver;
26 |
27 | import java.io.IOException;
28 |
29 | public class CaptouchActivity extends Activity {
30 | private static final String TAG = "CaptouchActivity";
31 |
32 | private Cap1xxxInputDriver mInputDriver;
33 |
34 | @Override
35 | protected void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | // Set input key codes
38 | int[] keyCodes = {
39 | KeyEvent.KEYCODE_1,
40 | KeyEvent.KEYCODE_2,
41 | KeyEvent.KEYCODE_3,
42 | KeyEvent.KEYCODE_4,
43 | KeyEvent.KEYCODE_5,
44 | KeyEvent.KEYCODE_6,
45 | KeyEvent.KEYCODE_7,
46 | KeyEvent.KEYCODE_8
47 | };
48 |
49 | try {
50 | mInputDriver = new Cap1xxxInputDriver(BoardDefaults.getI2CPort(), null,
51 | Cap1xxx.Configuration.CAP1208, keyCodes);
52 |
53 | // Disable repeated events
54 | mInputDriver.setRepeatRate(Cap1xxx.REPEAT_DISABLE);
55 | // Block touches above 4 unique inputs
56 | mInputDriver.setMultitouchInputMax(4);
57 |
58 | mInputDriver.register();
59 |
60 | } catch (IOException e) {
61 | Log.w(TAG, "Unable to open driver connection", e);
62 | }
63 | }
64 |
65 | @Override
66 | protected void onDestroy() {
67 | super.onDestroy();
68 |
69 | if (mInputDriver != null) {
70 | mInputDriver.unregister();
71 |
72 | try {
73 | mInputDriver.close();
74 | } catch (IOException e) {
75 | Log.w(TAG, "Unable to close touch driver", e);
76 | }
77 | }
78 | }
79 |
80 | @Override
81 | public boolean onKeyDown(int keyCode, KeyEvent event) {
82 | return handleKeyEvent(keyCode, true) || super.onKeyDown(keyCode, event);
83 | }
84 |
85 | @Override
86 | public boolean onKeyUp(int keyCode, KeyEvent event) {
87 | return handleKeyEvent(keyCode, false) || super.onKeyUp(keyCode, event);
88 | }
89 |
90 | /**
91 | * Handle key events from captouch inputs
92 | */
93 | private boolean handleKeyEvent(int keyCode, boolean pressed) {
94 | String event = pressed ? "pressed" : "released";
95 | switch (keyCode) {
96 | case KeyEvent.KEYCODE_1:
97 | case KeyEvent.KEYCODE_2:
98 | case KeyEvent.KEYCODE_3:
99 | case KeyEvent.KEYCODE_4:
100 | case KeyEvent.KEYCODE_5:
101 | case KeyEvent.KEYCODE_6:
102 | case KeyEvent.KEYCODE_7:
103 | case KeyEvent.KEYCODE_8:
104 | Log.d(TAG, String.format("Captouch key %s: %d", event, keyCode));
105 | return true;
106 | default:
107 | Log.d(TAG, String.format("Unknown key %s: %d", event, keyCode));
108 | return false;
109 | }
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/gps/src/main/java/com/example/androidthings/driversamples/GpsActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.Manifest;
20 | import android.app.Activity;
21 | import android.content.pm.PackageManager;
22 | import android.location.GnssStatus;
23 | import android.location.Location;
24 | import android.location.LocationListener;
25 | import android.location.LocationManager;
26 | import android.location.OnNmeaMessageListener;
27 | import android.os.Bundle;
28 | import android.util.Log;
29 |
30 | import com.google.android.things.contrib.driver.gps.NmeaGpsDriver;
31 |
32 | import java.io.IOException;
33 |
34 | public class GpsActivity extends Activity {
35 | private static final String TAG = "GpsActivity";
36 |
37 | public static final int UART_BAUD = 9600;
38 | public static final float ACCURACY = 2.5f; // From GPS datasheet
39 |
40 | private LocationManager mLocationManager;
41 | private NmeaGpsDriver mGpsDriver;
42 |
43 | @Override
44 | protected void onCreate(Bundle savedInstanceState) {
45 | super.onCreate(savedInstanceState);
46 |
47 | mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
48 |
49 | // We need permission to get location updates
50 | if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION)
51 | != PackageManager.PERMISSION_GRANTED) {
52 | // A problem occurred auto-granting the permission
53 | Log.d(TAG, "No permission");
54 | return;
55 | }
56 |
57 | try {
58 | // Register the GPS driver
59 | mGpsDriver = new NmeaGpsDriver(this, BoardDefaults.getUartName(),
60 | UART_BAUD, ACCURACY);
61 | mGpsDriver.register();
62 | // Register for location updates
63 | mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
64 | 0, 0, mLocationListener);
65 | mLocationManager.registerGnssStatusCallback(mStatusCallback);
66 | mLocationManager.addNmeaListener(mMessageListener);
67 | } catch (IOException e) {
68 | Log.w(TAG, "Unable to open GPS UART", e);
69 | }
70 | }
71 |
72 | @Override
73 | protected void onDestroy() {
74 | super.onDestroy();
75 |
76 | // Verify permission was granted
77 | if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION)
78 | != PackageManager.PERMISSION_GRANTED) {
79 | Log.d(TAG, "No permission");
80 | return;
81 | }
82 |
83 | if (mGpsDriver != null) {
84 | // Unregister components
85 | mGpsDriver.unregister();
86 | mLocationManager.removeUpdates(mLocationListener);
87 | mLocationManager.unregisterGnssStatusCallback(mStatusCallback);
88 | mLocationManager.removeNmeaListener(mMessageListener);
89 | try {
90 | mGpsDriver.close();
91 | } catch (IOException e) {
92 | Log.w(TAG, "Unable to close GPS driver", e);
93 | }
94 | }
95 | }
96 |
97 | /** Report location updates */
98 | private LocationListener mLocationListener = new LocationListener() {
99 | @Override
100 | public void onLocationChanged(Location location) {
101 | Log.v(TAG, "Location update: " + location);
102 | }
103 |
104 | @Override
105 | public void onStatusChanged(String provider, int status, Bundle extras) { }
106 |
107 | @Override
108 | public void onProviderEnabled(String provider) { }
109 |
110 | @Override
111 | public void onProviderDisabled(String provider) { }
112 | };
113 |
114 | /** Report satellite status */
115 | private GnssStatus.Callback mStatusCallback = new GnssStatus.Callback() {
116 | @Override
117 | public void onStarted() { }
118 |
119 | @Override
120 | public void onStopped() { }
121 |
122 | @Override
123 | public void onFirstFix(int ttffMillis) { }
124 |
125 | @Override
126 | public void onSatelliteStatusChanged(GnssStatus status) {
127 | Log.v(TAG, "GNSS Status: " + status.getSatelliteCount() + " satellites.");
128 | }
129 | };
130 |
131 | /** Report raw NMEA messages */
132 | private OnNmeaMessageListener mMessageListener = new OnNmeaMessageListener() {
133 | @Override
134 | public void onNmeaMessage(String message, long timestamp) {
135 | Log.v(TAG, "NMEA: " + message);
136 | }
137 | };
138 | }
139 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/ssd1306/src/main/java/com/example/androidthings/driversamples/OledScreenActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.androidthings.driversamples;
18 |
19 | import android.app.Activity;
20 | import android.graphics.Bitmap;
21 | import android.graphics.BitmapFactory;
22 | import android.os.Bundle;
23 | import android.os.Handler;
24 | import android.util.Log;
25 |
26 | import com.google.android.things.contrib.driver.ssd1306.BitmapHelper;
27 | import com.google.android.things.contrib.driver.ssd1306.Ssd1306;
28 |
29 | import java.io.IOException;
30 |
31 | /**
32 | * Activity that tests the Ssd1306 display.
33 | */
34 | public class OledScreenActivity extends Activity {
35 | private static final String TAG = "OledScreenActivity";
36 | private static final int FPS = 30; // Frames per second on draw thread
37 | private static final int BITMAP_FRAMES_PER_MOVE = 4; // Frames to show bitmap before moving it
38 |
39 | private boolean mExpandingPixels = true;
40 | private int mDotMod = 1;
41 | private int mBitmapMod = 0;
42 | private int mTick = 0;
43 | private Modes mMode = Modes.BITMAP;
44 | private Ssd1306 mScreen;
45 |
46 | private Handler mHandler = new Handler();
47 | private Bitmap mBitmap;
48 |
49 | enum Modes {
50 | CROSSHAIRS,
51 | DOTS,
52 | BITMAP
53 | }
54 |
55 | @Override
56 | protected void onCreate(Bundle savedInstanceState) {
57 | super.onCreate(savedInstanceState);
58 | try {
59 | mScreen = new Ssd1306(BoardDefaults.getI2CPort(), Ssd1306.I2C_ADDRESS_SA0_HIGH);
60 | } catch (IOException e) {
61 | Log.e(TAG, "Error while opening screen", e);
62 | throw new RuntimeException(e);
63 | }
64 | Log.d(TAG, "OLED screen activity created");
65 | mHandler.post(mDrawRunnable);
66 | }
67 |
68 | @Override
69 | public void onDestroy() {
70 | super.onDestroy();
71 | // remove pending runnable from the handler
72 | mHandler.removeCallbacks(mDrawRunnable);
73 | // Close the device.
74 | try {
75 | mScreen.close();
76 | } catch (IOException e) {
77 | Log.e(TAG, "Error closing SSD1306", e);
78 | } finally {
79 | mScreen = null;
80 | }
81 | }
82 |
83 | /**
84 | * Draws crosshair pattern.
85 | */
86 | private void drawCrosshairs() {
87 | mScreen.clearPixels();
88 | int y = mTick % mScreen.getLcdHeight();
89 | for (int x = 0; x < mScreen.getLcdWidth(); x++) {
90 | mScreen.setPixel(x, y, true);
91 | mScreen.setPixel(x, mScreen.getLcdHeight() - (y + 1), true);
92 | }
93 | int x = mTick % mScreen.getLcdWidth();
94 | for (y = 0; y < mScreen.getLcdHeight(); y++) {
95 | mScreen.setPixel(x, y, true);
96 | mScreen.setPixel(mScreen.getLcdWidth() - (x + 1), y, true);
97 | }
98 | }
99 |
100 | /**
101 | * Draws expanding and contracting pixels.
102 | */
103 | private void drawExpandingDots() {
104 | if (mExpandingPixels) {
105 | for (int x = 0; x < mScreen.getLcdWidth(); x++) {
106 | for (int y = 0; y < mScreen.getLcdHeight() && mMode == Modes.DOTS; y++) {
107 | mScreen.setPixel(x, y, (x % mDotMod) == 1 && (y % mDotMod) == 1);
108 | }
109 | }
110 | mDotMod++;
111 | if (mDotMod > mScreen.getLcdHeight()) {
112 | mExpandingPixels = false;
113 | mDotMod = mScreen.getLcdHeight();
114 | }
115 | } else {
116 | for (int x = 0; x < mScreen.getLcdWidth(); x++) {
117 | for (int y = 0; y < mScreen.getLcdHeight() && mMode == Modes.DOTS; y++) {
118 | mScreen.setPixel(x, y, (x % mDotMod) == 1 && (y % mDotMod) == 1);
119 | }
120 | }
121 | mDotMod--;
122 | if (mDotMod < 1) {
123 | mExpandingPixels = true;
124 | mDotMod = 1;
125 | }
126 | }
127 | }
128 |
129 | /**
130 | * Draws a BMP in one of three positions.
131 | */
132 | private void drawMovingBitmap() {
133 | if (mBitmap == null) {
134 | mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.flower);
135 | }
136 | // Move the bmp every few ticks
137 | if (mTick % BITMAP_FRAMES_PER_MOVE == 0) {
138 | mScreen.clearPixels();
139 | // Move the bitmap back and forth based on mBitmapMod:
140 | // 0 - left aligned
141 | // 1 - centered
142 | // 2 - right aligned
143 | // 3 - centered
144 | int diff = mScreen.getLcdWidth() - mBitmap.getWidth();
145 | int mult = mBitmapMod == 3 ? 1 : mBitmapMod; // 0, 1, or 2
146 | int offset = mult * (diff / 2);
147 | BitmapHelper.setBmpData(mScreen, offset, 0, mBitmap, false);
148 | mBitmapMod = (mBitmapMod + 1) % 4;
149 | }
150 | }
151 |
152 | private Runnable mDrawRunnable = new Runnable() {
153 | /**
154 | * Updates the display and tick counter.
155 | */
156 | @Override
157 | public void run() {
158 | // exit Runnable if the device is already closed
159 | if (mScreen == null) {
160 | return;
161 | }
162 | mTick++;
163 | try {
164 | switch (mMode) {
165 | case DOTS:
166 | drawExpandingDots();
167 | break;
168 | case BITMAP:
169 | drawMovingBitmap();
170 | break;
171 | default:
172 | drawCrosshairs();
173 | break;
174 | }
175 | mScreen.show();
176 | mHandler.postDelayed(this, 1000 / FPS);
177 | } catch (IOException e) {
178 | Log.e(TAG, "Exception during screen update", e);
179 | }
180 | }
181 | };
182 | }
183 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2014 The Android Open Source Project
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------