GPIO control.
Bug fix.
This commit is contained in:
@@ -79,6 +79,7 @@ public class GPIO {
|
||||
* @param pin GPIO pin number
|
||||
* @return "in" if the pin is input, "out" if the pin is output, "unknown" if the direction is unknown
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public static String GetPinDirection(@NotNull RaspberryPi5BPins pin){
|
||||
Path pinPath = gpioPath.resolve("gpio"+pin.gpionumber).resolve("direction");
|
||||
if (pinPath.toFile().isFile()){
|
||||
@@ -124,13 +125,14 @@ public class GPIO {
|
||||
* @param isON true to set the pin value to 1, false to set the pin value to 0
|
||||
* @return true if the value is successfully set
|
||||
*/
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public static boolean SetValue(@NotNull RaspberryPi5BPins pin, boolean isON){
|
||||
Path pinPath = gpioPath.resolve("gpio"+pin.gpionumber).resolve("value");
|
||||
if (pinPath.toFile().isFile()){
|
||||
if (Files.isWritable(pinPath)){
|
||||
try{
|
||||
Files.write(pinPath, isON?"1".getBytes():"0".getBytes());
|
||||
Logger.info("Pin "+pin.pin+" value set to "+(isON?"1":"0"));
|
||||
//Logger.info("Pin "+pin.pin+" value set to "+(isON?"1":"0"));
|
||||
return true;
|
||||
} catch (Exception e){
|
||||
Logger.error("Failed to set pin value: "+pin.pin+", Message: "+e.getMessage());
|
||||
@@ -145,6 +147,7 @@ public class GPIO {
|
||||
* @param pin GPIO pin number
|
||||
* @return "1" if the pin value is 1, "0" if the pin value is 0, "unknown" if the value is unknown
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public static String GetValue(@NotNull RaspberryPi5BPins pin){
|
||||
Path pinPath = gpioPath.resolve("gpio"+pin.gpionumber).resolve("value");
|
||||
if (pinPath.toFile().isFile()){
|
||||
|
||||
Reference in New Issue
Block a user