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

Commit

Permalink
Merge pull request #1 from leinardi/pcf8574-hd44780
Browse files Browse the repository at this point in the history
Added pcf8574-hd44780 driver
  • Loading branch information
leinardi authored Dec 19, 2017
2 parents 7d5787d + e67a95d commit 3f2b27d
Show file tree
Hide file tree
Showing 23 changed files with 1,226 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ dependencies {
<!-- DRIVER_LIST_START -->
Driver | Type | Usage (add to your gradle dependencies) | Note
:---:|:---:| --- | ---
[driver-sh1106](driver-sh1106) | OLED display | `implementation 'com.leinardi.androidthings:driver-sh1106:0.1'` | [![Bintray](https://img.shields.io/bintray/v/leinardi/androidthings/driver-sh1106.svg)](https://bintray.com/leinardi/androidthings/driver-sh1106) [changelog](driver-sh1106/CHANGELOG.md)
[driver-pcf8574-hd44780](driver-pcf8574-hd44780) | LCD | `implementation 'com.leinardi.androidthings:driver-pcf8574-hd44780:0.1'` | [![Bintray](https://img.shields.io/bintray/v/leinardi/androidthings/driver-pcf8574-hd44780.svg)](https://bintray.com/leinardi/androidthings/driver-pcf8574-hd44780) [changelog](driver-pcf8574-hd44780/CHANGELOG.md) [sample](sample-pcf8574-hd44780)
[driver-sh1106](driver-sh1106) | OLED display | `implementation 'com.leinardi.androidthings:driver-sh1106:0.1'` | [![Bintray](https://img.shields.io/bintray/v/leinardi/androidthings/driver-sh1106.svg)](https://bintray.com/leinardi/androidthings/driver-sh1106) [changelog](driver-sh1106/CHANGELOG.md) [sample](sample-sh1106)
<!-- DRIVER_LIST_END -->

## License
Expand Down
1 change: 1 addition & 0 deletions driver-pcf8574-hd44780/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
4 changes: 4 additions & 0 deletions driver-pcf8574-hd44780/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Change Log

## [0.1] - 2017-12-19
- initial version
87 changes: 87 additions & 0 deletions driver-pcf8574-hd44780/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# HD44780 LCD driver for Android Things

[![Bintray](https://img.shields.io/bintray/v/leinardi/androidthings/driver-pcf8574-hd44780.svg?style=plastic)](https://bintray.com/leinardi/androidthings/driver-pcf8574-hd44780)
[![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 LCD peripherals built on the HD44780 chip and controlled with the PCF8574 chip.

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 [lcd-pcf8574-androidthings driver from Nilhcem](https://github.com/Nilhcem/lcd-pcf8574-androidthings)
and the [hd44780-i2c driver from gorskima](https://github.com/gorskima/hd44780-i2c)

## How to use the driver

### Gradle dependency

To use the `driver-pcf8574-hd44780` 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.androidthings:driver-pcf8574-hd44780:<version>'
}
```

### Sample usage

```java
import com.leinardi.androidthings.driver.pcf8574.hd44780.Hd44780;

// Access the LCD:
Hd44780 mLcd;

try {
mLcd = new Hd44780(BoardDefaults.getI2CPort(), Hd44780.I2cAddress.PCF8574AT, Hd44780.Geometry.LCD_20X4);
} catch (IOException e) {
// couldn't configure the LCD...
}

// Draw on the screen:

try {
mLcd.setBacklight(true);
mLcd.cursorHome();
mLcd.clearDisplay();
mLcd.setText("Hello LCD");
int[] heart = {0b00000, 0b01010, 0b11111, 0b11111, 0b11111, 0b01110, 0b00100, 0b00000};
mLcd.createCustomChar(heart, 0);
mLcd.setCursor(10, 0);
mLcd.writeCustomChar(0);
} catch (IOException e) {
// error setting LCD
}

// Close the LCD when finished:

try {
mLcd.close();
} catch (IOException e) {
// error closing LCD
}
```

## 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.

[jcenter]: https://bintray.com/leinardi/androidthings/driver-pcf8574-hd44780/_latestVersion
55 changes: 55 additions & 0 deletions driver-pcf8574-hd44780/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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.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

testImplementation deps.androidthings
testImplementation deps.powermock.module_junit4
testImplementation deps.powermock.api_mockito
}
Binary file added driver-pcf8574-hd44780/docs/HD44780.pdf
Binary file not shown.
Binary file added driver-pcf8574-hd44780/docs/PCF8574.pdf
Binary file not shown.
Binary file added driver-pcf8574-hd44780/docs/PCF8574_PCF8574A.pdf
Binary file not shown.
52 changes: 52 additions & 0 deletions driver-pcf8574-hd44780/maven.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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.github.dcendents.android-maven'

install {
repositories.mavenInstaller {
pom.project {
name 'driver-pcf8574-hd44780'
description 'Android Things driver for SH1106'
url 'https://github.com/leinardi/androidthings-drivers'
inceptionYear '2017'

packaging 'aar'
groupId 'com.leinardi.androidthings'
artifactId 'driver-pcf8574-hd44780'
version '0.1'

licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
scm {
connection 'https://github.com/leinardi/androidthings-drivers.git'
url 'https://github.com/leinardi/androidthings-drivers'

}
developers {
developer {
name "Roberto Leinardi"
email "[email protected]"
}
}
}
}
}
36 changes: 36 additions & 0 deletions driver-pcf8574-hd44780/mavenConfig.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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.
*/

def mvn_config = [:]
mvn_config.repository = 'androidthings'
mvn_config.group_id = 'com.leinardi.androidthings'
mvn_config.artifact_id = 'driver-pcf8574-hd44780'
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 = 'PCF8574-HD44780 LCD driver for Android Things'
mvn_config.tags = 'pcf8574,hd44780,android-things,android,raspberry-pi' // Comma separated
mvn_config.inception_year = '2017'
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-pcf8574-hd44780/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
18 changes: 18 additions & 0 deletions driver-pcf8574-hd44780/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!--
~ 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 xmlns:android="http://schemas.android.com/apk/res/android"
package="com.leinardi.androidthings.driver.pcf8574.hd44780" />
Loading

0 comments on commit 3f2b27d

Please sign in to comment.