-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #322 from alex9849/feature/gpiod
Feature/gpiod
- Loading branch information
Showing
43 changed files
with
5,863 additions
and
36 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,49 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="Run on Raspberry Pi" type="MavenRunConfiguration" factoryName="Maven"> | ||
<MavenSettings> | ||
<option name="myGeneralSettings" /> | ||
<option name="myRunnerSettings"> | ||
<MavenRunnerSettings> | ||
<option name="delegateBuildToMaven" value="false" /> | ||
<option name="environmentProperties"> | ||
<map /> | ||
</option> | ||
<option name="jreName" value="#USE_PROJECT_JDK" /> | ||
<option name="mavenProperties"> | ||
<map /> | ||
</option> | ||
<option name="passParentEnv" value="true" /> | ||
<option name="runMavenInBackground" value="true" /> | ||
<option name="skipTests" value="true" /> | ||
<option name="vmOptions" value="" /> | ||
</MavenRunnerSettings> | ||
</option> | ||
<option name="myRunnerParameters"> | ||
<MavenRunnerParameters> | ||
<option name="cmdOptions" /> | ||
<option name="profiles"> | ||
<set /> | ||
</option> | ||
<option name="goals"> | ||
<list> | ||
<option value="install" /> | ||
</list> | ||
</option> | ||
<option name="multimoduleDir" /> | ||
<option name="pomFileName" value="pom.xml" /> | ||
<option name="profilesMap"> | ||
<map> | ||
<entry key="remote-run" value="true" /> | ||
</map> | ||
</option> | ||
<option name="projectsCmdOptionValues"> | ||
<list /> | ||
</option> | ||
<option name="resolveToWorkspace" value="false" /> | ||
<option name="workingDirPath" value="$PROJECT_DIR$/pi4j-test" /> | ||
</MavenRunnerParameters> | ||
</option> | ||
</MavenSettings> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
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,2 @@ | ||
#!/usr/bin/env bash | ||
javac src/main/java/com/pi4j/library/gpiod/internal/GpioD.java -h src/main/native |
Large diffs are not rendered by default.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
libraries/pi4j-library-gpiod/src/main/java/com/pi4j/library/gpiod/internal/CWrapper.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,28 @@ | ||
package com.pi4j.library.gpiod.internal; | ||
|
||
import java.util.Objects; | ||
|
||
public class CWrapper { | ||
private long cPointer; | ||
|
||
public CWrapper(long cPointer) { | ||
this.cPointer = cPointer; | ||
} | ||
|
||
long getCPointer() { | ||
return cPointer; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
CWrapper cWrapper = (CWrapper) o; | ||
return cPointer == cWrapper.cPointer; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(cPointer); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
libraries/pi4j-library-gpiod/src/main/java/com/pi4j/library/gpiod/internal/GpioChip.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,53 @@ | ||
package com.pi4j.library.gpiod.internal; | ||
|
||
import java.io.Closeable; | ||
|
||
/** | ||
* <p>GpioChip</p> | ||
* | ||
* @author Alexander Liggesmeyer (<a href="https://alexander.liggesmeyer.net/">https://alexander.liggesmeyer.net/</a>) | ||
* @version $Id: $Id | ||
*/ | ||
public class GpioChip extends CWrapper implements Closeable { | ||
|
||
public GpioChip(long cPointer) { | ||
super(cPointer); | ||
} | ||
|
||
public void close() { | ||
GpioD.chipClose(this); | ||
} | ||
|
||
public String getName() { | ||
return GpioD.chipGetName(this); | ||
} | ||
|
||
public String getLabel() { | ||
return GpioD.chipGetLabel(this); | ||
} | ||
|
||
public int getNumLines() { | ||
return GpioD.chipGetNumLines(this); | ||
} | ||
|
||
public GpioLine getLine(int offset) { | ||
return GpioD.chipGetLine(this, offset); | ||
} | ||
|
||
public GpioLineBulk getLines(int[] offsets) { | ||
GpioLineBulk bulk = new GpioLineBulk(); | ||
GpioD.chipGetLines(this, offsets, bulk); | ||
return bulk; | ||
} | ||
|
||
public GpioLineBulk getLines() { | ||
GpioLineBulk bulk = new GpioLineBulk(); | ||
GpioD.chipGetAllLines(this, bulk); | ||
return bulk; | ||
} | ||
|
||
public GpioLine getLine(String name) { | ||
return GpioD.chipGetLine(this, name); | ||
} | ||
|
||
} |
72 changes: 72 additions & 0 deletions
72
...es/pi4j-library-gpiod/src/main/java/com/pi4j/library/gpiod/internal/GpioChipIterator.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,72 @@ | ||
package com.pi4j.library.gpiod.internal; | ||
|
||
import java.util.Iterator; | ||
|
||
/** | ||
* <p>GpioChipIterator</p> | ||
* | ||
* @author Alexander Liggesmeyer (<a href="https://alexander.liggesmeyer.net/">https://alexander.liggesmeyer.net/</a>) | ||
* @version $Id: $Id | ||
*/ | ||
public class GpioChipIterator extends CWrapper implements Iterator<GpioChip> { | ||
|
||
private boolean noCloseCurrent; | ||
private GpioChip next; | ||
private GpioChip current; | ||
|
||
GpioChipIterator(long cPointer) { | ||
super(cPointer); | ||
} | ||
|
||
public GpioChipIterator() { | ||
this(GpioD.chipIterNew()); | ||
} | ||
|
||
|
||
@Override | ||
protected void finalize() { | ||
if(next == null) { | ||
if(noCloseCurrent) { | ||
GpioD.chipIterFreeNoClose(this); | ||
} else { | ||
GpioD.chipIterFree(this); | ||
} | ||
} else { | ||
if(!noCloseCurrent) { | ||
GpioD.chipClose(current); | ||
} | ||
GpioD.chipIterFree(this); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean hasNext() { | ||
if(next == null) { | ||
next = GpioD.chipIterNextNoClose(this); | ||
} | ||
return next != null; | ||
} | ||
|
||
@Override | ||
public GpioChip next() { | ||
if(next == null) { | ||
if(noCloseCurrent) { | ||
current = GpioD.chipIterNextNoClose(this); | ||
} else { | ||
current = GpioD.chipIterNext(this); | ||
} | ||
} else { | ||
if(current != null && !noCloseCurrent) { | ||
GpioD.chipClose(current); | ||
} | ||
current = next; | ||
noCloseCurrent = false; | ||
next = null; | ||
} | ||
return current; | ||
} | ||
|
||
public void noCloseCurrent() { | ||
this.noCloseCurrent = true; | ||
} | ||
} |
Oops, something went wrong.