Skip to content

Commit

Permalink
encounters Issue: Simultaneous SPI Instances aren't supported in pi4j…
Browse files Browse the repository at this point in the history
…, probably because of this bug: Pi4J/pi4j-v2#244

result: IOAlreadyExistsException at runtime
  • Loading branch information
MMMMMNG committed Nov 30, 2022
1 parent 540e096 commit 059a97b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/example/LEDStrip.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,12 @@ public LEDStrip(Context pi4j, int numLEDs, double brightness, SpiBus bus, SpiChi
private SpiConfig buildSpiConfig(Context pi4j, SpiBus bus, SpiChipSelect channel, int frequency) {
return Spi.newConfigBuilder(pi4j)
.id("SPI" + 1)
.name("LED Matrix")
.name("LED Strip")
.bus(bus)
.chipSelect(channel)
.mode(SpiMode.MODE_0)
.baud(8 * frequency) //bitbanging from Bit to SPI-Byte
.provider("pigpio-spi")
.build();
}

Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/example/MCP23S17.java
Original file line number Diff line number Diff line change
Expand Up @@ -784,10 +784,11 @@ private MCP23S17(Context pi4j,
*/
private SpiConfig buildSpiConfig(Context pi4j, SpiBus bus,int frequency) {
return Spi.newConfigBuilder(pi4j)
.id("SPI" + 1)
.name("LED Matrix")
.id("SPI" + 2)
.name("GPIO-Circuit")
.description("SPI-Config for GPIO-Extension Integrated Circuits (MCP23S17)")
.bus(bus)
.chipSelect(SpiChipSelect.CS_0)
.chipSelect(SpiChipSelect.CS_2)
.mode(SpiMode.MODE_0)
.baud(frequency)
.build();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/example/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private void run(Context pi4j) throws Exception {


int pixels = 12;
ledStrip = new LEDStrip(pi4j, pixels, 1.0, SpiBus.BUS_1);
ledStrip = new LEDStrip(pi4j, pixels, 1.0, SpiBus.BUS_0);
ledStrip.allOff();
int h=0;
while(h++ < 10000) {
Expand Down
Binary file modified target/classes/com/example/Main.class
Binary file not shown.
Binary file modified target/lib/remoteDebugTest.jar
Binary file not shown.

0 comments on commit 059a97b

Please sign in to comment.