Skip to content

Commit

Permalink
E-Paper Driver HAT: Added sample project
Browse files Browse the repository at this point in the history
  • Loading branch information
leinardi committed Jan 20, 2018
1 parent 069e430 commit 76caad6
Show file tree
Hide file tree
Showing 9 changed files with 234 additions and 11 deletions.
1 change: 1 addition & 0 deletions sample-epaperdriverhat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
17 changes: 6 additions & 11 deletions sample-epaperdriverhat/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
## OLED Screen sample for Android Things
## E-Paper Driver HAT sample for Android Things

This sample demonstrates how to control the EPAPERDRIVERHAT OLED display using I2C with
This sample demonstrates how to control the GDEW075T8 E-Paper display using E-Paper Driver HAT with
Android Things.

## Pre-requisites

- Android Things compatible board
- Android Studio 2.2+
- 1 [EPAPERDRIVERHAT OLED screen](https://www.elecrow.com/download/EPAPERDRIVERHAT%20datasheet.pdf)
- jumper wires
- 1 breadboard
- 1 [GDEW075T8 + E-Paper Driver HAT](https://www.waveshare.com/wiki/7.5inch_e-Paper_HAT)


# Build and install
Expand All @@ -19,14 +17,11 @@ 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-epd:installDebug
adb shell am start com.leinardi.android.things.sample.epd/.OledScreenActivity
./gradlew sample-epaperdriverhat:installDebug
adb shell am start com.leinardi.android.things.sample.epaperdriverhat/.EpdScreenActivity
```

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.
If you have everything set up correctly, you will see an image on the screen.


## License
Expand Down
54 changes: 54 additions & 0 deletions sample-epaperdriverhat/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2018 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.android.things.sample.epaperdriverhat"
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 project(':driver-epaperdriverhat')

}
21 changes: 21 additions & 0 deletions sample-epaperdriverhat/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
47 changes: 47 additions & 0 deletions sample-epaperdriverhat/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2018 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.android.things.sample.epd"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application
android:allowBackup="true"
android:icon="@android:drawable/sym_def_app_icon"
android:label="@string/app_name"
android:theme="@style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">

<uses-library android:name="com.google.android.things" />

<activity android:name="com.leinardi.android.things.sample.epaperdriverhat.EpdScreenActivity">
<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,64 @@
/*
* Copyright 2018 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.android.things.sample.epaperdriverhat;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;

import com.leinardi.android.things.driver.epaperdriverhat.BitmapHelper;
import com.leinardi.android.things.driver.epaperdriverhat.Gdew075t8Epd;
import com.leinardi.android.things.sample.epd.R;

import java.io.IOException;

/**
* Activity that tests the EPD.
*/
public class EpdScreenActivity extends Activity {
private static final String TAG = EpdScreenActivity.class.getSimpleName();
Gdew075t8Epd mEpd;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "EPD screen activity created");
try {
mEpd = new Gdew075t8Epd();
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.monocolor_640x384);
BitmapHelper.setBmpData(mEpd, 0, 0, bitmap, false);
mEpd.show(); // render the pixel data
} catch (IOException e) {
Log.e(TAG, "Error initializing EPD", e);
}
}

@Override
public void onDestroy() {
super.onDestroy();
Log.d(TAG, "Closing EPD");
try {
mEpd.close();
} catch (IOException e) {
Log.e(TAG, "Exception closing EPD", e);
} finally {
mEpd = null;
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions sample-epaperdriverhat/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!--
~ Copyright 2018 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.
-->

<resources>
<string name="app_name">Sample E-Paper Driver HAT</string>
</resources>
22 changes: 22 additions & 0 deletions sample-epaperdriverhat/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
~ Copyright 2018 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.
-->

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar" />

</resources>

0 comments on commit 76caad6

Please sign in to comment.