forked from eurotech/RedHat-CodeStarter-2017
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: nicolatimeus <[email protected]>
- Loading branch information
1 parent
1bb3b44
commit 13e1bea
Showing
151 changed files
with
6,462 additions
and
175 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
target/ | ||
pom.xml.tag | ||
pom.xml.releaseBackup | ||
pom.xml.versionsBackup | ||
pom.xml.next | ||
release.properties | ||
dependency-reduced-pom.xml | ||
buildNumber.properties | ||
/examples/nbproject/private/ | ||
/examples/build/ | ||
/examples/dist/ | ||
/ProjectStub/nbproject/private/ | ||
/ProjectStub/build/ | ||
/ProjectStub/dist/ |
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>GrovePi</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
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,4 @@ | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
resolveWorkspaceProjects=true | ||
version=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,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
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,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>GrovePi-dio</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
4 changes: 4 additions & 0 deletions
4
grovepi-libs/GrovePi-dio/.settings/org.eclipse.core.resources.prefs
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,4 @@ | ||
eclipse.preferences.version=1 | ||
encoding//src/main/java=UTF-8 | ||
encoding//src/main/resources=UTF-8 | ||
encoding/<project>=UTF-8 |
5 changes: 5 additions & 0 deletions
5
grovepi-libs/GrovePi-dio/.settings/org.eclipse.jdt.core.prefs
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,5 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
org.eclipse.jdt.core.compiler.source=1.8 |
4 changes: 4 additions & 0 deletions
4
grovepi-libs/GrovePi-dio/.settings/org.eclipse.m2e.core.prefs
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,4 @@ | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
resolveWorkspaceProjects=true | ||
version=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,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.iot.raspberry</groupId> | ||
<artifactId>GrovePi-dio</artifactId> | ||
<version>0.1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
<repositories> | ||
<repository> | ||
<id>kura-addons</id> | ||
<name>Kura Addons</name> | ||
<url>https://raw.github.com/eurotech/kura_addons/mvn-repo</url> | ||
</repository> | ||
</repositories> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.iot.raspberry</groupId> | ||
<artifactId>GrovePi-spec</artifactId> | ||
<version>0.1.0-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>jdk</groupId> | ||
<artifactId>jdk.dio</artifactId> | ||
<version>1.0.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
62 changes: 62 additions & 0 deletions
62
grovepi-libs/GrovePi-dio/src/main/java/org/iot/raspberry/grovepi/dio/GrovePiDio.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,62 @@ | ||
package org.iot.raspberry.grovepi.dio; | ||
|
||
import java.io.IOException; | ||
import jdk.dio.DeviceManager; | ||
import jdk.dio.i2cbus.I2CDevice; | ||
import jdk.dio.i2cbus.I2CDeviceConfig; | ||
import org.iot.raspberry.grovepi.GrovePi; | ||
import org.iot.raspberry.grovepi.GrovePiSequence; | ||
import org.iot.raspberry.grovepi.GrovePiSequenceVoid; | ||
import org.iot.raspberry.grovepi.devices.GroveRgbLcd; | ||
|
||
/** | ||
* Create a new GrovePi interface using the Device I/O | ||
* | ||
* @author Eduardo Moranchel <[email protected]> | ||
*/ | ||
public class GrovePiDio implements GrovePi { | ||
|
||
private final I2CDevice device; | ||
|
||
public GrovePiDio() throws IOException { | ||
final int i2cBus = 1; // Raspberry Pi's I2C bus | ||
final int address = 0x04; // Device address | ||
final int serialClock = 3400000; // 3.4MHz Max clock | ||
final int addressSizeBits = 7; // Device address size in bits | ||
|
||
I2CDeviceConfig config = new I2CDeviceConfig(i2cBus, address, addressSizeBits, serialClock); | ||
device = DeviceManager.open(config); | ||
|
||
} | ||
|
||
@Override | ||
public <T> T exec(GrovePiSequence<T> sequence) throws IOException { | ||
synchronized (this) { | ||
return sequence.execute(new IO(device)); | ||
} | ||
} | ||
|
||
@Override | ||
public void execVoid(GrovePiSequenceVoid sequence) throws IOException { | ||
synchronized (this) { | ||
sequence.execute(new IO(device)); | ||
} | ||
} | ||
|
||
@Override | ||
public void close() { | ||
if (device != null) { | ||
try { | ||
device.close(); | ||
} catch (Exception e) { | ||
// ignore for now | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public GroveRgbLcd getLCD() throws IOException { | ||
return new GroveRgbLcdDIO(); | ||
} | ||
|
||
} |
57 changes: 57 additions & 0 deletions
57
grovepi-libs/GrovePi-dio/src/main/java/org/iot/raspberry/grovepi/dio/GroveRgbLcdDIO.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,57 @@ | ||
package org.iot.raspberry.grovepi.dio; | ||
|
||
import java.io.IOException; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import jdk.dio.DeviceManager; | ||
import jdk.dio.i2cbus.I2CDevice; | ||
import jdk.dio.i2cbus.I2CDeviceConfig; | ||
import org.iot.raspberry.grovepi.GrovePiSequenceVoid; | ||
import org.iot.raspberry.grovepi.devices.GroveRgbLcd; | ||
|
||
public class GroveRgbLcdDIO extends GroveRgbLcd { | ||
|
||
private final I2CDevice rgb; | ||
private final I2CDevice text; | ||
|
||
public GroveRgbLcdDIO() throws IOException { | ||
final int i2cBus = 1; // Raspberry Pi's I2C bus | ||
final int serialClock = 3400000; // 3.4MHz Max clock | ||
final int addressSizeBits = 7; // Device address size in bits | ||
|
||
this.text = DeviceManager.open(new I2CDeviceConfig(i2cBus, DISPLAY_TEXT_ADDR, addressSizeBits, serialClock)); | ||
|
||
this.rgb = DeviceManager.open(new I2CDeviceConfig(i2cBus, DISPLAY_RGB_ADDR, addressSizeBits, serialClock)); | ||
|
||
init(); | ||
} | ||
|
||
@Override | ||
public void execRGB(GrovePiSequenceVoid sequence) throws IOException { | ||
synchronized (this) { | ||
sequence.execute(new IO(rgb)); | ||
} | ||
} | ||
|
||
@Override | ||
public void execTEXT(GrovePiSequenceVoid sequence) throws IOException { | ||
synchronized (this) { | ||
sequence.execute(new IO(text)); | ||
} | ||
} | ||
|
||
@Override | ||
public void close() { | ||
try { | ||
rgb.close(); | ||
} catch (IOException ex) { | ||
Logger.getLogger("GrovePi").log(Level.SEVERE, null, ex); | ||
} | ||
try { | ||
text.close(); | ||
} catch (IOException ex) { | ||
Logger.getLogger("GrovePi").log(Level.SEVERE, null, ex); | ||
} | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
grovepi-libs/GrovePi-dio/src/main/java/org/iot/raspberry/grovepi/dio/IO.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 @@ | ||
package org.iot.raspberry.grovepi.dio; | ||
|
||
import java.io.IOException; | ||
import java.nio.ByteBuffer; | ||
import java.util.Arrays; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import jdk.dio.i2cbus.I2CDevice; | ||
import org.iot.raspberry.grovepi.GroveIO; | ||
|
||
public class IO implements GroveIO { | ||
|
||
private final I2CDevice device; | ||
|
||
public IO(I2CDevice device) { | ||
this.device = device; | ||
} | ||
|
||
// IO | ||
@Override | ||
public void write(int... cmd) throws IOException { | ||
ByteBuffer command = ByteBuffer.allocateDirect(cmd.length); | ||
Arrays.stream(cmd).forEach((c) -> command.put((byte) c)); | ||
command.rewind(); | ||
Logger.getLogger("GrovePi").log(Level.INFO, "[DIO IO write]{0}", Arrays.toString(cmd)); | ||
device.write(command); | ||
} | ||
|
||
@Override | ||
public int read() throws IOException { | ||
final int read = device.read(); | ||
Logger.getLogger("GrovePi").log(Level.INFO, "[DIO IO read]{0}", read); | ||
return read; | ||
} | ||
|
||
@Override | ||
public byte[] read(byte[] buffer) throws IOException { | ||
ByteBuffer bf = ByteBuffer.wrap(buffer); | ||
bf.rewind(); | ||
device.read(bf); | ||
Logger.getLogger("GrovePi").log(Level.INFO, "[DIO IO read]{0}", buffer); | ||
return buffer; | ||
} | ||
|
||
} |
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,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
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,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>GrovePi-pi4j</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
4 changes: 4 additions & 0 deletions
4
grovepi-libs/GrovePi-pi4j/.settings/org.eclipse.core.resources.prefs
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,4 @@ | ||
eclipse.preferences.version=1 | ||
encoding//src/main/java=UTF-8 | ||
encoding//src/main/resources=UTF-8 | ||
encoding/<project>=UTF-8 |
5 changes: 5 additions & 0 deletions
5
grovepi-libs/GrovePi-pi4j/.settings/org.eclipse.jdt.core.prefs
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,5 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
org.eclipse.jdt.core.compiler.source=1.8 |
4 changes: 4 additions & 0 deletions
4
grovepi-libs/GrovePi-pi4j/.settings/org.eclipse.m2e.core.prefs
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,4 @@ | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
resolveWorkspaceProjects=true | ||
version=1 |
Oops, something went wrong.