This repository has been archived by the owner on Nov 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
440 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
## OLED Screen sample for Android Things | ||
|
||
This sample demonstrates how to control the SH1106 OLED display using I2C with | ||
Android Things. | ||
|
||
## Pre-requisites | ||
|
||
- Android Things compatible board | ||
- Android Studio 2.2+ | ||
- 1 [SH1106 OLED screen](https://www.elecrow.com/download/SH1106%20datasheet.pdf) | ||
- jumper wires | ||
- 1 breadboard | ||
|
||
|
||
# Build and install | ||
|
||
On Android Studio, click on the "Run" button. | ||
|
||
If you prefer to run on the command line, from this repository's root directory, type | ||
|
||
```bash | ||
./gradlew sample-sh1106:installDebug | ||
adb shell am start com.leinardi.androidthings.sh1106.sample/.OledScreenActivity | ||
``` | ||
|
||
If you have everything set up correctly, you will see a small bitmap slowly | ||
moving in the screen. If you want to change the pattern displayed, change the | ||
variable mMode in OledScreenActivity and deploy again. The sample has three | ||
modes: DOTS, BITMAP (default) and CROSSHAIRS. | ||
|
||
|
||
## License | ||
|
||
Copyright 2017 Roberto Leinardi. | ||
|
||
Licensed to the Apache Software Foundation (ASF) under one or more contributor | ||
license agreements. See the NOTICE file distributed with this work for | ||
additional information regarding copyright ownership. The ASF licenses this | ||
file to you under the Apache License, Version 2.0 (the "License"); you may not | ||
use this file except in compliance with the License. You may obtain a copy of | ||
the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
License for the specific language governing permissions and limitations under | ||
the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2017 Roberto Leinardi. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
apply plugin: 'com.android.application' | ||
apply from: rootProject.file('checkstyle.gradle') | ||
|
||
android { | ||
compileSdkVersion build_versions.target_sdk | ||
buildToolsVersion build_versions.build_tools | ||
|
||
defaultConfig { | ||
applicationId "com.leinardi.androidthings.sh1106.sample" | ||
minSdkVersion build_versions.min_sdk | ||
targetSdkVersion build_versions.target_sdk | ||
versionCode build_versions.version_code | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
|
||
} | ||
|
||
compileOptions { | ||
sourceCompatibility build_versions.java_version | ||
targetCompatibility build_versions.java_version | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
compileOnly deps.androidthings | ||
implementation deps.support.annotations | ||
implementation 'com.leinardi.androidthings:driver-sh1106:0.1' | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
~ Copyright 2017 Roberto Leinardi. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<manifest package="com.leinardi.androidthings.sh1106.sample" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@android:drawable/sym_def_app_icon" | ||
android:label="@string/app_name"> | ||
|
||
<uses-library android:name="com.google.android.things" /> | ||
|
||
<activity android:name=".OledScreenActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
|
||
<!-- Launch activity automatically on boot --> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.IOT_LAUNCHER" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
45 changes: 45 additions & 0 deletions
45
sample-sh1106/src/main/java/com/leinardi/androidthings/sh1106/sample/BoardDefaults.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2017 Roberto Leinardi. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.leinardi.androidthings.sh1106.sample; | ||
|
||
import android.os.Build; | ||
|
||
@SuppressWarnings("WeakerAccess") | ||
public class BoardDefaults { | ||
private static final String DEVICE_RPI3 = "rpi3"; | ||
private static final String DEVICE_IMX6UL_PICO = "imx6ul_pico"; | ||
private static final String DEVICE_IMX7D_PICO = "imx7d_pico"; | ||
|
||
private BoardDefaults() { | ||
} | ||
|
||
/** | ||
* Return the preferred I2C port for each board. | ||
*/ | ||
public static String getI2CPort() { | ||
switch (Build.DEVICE) { | ||
case DEVICE_RPI3: | ||
return "I2C1"; | ||
case DEVICE_IMX6UL_PICO: | ||
return "I2C2"; | ||
case DEVICE_IMX7D_PICO: | ||
return "I2C1"; | ||
default: | ||
throw new IllegalStateException("Unknown Build.DEVICE " + Build.DEVICE); | ||
} | ||
} | ||
} |
Oops, something went wrong.