-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Major] Refactored gpiod memory handling, and disposing
Now can properly stop an IO and change to a different one. At most 10ms are required... This is due to the input listener waiting now only 10ms for a change, which is not interruptible at the moment
- Loading branch information
Showing
24 changed files
with
620 additions
and
965 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
51 changes: 11 additions & 40 deletions
51
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 |
---|---|---|
@@ -1,62 +1,33 @@ | ||
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 class GpioChip extends CWrapper { | ||
|
||
private boolean open; | ||
private final String name; | ||
private final String label; | ||
private final int numLines; | ||
|
||
public GpioChip(long cPointer) { | ||
GpioChip(long cPointer) { | ||
super(cPointer); | ||
this.open = true; | ||
} | ||
|
||
public boolean isOpen() { | ||
return this.open; | ||
} | ||
|
||
public void close() { | ||
if (!this.open) | ||
return; | ||
GpioD.chipClose(this); | ||
this.open = false; | ||
this.name = GpioD.chipGetName(getCPointer()); | ||
this.label = GpioD.chipGetLabel(getCPointer()); | ||
this.numLines = GpioD.chipGetNumLines(getCPointer()); | ||
} | ||
|
||
public String getName() { | ||
return GpioD.chipGetName(this); | ||
return this.name; | ||
} | ||
|
||
public String getLabel() { | ||
return GpioD.chipGetLabel(this); | ||
return this.label; | ||
} | ||
|
||
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); | ||
return this.numLines; | ||
} | ||
} |
72 changes: 0 additions & 72 deletions
72
...es/pi4j-library-gpiod/src/main/java/com/pi4j/library/gpiod/internal/GpioChipIterator.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.