Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/gpiod #322

Merged
merged 58 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
51afed5
Added initial GpioD module and first methods to GpioD class
alex9849 Jan 10, 2024
77acca7
Added a few more native lib definitions
alex9849 Jan 11, 2024
bd4651f
Added all methods and objects without implementation
alex9849 Jan 13, 2024
aa4badd
chipiterator
alex9849 Jan 13, 2024
cf3ae15
Added a few methods to Gpio objects
alex9849 Jan 13, 2024
84e36fa
Added a few methods to Gpio objects
alex9849 Jan 13, 2024
03c3a99
Added a few methods to Gpio objects
alex9849 Jan 13, 2024
f0d1f32
Added a few methods to Gpio objects
alex9849 Jan 13, 2024
27f0bb9
gitignore
alex9849 Jan 13, 2024
eb9506e
added NativeLibraryLoader
alex9849 Jan 13, 2024
bad9f71
Added generated c header file
alex9849 Jan 13, 2024
aebe362
implemented first two methods in c
alex9849 Jan 13, 2024
86dc1c9
Added c side for first methods
alex9849 Jan 13, 2024
fc791b0
Added getLines methods
alex9849 Jan 13, 2024
14ded4d
Added more Functions
alex9849 Jan 13, 2024
d9357e7
Added more Functions
alex9849 Jan 13, 2024
51c72c1
Added more Functions
alex9849 Jan 14, 2024
c034df6
Added more Functions
alex9849 Jan 14, 2024
45be449
Added more Functions
alex9849 Jan 14, 2024
1451c43
Added more Functions
alex9849 Jan 14, 2024
c42860a
Some compiler functions
alex9849 Jan 14, 2024
25bead0
Added compiler scripts
alex9849 Jan 14, 2024
3836f31
pom
alex9849 Jan 14, 2024
cfe609b
GpioD fix
alex9849 Jan 14, 2024
9e967e4
fixed warnings
alex9849 Jan 14, 2024
7364657
fixed build script
alex9849 Jan 14, 2024
a552d7a
Added some base classes
alex9849 Jan 14, 2024
f4a2b43
Added GpioDDigitalOutputProvider
alex9849 Jan 14, 2024
ce08a1e
Added GpioDDigitalOutputProvider
alex9849 Jan 14, 2024
7dcef23
comments
alex9849 Jan 14, 2024
de886ac
distribution project
alex9849 Jan 14, 2024
1b1c853
Merge branch 'Pi4J:develop' into feature/gpiod
alex9849 Jan 14, 2024
50862a1
dependencies
alex9849 Jan 16, 2024
a1d4a3c
[Project] Enabling building of gpiod plugin
eitch Jan 22, 2024
6099725
enabled lib build again
alex9849 Jan 24, 2024
095467b
Added module-info.java
alex9849 Feb 3, 2024
02d27ae
plugin initializes
alex9849 Feb 3, 2024
bf6650c
Fixed provider initializer
alex9849 Feb 3, 2024
c90d9b2
Working OutputProvider
alex9849 Feb 3, 2024
5f876e5
Added DigitalInput
alex9849 Feb 3, 2024
3d9feec
enabled lib build again
alex9849 Feb 3, 2024
ca3e820
InputProvider
alex9849 Feb 3, 2024
c7dc5cc
Testing
alex9849 Feb 3, 2024
48cab62
Added debouncing
alex9849 Feb 3, 2024
fbf1680
Fixed debouncing
alex9849 Feb 3, 2024
501a50f
Fixed debouncing
alex9849 Feb 3, 2024
e670202
Added author tag to gpiod classes
alex9849 Feb 3, 2024
e379112
Set chip to null if closed
alex9849 Feb 3, 2024
59c9a0c
Fixed native build path
alex9849 Feb 4, 2024
6df35d9
changed include path
alex9849 Feb 4, 2024
c6445d3
build script
alex9849 Feb 4, 2024
39aed92
Added gpiod back to lib path
alex9849 Feb 4, 2024
beb35e3
Prevent eventRead() from blocking thread interrupt
alex9849 Feb 5, 2024
fabc381
Added priority to GpioDProviders
alex9849 Feb 5, 2024
7a9369f
Make pi4j ship libgpiod by itself. (No need to "apt get install libgp…
alex9849 Feb 6, 2024
11482c9
Cleanup
alex9849 Feb 6, 2024
b5da771
include self compiled lib
alex9849 Feb 6, 2024
25d1187
Applied review comments
alex9849 Feb 6, 2024
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
49 changes: 49 additions & 0 deletions .run/Run on Raspberry Pi.run.xml
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>
2 changes: 2 additions & 0 deletions libraries/pi4j-library-gpiod/generate-headers.sh
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
365 changes: 365 additions & 0 deletions libraries/pi4j-library-gpiod/pom.xml

Large diffs are not rendered by default.

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);
}
}
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);
}

}
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;
}
}
Loading
Loading