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

E-Paper Driver HAT #8

Merged
merged 7 commits into from
Jan 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ dependencies {
<!-- DRIVER_LIST_START -->
Driver | Type | Usage (add to your gradle dependencies) | Note
:---:|:---:| --- | ---
[driver-ds3231](driver-ds3231) | real-time clock (RTC) | `implementation 'com.leinardi.android.things:driver-ds3231:0.1'` | [![Maven metadata URI](https://img.shields.io/maven-metadata/v/http/jcenter.bintray.com/com/leinardi/android/things/driver-ds3231/maven-metadata.xml.svg)](https://jcenter.bintray.com/com/leinardi/android/things/driver-ds3231/maven-metadata.xml) [changelog](driver-ds3231/CHANGELOG.md) [sample](sample-ds3231)
[driver-ds3231-receiver](driver-ds3231-receiver) | automatic persist on reboot/poweroff the system wall clock time | `implementation 'com.leinardi.android.things:driver-ds3231-receiver:0.1'` | [![Maven metadata URI](https://img.shields.io/maven-metadata/v/http/jcenter.bintray.com/com/leinardi/android/things/driver-ds3231-receiver/maven-metadata.xml.svg)](https://jcenter.bintray.com/com/leinardi/android/things/driver-ds3231-receiver/maven-metadata.xml) [changelog](driver-ds3231-receiver/CHANGELOG.md)
[driver-ds3231](driver-ds3231) | real-time clock (RTC) | `implementation 'com.leinardi.android.things:driver-ds3231:0.1'` | [![Maven metadata URI](https://img.shields.io/maven-metadata/v/http/jcenter.bintray.com/com/leinardi/android/things/driver-ds3231/maven-metadata.xml.svg)](https://jcenter.bintray.com/com/leinardi/android/things/driver-ds3231/maven-metadata.xml) [changelog](driver-ds3231/CHANGELOG.md) [sample](sample-ds3231) [driver-ds3231-receiver](driver-ds3231-receiver)
[driver-epaperdriverhat](driver-epaperdriverhat) | E-Paper Driver HAT | `implementation 'com.leinardi.android.things:driver-epaperdriverhat:0.1'` | [![Maven metadata URI](https://img.shields.io/maven-metadata/v/http/jcenter.bintray.com/com/leinardi/android/things/driver-epaperdriverhat/maven-metadata.xml.svg)](https://jcenter.bintray.com/com/leinardi/android/things/driver-epaperdriverhat/maven-metadata.xml) [changelog](driver-epaperdriverhat/CHANGELOG.md) [sample](sample-epaperdriverhat)
[driver-hcsr04](driver-hcsr04) | ultrasonic ranging module | `implementation 'com.leinardi.android.things:driver-hcsr04:0.1'` | [![Maven metadata URI](https://img.shields.io/maven-metadata/v/http/jcenter.bintray.com/com/leinardi/android/things/driver-hcsr04/maven-metadata.xml.svg)](https://jcenter.bintray.com/com/leinardi/android/things/driver-hcsr04/maven-metadata.xml) [changelog](driver-hcsr04/CHANGELOG.md) [sample](sample-hcsr04)
[driver-hd44780](driver-hd44780) | alphanumeric dot matrix LCD | `implementation 'com.leinardi.android.things:driver-hd44780:0.2'` | [![Maven metadata URI](https://img.shields.io/maven-metadata/v/http/jcenter.bintray.com/com/leinardi/android/things/driver-hd44780/maven-metadata.xml.svg)](https://jcenter.bintray.com/com/leinardi/android/things/driver-hd44780/maven-metadata.xml) [changelog](driver-hd44780/CHANGELOG.md) [sample](sample-hd44780)
[driver-lsm9ds1](driver-lsm9ds1) | 3D accelerometer, 3D gyroscope, 3D magnetometer and temperature sensor | `implementation 'com.leinardi.android.things:driver-lsm9ds1:0.3'` | [![Maven metadata URI](https://img.shields.io/maven-metadata/v/http/jcenter.bintray.com/com/leinardi/android/things/driver-lsm9ds1/maven-metadata.xml.svg)](https://jcenter.bintray.com/com/leinardi/android/things/driver-lsm9ds1/maven-metadata.xml) [changelog](driver-lsm9ds1/CHANGELOG.md) [sample](sample-lsm9ds1)
Expand Down
2 changes: 2 additions & 0 deletions bintray.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ bintray {
licenses = mvn_config.licenses.split(',')
websiteUrl = mvn_config.website
issueTrackerUrl = mvn_config.issue_tracker_url
githubRepo = mvn_config.githubRepo
// githubReleaseNotesFile = mvn_config.githubReleaseNotesFile
vcsUrl = mvn_config.vcs_url
labels = mvn_config.tags.split(',')
version {
Expand Down
1 change: 1 addition & 0 deletions driver-ds3231-receiver/mavenConfig.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ mvn_config.issue_tracker_url = 'https://github.com/leinardi/androidthings-driver
mvn_config.vcs_url = 'https://github.com/leinardi/androidthings-drivers.git'
mvn_config.description = 'DS3231 boot completed and time set receiver for Android Things'
mvn_config.tags = 'ds3231,android-things,android,raspberry-pi' // Comma separated
mvn_config.githubRepo = 'leinardi/androidthings-drivers'
mvn_config.inception_year = '2018'
mvn_config.dryRun = false
mvn_config.publish = false
Expand Down
1 change: 1 addition & 0 deletions driver-ds3231/mavenConfig.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ mvn_config.issue_tracker_url = 'https://github.com/leinardi/androidthings-driver
mvn_config.vcs_url = 'https://github.com/leinardi/androidthings-drivers.git'
mvn_config.description = 'DS3231 driver for Android Things'
mvn_config.tags = 'ds3231,android-things,android,raspberry-pi' // Comma separated
mvn_config.githubRepo = 'leinardi/androidthings-drivers'
mvn_config.inception_year = '2018'
mvn_config.dryRun = false
mvn_config.publish = false
Expand Down
1 change: 1 addition & 0 deletions driver-epaperdriverhat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
5 changes: 5 additions & 0 deletions driver-epaperdriverhat/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Change Log

## [0.1] - 2018-01-19
- initial version

95 changes: 95 additions & 0 deletions driver-epaperdriverhat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# E-Paper Driver HAT display driver for Android Things

[![Maven metadata URI](https://img.shields.io/maven-metadata/v/http/jcenter.bintray.com/com/leinardi/android/things/driver-epaperdriverhat/maven-metadata.xml.svg?style=plastic)](https://jcenter.bintray.com/com/leinardi/android/things/driver-epaperdriverhat/maven-metadata.xml)
[![Build Status](https://img.shields.io/travis/leinardi/androidthings-drivers/master.svg?style=plastic)](https://travis-ci.org/leinardi/androidthings-drivers)
[![GitHub license](https://img.shields.io/github/license/leinardi/androidthings-drivers.svg?style=plastic)](https://github.com/leinardi/androidthings-drivers/blob/master/LICENSE)

This driver supports E-Paper screen peripherals connected with an E-Paper Driver HAT.

## Supported displays

<!-- DISPLAY_LIST_START -->
Part Number | Class | Size | Color | Resolution | Interface
:---:|:---:| --- | --- | --- | ---
[GDEW075T8](https://www.waveshare.com/wiki/7.5inch_e-Paper_HAT) | `Gdew075t8Epd` | 7.5" | Black, White | 640x384 | SPI
<!-- DISPLAY_LIST_END -->

NOTE: these drivers are not production-ready. They are offered as sample
implementations of Android Things user space drivers for common peripherals
as part of the Developer Preview release. There is no guarantee
of correctness, completeness or robustness.

This driver is based on the [GxEPD driver from ZinggJM](https://github.com/ZinggJM/GxEPD)

## How to use the driver

### Gradle dependency

To use the `epaperdriverhat` driver, simply add the line below to your project's `build.gradle`,
where `<version>` matches the last version of the driver available on [jcenter][jcenter].

```
dependencies {
implementation 'com.leinardi.android.things:driver-epaperdriverhat:<version>'
}
```

### Sample usage

```java
public class EpdScreenActivity extends Activity {
private static final String TAG = EpdScreenActivity.class.getSimpleName();
Gdew075t8Epd mEpd;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
mEpd = new Gdew075t8Epd();
// Show checkerboard
for (int i = 0; i < mEpd.getDisplayWidth(); i++) {
for (int j = 0; j < mEpd.getDisplayHeight(); j++) {
mEpd.setPixel(i, j, (i % 2) == (j % 2));
}
}
mEpd.show();
} catch (IOException e) {
Log.e(TAG, "Error initializing EPD", e);
}
}

@Override
public void onDestroy() {
super.onDestroy();
try {
mEpd.close();
} catch (IOException e) {
Log.e(TAG, "Exception closing EPD", e);
} finally {
mEpd = null;
}
}
}

```

## License

Copyright 2018 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.

[jcenter]: https://bintray.com/leinardi/androidthings/driver-epaperdriverhat/_latestVersion
51 changes: 51 additions & 0 deletions driver-epaperdriverhat/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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.library'
apply from: rootProject.file('checkstyle.gradle')

android {
compileSdkVersion build_versions.target_sdk
buildToolsVersion build_versions.build_tools

apply from: 'mavenConfig.gradle'

defaultConfig {
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
versionCode build_versions.version_code
versionName mvn_config.version as String
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 {
compileOnly deps.androidthings
implementation deps.support.annotations
}
Binary file added driver-epaperdriverhat/docs/GDEW075T8.pdf
Binary file not shown.
37 changes: 37 additions & 0 deletions driver-epaperdriverhat/mavenConfig.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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.
*/

def mvn_config = [:]
mvn_config.repository = 'androidthings'
mvn_config.group_id = 'com.leinardi.android.things'
mvn_config.artifact_id = 'driver-epaperdriverhat'
mvn_config.version = '0.1'
mvn_config.licenses = 'Apache-2.0' // Comma separated
mvn_config.website = 'https://github.com/leinardi/androidthings-drivers'
mvn_config.issue_tracker_url = 'https://github.com/leinardi/androidthings-drivers/issues'
mvn_config.vcs_url = 'https://github.com/leinardi/androidthings-drivers.git'
mvn_config.description = 'E-Paper Driver HAT driver for Android Things'
mvn_config.tags = 'epaperdriverhat,gdew075t8,android-things,android,raspberry-pi' // Comma separated
mvn_config.githubRepo = 'leinardi/androidthings-drivers'
mvn_config.inception_year = '2018'
mvn_config.dryRun = false
mvn_config.publish = false
mvn_config.override = true

ext.mvn_config = mvn_config

apply from: rootProject.file('maven.gradle')
apply from: rootProject.file('bintray.gradle')
21 changes: 21 additions & 0 deletions driver-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
25 changes: 25 additions & 0 deletions driver-epaperdriverhat/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
~ 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.driver.epd"
xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<uses-library
android:name="com.google.android.things"
android:required="false" />
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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.driver.epaperdriverhat;

import android.graphics.Bitmap;

public class BitmapHelper {
private static final int GRADIENT_CUTOFF = 85; // Tune for gradient picker on grayscale images.

private BitmapHelper() {
}

/**
* Converts a bitmap image to LCD screen data and sets it on the given screen at the specified
* offset.
*
* @param mScreen The e-paper screen to write the bitmap data to.
* @param xOffset The horizontal offset to draw the image at.
* @param yOffset The vertical offset to draw the image at.
* @param bmp The bitmap image that you want to convert to screen data.
* @param drawWhite true for drawing only white pixels, false for drawing grayscale pixel
* based on {@link #GRADIENT_CUTOFF}.
*/
public static void setBmpData(Epd mScreen, int xOffset, int yOffset, Bitmap bmp, boolean drawWhite) {
int width = bmp.getWidth();
int height = bmp.getHeight();

for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int pixel = bmp.getPixel(x, y);
if (!drawWhite) { // Look at Alpha channel instead
if ((pixel & 0xFF) <= GRADIENT_CUTOFF) {
mScreen.setPixel(x + xOffset, y + yOffset, true);
} else {
mScreen.setPixel(x + xOffset, y + yOffset, false);
}
} else {
if (pixel == -1) { // Only draw white pixels
mScreen.setPixel(x + xOffset, y + yOffset, true);
} else {
mScreen.setPixel(x + xOffset, y + yOffset, false);
}
}
}
}
}
}
Loading