Skip to content
This repository has been archived by the owner on Nov 13, 2021. It is now read-only.

Commit

Permalink
Added sample project for SH1106.
Browse files Browse the repository at this point in the history
  • Loading branch information
leinardi committed Dec 18, 2017
1 parent 5c9f8bf commit 5234fd0
Show file tree
Hide file tree
Showing 13 changed files with 440 additions and 3 deletions.
2 changes: 1 addition & 1 deletion driver-sh1106/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ android {
apply from: 'mavenConfig.gradle'

defaultConfig {
minSdkVersion 24
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
versionCode build_versions.version_code
versionName mvn_config.version as String
Expand Down
1 change: 1 addition & 0 deletions sample-sh1106/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
49 changes: 49 additions & 0 deletions sample-sh1106/README.md
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.
54 changes: 54 additions & 0 deletions sample-sh1106/build.gradle
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'

}
21 changes: 21 additions & 0 deletions sample-sh1106/proguard-rules.pro
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
44 changes: 44 additions & 0 deletions sample-sh1106/src/main/AndroidManifest.xml
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>
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);
}
}
}
Loading

0 comments on commit 5234fd0

Please sign in to comment.