Skip to content

Commit

Permalink
Bump to Pi4J with integrated BoardInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Delporte committed Apr 25, 2024
1 parent c46d4b7 commit e15637d
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.pi4j.Pi4J;
import com.pi4j.context.Context;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
Expand All @@ -11,11 +13,15 @@
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(Context.class)
public class ContextConfiguration {

private final Context pi4j;
private final Logger logger = LoggerFactory.getLogger(ContextConfiguration.class);
private Context pi4j;

public ContextConfiguration() {
this.pi4j = Pi4J.newAutoContext();
try {
this.pi4j = Pi4J.newAutoContext();
} catch (Error e) { // TODO Temporary fix for https://github.com/Pi4J/pi4j-v2/issues/354
logger.error("Pi4J library failed to load: {}", e.getMessage());
}
}

@Bean
Expand Down

0 comments on commit e15637d

Please sign in to comment.